JAL-629 JAL-4124 JAL-3855 test to check we can import PAE matrices in a variety of...
[jalview.git] / src / jalview / ws / dbsources / EBIAlfaFold.java
index b3bcfd9..72fd8d9 100644 (file)
@@ -402,8 +402,26 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
       }
     }
 
+    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
+  {
     Object paeJson = Platform.parseJSON(pae_input);
-    JSONObject paeDict = null;
+    JSONObject paeDict=null;
     if (paeJson instanceof JSONObject)
     {
       Console.debug("***** paeJson is a JSONObject");
@@ -416,18 +434,7 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
         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(
@@ -452,7 +459,7 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
           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.");
@@ -460,7 +467,7 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
     }
 
     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);