Merge branch 'develop' into features/r2_11_2_alphafold/JAL-629
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 27 Feb 2023 09:52:13 +0000 (09:52 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 27 Feb 2023 09:52:13 +0000 (09:52 +0000)
1  2 
src/jalview/ws/dbsources/EBIAlfaFold.java

@@@ -292,8 -292,14 +292,8 @@@ public class EBIAlfaFold extends EbiFil
        if (ssm != null)
        {
          String structFile = isStructId ? ssm.findFileForPDBId(id) : id;
 -        Console.debug("##### AHA! structFile = " + structFile);
 -        Console.debug("##### structFile "
 -                + (ssm.isPDBFileRegistered(structFile) ? "IS " : "is NOT ")
 -                + "registered.");
  
          StructureMapping[] smArray = ssm.getMapping(structFile);
 -        Console.debug("##### AHA! smArray obtained with " + smArray.length
 -                + " elements");
  
          try
          {
            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)
      {
        }
      }
  
+     JSONObject paeDict = parseJSONtoPAEContactMatrix(pae_input);
+     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 JSONObject parseJSONtoPAEContactMatrix(
 -          InputStream pae_input) throws IOException,ParseException
++          InputStream pae_input) throws IOException, ParseException
+   {
      Object paeJson = Platform.parseJSON(pae_input);
 -    JSONObject paeDict=null;
 +    JSONObject paeDict = null;
      if (paeJson instanceof JSONObject)
      {
 -      Console.debug("***** paeJson is a JSONObject");
        paeDict = (JSONObject) paeJson;
      }
      else if (paeJson instanceof JSONArray)
          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;
+     return paeDict;
    }
  
    public static boolean importPaeJSONAsContactMatrixToStructure(
            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;
            throws IOException, ParseException
    {
  
-     List<Object> pae_obj = (List<Object>) Platform.parseJSON(paeInput);
+     JSONObject pae_obj = parseJSONtoPAEContactMatrix(paeInput);
      if (pae_obj == null)
      {
        Console.debug("JSON file did not parse properly.");
      }
  
      ContactMatrixI matrix = new PAEContactMatrix(sm.getSequence(),
-             (Map<String, Object>) pae_obj.get(0));
+             (Map<String, Object>) pae_obj);
  
      AlignmentAnnotation cmannot = sm.getSequence().addContactList(matrix);
      // sm.getSequence().addAlignmentAnnotation(cmannot);