+ public static boolean importPaeJSONAsContactMatrixToSequence(
+ AlignmentI pdbAlignment, InputStream pae_input, int index,
+ String seqId) throws IOException, ParseException
+ {
+ SequenceI sequence = null;
+ /* debugging */
+ SequenceI[] seqs = pdbAlignment.getSequencesArray();
+ if (seqs == null)
+ Console.debug("******* sequences is null");
+ else
+ {
+ for (int i = 0; i < seqs.length; i++)
+ {
+ SequenceI s = seqs[i];
+ }
+ }
+ /* end debug */
+ if (seqId == null)
+ {
+ int seqToGet = index > 0 ? index : 0;
+ sequence = pdbAlignment.getSequenceAt(seqToGet);
+ Console.debug("***** Got sequence at index " + seqToGet + ": "
+ + (sequence == null ? null : sequence.getName()));
+ }
+ if (sequence == null)
+ {
+ SequenceI[] sequences = pdbAlignment.findSequenceMatch(seqId);
+ if (sequences == null || sequences.length < 1)
+ {
+ Console.warn("Could not find sequence with id '" + seqId
+ + "' to attach pAE matrix to. Ignoring matrix.");
+ return false;
+ }
+ else
+ {
+ sequence = sequences[0]; // just use the first sequence with this seqId
+ }
+ }
+
+ Object paeJson = Platform.parseJSON(pae_input);
+ JSONObject paeDict = null;
+ if (paeJson instanceof JSONObject)
+ {
+ Console.debug("***** paeJson is a JSONObject");
+ paeDict = (JSONObject) paeJson;
+ }
+ else if (paeJson instanceof JSONArray)
+ {
+ JSONArray jsonArray = (JSONArray) paeJson;
+ if (jsonArray.size() > 0)
+ paeDict = (JSONObject) jsonArray.get(0);
+ }
+
+ if (paeDict == null)
+ {
+ Console.debug("JSON file did not parse properly.");
+ return false;
+ }
+ ContactMatrixI matrix = new PAEContactMatrix(sequence,
+ (Map<String, Object>) paeDict);
+
+ AlignmentAnnotation cmannot = sequence.addContactList(matrix);
+ pdbAlignment.addAnnotation(cmannot);
+
+ return true;
+ }
+
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping[] smArray, InputStream paeInput)
+ throws IOException, ParseException
+ {
+ boolean someDone = false;
+ Console.debug("##### smArray.length=" + smArray.length);
+ for (StructureMapping sm : smArray)
+ {
+ Console.debug("##### sm[n]=" + sm.getPdbId());
+ boolean thisDone = importPaeJSONAsContactMatrixToStructure(sm,
+ paeInput);
+ Console.debug("##### thisDone = " + thisDone);
+ someDone |= thisDone;
+ }
+ return someDone;
+ }
+
+ public static boolean importPaeJSONAsContactMatrixToStructure(
+ StructureMapping sm, InputStream paeInput)
+ throws IOException, ParseException
+ {
+
+ List<Object> pae_obj = (List<Object>) Platform.parseJSON(paeInput);