+
+ return true;
+ }
+
+ public static JSONObject parseJSONtoPAEContactMatrix(
+ InputStream pae_input) throws IOException, ParseException
+ {
+ Object paeJson = Platform.parseJSON(pae_input);
+ JSONObject paeDict = null;
+ if (paeJson instanceof JSONObject)
+ {
+ paeDict = (JSONObject) paeJson;
+ }
+ else if (paeJson instanceof JSONArray)
+ {
+ JSONArray jsonArray = (JSONArray) paeJson;
+ if (jsonArray.size() > 0)
+ paeDict = (JSONObject) jsonArray.get(0);
+ }
+
+ return paeDict;
+ }
+
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping[] smArray, InputStream paeInput)
+ throws IOException, ParseException
+ {
+ boolean someDone = false;
+ for (StructureMapping sm : smArray)
+ {
+ boolean thisDone = importPaeJSONAsContactMatrixToStructure(sm,
+ paeInput);
+ someDone |= thisDone;
+ }
+ return someDone;
+ }
+
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping sm, File paeFile)
+ throws FileNotFoundException, IOException, ParseException
+ {
+ return importPaeJSONAsContactMatrixToStructure(sm,
+ new FileInputStream(paeFile));
+ }
+
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping sm, InputStream paeInput)
+ throws IOException, ParseException
+ {
+ JSONObject pae_obj = parseJSONtoPAEContactMatrix(paeInput);
+ if (pae_obj == null)
+ {
+ Console.debug("JSON file did not parse properly.");
+ return false;
+ }
+
+ ContactMatrixI matrix = new PAEContactMatrix(sm.getSequence(),
+ (Map<String, Object>) pae_obj);
+
+ AlignmentAnnotation cmannot = sm.getSequence().addContactList(matrix);
+ // sm.getSequence().addAlignmentAnnotation(cmannot);
+ sm.transfer(cmannot);
+ // return true;
+
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance);
+ List<AlignedCodonFrame> acfList = ssm.getSequenceMappings();
+