From 7bf12085343eb53718fc159b281823243f2c9f9b Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 6 Oct 2022 12:31:14 +0100 Subject: [PATCH] JAL-1551 formatting --- src/jalview/io/StockholmFile.java | 2 +- src/jalview/ws/dbsources/Pfam.java | 32 +++++++++++++++------------ src/jalview/ws/dbsources/PfamFull.java | 2 +- src/jalview/ws/dbsources/PfamSeed.java | 2 +- test/jalview/ws/dbsources/PfamFullTest.java | 9 ++++---- test/jalview/ws/dbsources/PfamSeedTest.java | 9 ++++---- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index 5d645ca..a3f7531 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -219,7 +219,7 @@ public class StockholmFile extends AlignFile if (!r.search(nextLine())) { throw new IOException(MessageManager - .getString("exception.stockholm_invalid_format")); + .getString("exception.stockholm_invalid_format") +" ("+r+")"); } else { diff --git a/src/jalview/ws/dbsources/Pfam.java b/src/jalview/ws/dbsources/Pfam.java index 0c21d42..93001a4 100644 --- a/src/jalview/ws/dbsources/Pfam.java +++ b/src/jalview/ws/dbsources/Pfam.java @@ -22,12 +22,12 @@ package jalview.ws.dbsources; import java.util.Locale; +import com.stevesoft.pat.Regex; + import jalview.bin.Cache; import jalview.datamodel.DBRefSource; import jalview.util.Platform; -import com.stevesoft.pat.Regex; - /** * TODO: later PFAM is a complex datasource - it could return a tree in addition * to an alignment TODO: create interface to pass alignment properties and tree @@ -38,17 +38,21 @@ import com.stevesoft.pat.Regex; */ abstract public class Pfam extends Xfam { - 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; - } + 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"; static @@ -61,11 +65,11 @@ abstract public class Pfam extends Xfam super(); } - - String getURL(String queries) + @Override + String getURL(String queries) { - return getPfamDownloadURL( - queries.trim().toUpperCase(Locale.ROOT), alignmentType); + return getPfamDownloadURL(queries.trim().toUpperCase(Locale.ROOT), + alignmentType); } /* diff --git a/src/jalview/ws/dbsources/PfamFull.java b/src/jalview/ws/dbsources/PfamFull.java index ffb5e41..6cf5fda 100644 --- a/src/jalview/ws/dbsources/PfamFull.java +++ b/src/jalview/ws/dbsources/PfamFull.java @@ -29,7 +29,7 @@ public class PfamFull extends Pfam public PfamFull() { super(); - alignmentType=FULL; + alignmentType = FULL; } /* diff --git a/src/jalview/ws/dbsources/PfamSeed.java b/src/jalview/ws/dbsources/PfamSeed.java index 6d486e8..45a1840 100644 --- a/src/jalview/ws/dbsources/PfamSeed.java +++ b/src/jalview/ws/dbsources/PfamSeed.java @@ -31,7 +31,7 @@ public class PfamSeed extends Pfam public PfamSeed() { super(); - alignmentType=SEED; + alignmentType = SEED; } /* diff --git a/test/jalview/ws/dbsources/PfamFullTest.java b/test/jalview/ws/dbsources/PfamFullTest.java index eb2f147..fd59ef3 100644 --- a/test/jalview/ws/dbsources/PfamFullTest.java +++ b/test/jalview/ws/dbsources/PfamFullTest.java @@ -22,11 +22,11 @@ package jalview.ws.dbsources; import static org.testng.Assert.assertEquals; -import jalview.bin.Cache; - import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import jalview.bin.Cache; + public class PfamFullTest { @BeforeClass(alwaysRun = true) @@ -38,14 +38,15 @@ public class PfamFullTest @Test(groups = "Functional") public void testGetURL() { - String path = "www.ebi.ac.uk/interpro/wwwapi/entry/pfam/ABC/?annotation=alignment:full&download"; + 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://www.ebi.ac.uk/interpro/wwwapi/entry/pfam/$PFAMID$/?annotation=alignment:$ALTYPE$&download"); + 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); } diff --git a/test/jalview/ws/dbsources/PfamSeedTest.java b/test/jalview/ws/dbsources/PfamSeedTest.java index 451810b..d228c35 100644 --- a/test/jalview/ws/dbsources/PfamSeedTest.java +++ b/test/jalview/ws/dbsources/PfamSeedTest.java @@ -22,11 +22,11 @@ package jalview.ws.dbsources; import static org.testng.Assert.assertEquals; -import jalview.bin.Cache; - import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import jalview.bin.Cache; + public class PfamSeedTest { @BeforeClass(alwaysRun = true) @@ -38,14 +38,15 @@ public class PfamSeedTest @Test(groups = "Functional") public void testGetURL() { - String path = "pfam.xfam.org/family/ABC/alignment/seed/gzipped"; + String path = "www.ebi.ac.uk/interpro/wwwapi/entry/pfam/ABC/?annotation=alignment:seed&download"; // with default value for domain String url = new PfamSeed().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 PfamSeed().getURL(" abc "); assertEquals(url, "http://" + path); } -- 1.7.10.2