+
+ 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;
+ }
+
+ // ###### TEST THIS
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping[] smArray, InputStream paeInput, String label)
+ throws IOException, ParseException
+ {
+ boolean someDone = false;
+ for (StructureMapping sm : smArray)
+ {
+ boolean thisDone = importPaeJSONAsContactMatrixToStructure(sm,
+ paeInput, label);
+ someDone |= thisDone;
+ }
+ return someDone;
+ }
+
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping sm, InputStream paeInput, String label)
+ throws IOException, ParseException
+ {
+ JSONObject pae_obj = parseJSONtoPAEContactMatrix(paeInput);
+ if (pae_obj == null)
+ {
+ Console.debug("JSON file did not parse properly.");
+ return false;
+ }
+
+ SequenceI seq = sm.getSequence();
+ ContactMatrixI matrix = new PAEContactMatrix(seq,
+ (Map<String, Object>) pae_obj);
+ AlignmentAnnotation cmannot = sm.getSequence().addContactList(matrix);
+ /* this already happens in Sequence.addContactList()
+ seq.addAlignmentAnnotation(cmannot);
+ */