JAL-3855 update EBI Alphafold barcoded URL generation to v2.cif/json URLs
[jalview.git] / src / jalview / ws / dbsources / EBIAlfaFold.java
index 7c72f4b..97eacab 100644 (file)
@@ -72,6 +72,8 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
 
   private static final int PDB_ID_LENGTH = 4;
 
+  private static String AF_VERSION = "2";
+
   public EBIAlfaFold()
   {
     super();
@@ -123,15 +125,24 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
     return "1";
   }
 
-  public static String getAlphaFoldCifDownloadUrl(String id)
+  public static String getAlphaFoldCifDownloadUrl(String id, String vnum)
   {
-    return "https://alphafold.ebi.ac.uk/files/" + id + "-model_v1.cif";
+    if (vnum == null || vnum.length() == 0)
+    {
+      vnum = AF_VERSION;
+    }
+    return "https://alphafold.ebi.ac.uk/files/" + id + "-model_v" + vnum
+            + ".cif";
   }
 
-  public static String getAlphaFoldPaeDownloadUrl(String id)
+  public static String getAlphaFoldPaeDownloadUrl(String id, String vnum)
   {
+    if (vnum == null || vnum.length() == 0)
+    {
+      vnum = AF_VERSION;
+    }
     return "https://alphafold.ebi.ac.uk/files/" + id
-            + "-predicted_aligned_error_v1.json";
+            + "-predicted_aligned_error_v" + vnum + ".json";
   }
 
   /*
@@ -168,7 +179,7 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
-    String alphaFoldCif = getAlphaFoldCifDownloadUrl(id);
+    String alphaFoldCif = getAlphaFoldCifDownloadUrl(id, AF_VERSION);
     if (retrievalUrl != null)
     {
       alphaFoldCif = retrievalUrl;
@@ -200,9 +211,10 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy
       // import PAE as contact matrix - assume this will work if there was a
       // model
       File pae = File.createTempFile(id, "pae_json");
-      String paeURL = getAlphaFoldPaeDownloadUrl(id);
-      
-      if (retrievalUrl!=null) {
+      String paeURL = getAlphaFoldPaeDownloadUrl(id, AF_VERSION);
+
+      if (retrievalUrl != null)
+      {
         // manufacture the PAE url from a url like ...-model-vN.cif
         paeURL = retrievalUrl.replace("model","predicted_aligned_error").replace(".cif",".json");
       }