From 0ad352a33dee2be3c35a875475e504a29a8b3ad6 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 6 Oct 2022 12:21:28 +0100 Subject: [PATCH] JAL-4073 Pfam retrieval now works via a template including $PFAMID$ and $ALTYPE$ (full, seed, etc). Also changed name of PFAM_BASEURL_KEY to PFAM_INTERPRO_URL_TEMPLATE to avoid misconfiguration --- src/jalview/ws/dbsources/Pfam.java | 29 +++++++++++++++++++-------- src/jalview/ws/dbsources/PfamFull.java | 7 +------ src/jalview/ws/dbsources/PfamSeed.java | 7 +------ test/jalview/ws/dbsources/PfamFullTest.java | 4 ++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/jalview/ws/dbsources/Pfam.java b/src/jalview/ws/dbsources/Pfam.java index 2587bac..0c21d42 100644 --- a/src/jalview/ws/dbsources/Pfam.java +++ b/src/jalview/ws/dbsources/Pfam.java @@ -20,6 +20,8 @@ */ package jalview.ws.dbsources; +import java.util.Locale; + import jalview.bin.Cache; import jalview.datamodel.DBRefSource; import jalview.util.Platform; @@ -36,14 +38,19 @@ import com.stevesoft.pat.Regex; */ abstract public class Pfam extends Xfam { - /* - * append to URLs to retrieve as a gzipped file - */ - protected static final String GZIPPED = "/gzipped"; - - static final String PFAM_BASEURL_KEY = "PFAM_BASEURL"; + public static final String FULL="full",RP35="rp35",RP15="rp15",RP75="rp75",RP55="rp55",SEED="seed"; + + public String getPfamDownloadURL(String id,String alType) { + String url = Cache.getDefault(PFAM_BASEURL_KEY,DEFAULT_PFAM_BASEURL); + url = url.replace("$PFAMID$",id); + url = url.replace("$ALTYPE$",alType); + return url; + } + static final String PFAM_BASEURL_KEY = "PFAM_INTERPRO_URL_TEMPLATE"; + + protected String alignmentType; + private static final String DEFAULT_PFAM_BASEURL = "https://www.ebi.ac.uk/interpro/wwwapi/entry/pfam/$PFAMID$/?annotation=alignment:$ALTYPE$&download"; - private static final String DEFAULT_PFAM_BASEURL = "https://pfam.xfam.org"; static { Platform.addJ2SDirectDatabaseCall(DEFAULT_PFAM_BASEURL); @@ -54,6 +61,13 @@ abstract public class Pfam extends Xfam super(); } + + String getURL(String queries) + { + return getPfamDownloadURL( + queries.trim().toUpperCase(Locale.ROOT), alignmentType); + } + /* * (non-Javadoc) * @@ -132,5 +146,4 @@ abstract public class Pfam extends Xfam { return DBRefSource.PFAM; } - } diff --git a/src/jalview/ws/dbsources/PfamFull.java b/src/jalview/ws/dbsources/PfamFull.java index d71892b..ffb5e41 100644 --- a/src/jalview/ws/dbsources/PfamFull.java +++ b/src/jalview/ws/dbsources/PfamFull.java @@ -29,12 +29,7 @@ public class PfamFull extends Pfam public PfamFull() { super(); - } - - @Override - public String getURLSuffix() - { - return "/alignment/full" + GZIPPED; + alignmentType=FULL; } /* diff --git a/src/jalview/ws/dbsources/PfamSeed.java b/src/jalview/ws/dbsources/PfamSeed.java index f64d07f..6d486e8 100644 --- a/src/jalview/ws/dbsources/PfamSeed.java +++ b/src/jalview/ws/dbsources/PfamSeed.java @@ -31,12 +31,7 @@ public class PfamSeed extends Pfam public PfamSeed() { super(); - } - - @Override - public String getURLSuffix() - { - return "/alignment/seed" + GZIPPED; + alignmentType=SEED; } /* diff --git a/test/jalview/ws/dbsources/PfamFullTest.java b/test/jalview/ws/dbsources/PfamFullTest.java index 23cceb2..eb2f147 100644 --- a/test/jalview/ws/dbsources/PfamFullTest.java +++ b/test/jalview/ws/dbsources/PfamFullTest.java @@ -38,14 +38,14 @@ public class PfamFullTest @Test(groups = "Functional") public void testGetURL() { - String path = "pfam.xfam.org/family/ABC/alignment/full/gzipped"; + String path = "www.ebi.ac.uk/interpro/wwwapi/entry/pfam/ABC/?annotation=alignment:full&download"; // with default value for domain String url = new PfamFull().getURL(" abc "); assertEquals(url, "https://" + path); // with override in properties - Cache.setProperty(Pfam.PFAM_BASEURL_KEY, "http://pfam.xfam.org"); + Cache.setProperty(Pfam.PFAM_BASEURL_KEY, "http://www.ebi.ac.uk/interpro/wwwapi/entry/pfam/$PFAMID$/?annotation=alignment:$ALTYPE$&download"); url = new PfamFull().getURL(" abc "); assertEquals(url, "http://" + path); } -- 1.7.10.2