From: Jim Procter Date: Fri, 24 Jun 2022 16:17:32 +0000 (+0100) Subject: JAL-3855 update EBI Alphafold barcoded URL generation to v2.cif/json URLs X-Git-Tag: Release_2_11_3_0~23^2~55 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=256638175cb9041da39d5c79090f537971e43df3 JAL-3855 update EBI Alphafold barcoded URL generation to v2.cif/json URLs --- diff --git a/src/jalview/fts/service/alphafold/AlphafoldRestClient.java b/src/jalview/fts/service/alphafold/AlphafoldRestClient.java index 7cecaeb..7e95dd2 100644 --- a/src/jalview/fts/service/alphafold/AlphafoldRestClient.java +++ b/src/jalview/fts/service/alphafold/AlphafoldRestClient.java @@ -20,12 +20,10 @@ */ package jalview.fts.service.alphafold; -import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Objects; import jalview.bin.Console; @@ -69,7 +67,8 @@ public class AlphafoldRestClient String alphaFoldId = "AF-" + upref.getAccessionId() + "-F1"; try { - String urls = EBIAlfaFold.getAlphaFoldCifDownloadUrl(alphaFoldId); + String urls = EBIAlfaFold.getAlphaFoldCifDownloadUrl(alphaFoldId, + null); URL url = new URL(urls); if (!HttpUtils.checkUrlAvailable(url, 50)) { diff --git a/src/jalview/ws/dbsources/EBIAlfaFold.java b/src/jalview/ws/dbsources/EBIAlfaFold.java index 7c72f4b..97eacab 100644 --- a/src/jalview/ws/dbsources/EBIAlfaFold.java +++ b/src/jalview/ws/dbsources/EBIAlfaFold.java @@ -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"); }