Merge branch 'develop' into releases/Release_2_11_2_Branch
authorJim Procter <j.procter@dundee.ac.uk>
Thu, 6 Oct 2022 11:36:33 +0000 (12:36 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Thu, 6 Oct 2022 11:36:33 +0000 (12:36 +0100)
help/markdown/releases/release-2_11_2_5.md
src/jalview/io/FileParse.java
src/jalview/io/StockholmFile.java
src/jalview/ws/dbsources/Pfam.java
src/jalview/ws/dbsources/PfamFull.java
src/jalview/ws/dbsources/PfamSeed.java
test/jalview/ws/dbsources/PfamFullTest.java
test/jalview/ws/dbsources/PfamSeedTest.java

index 4266bad..c470ee7 100644 (file)
@@ -7,6 +7,8 @@ channel: "release"
 ## New Features
 
 ## Issues Resolved
+- <!-- JAL-4073 --> Pfam Full and Seed alignment retrieval switched to the Interpro Server
+- <!-- JAL-4074 --> URLs reporting Content-Type as application/gzip not being recognized as a gzipped stream
 - <!-- JAL-4063 --> Clustalx colour scheme renamed (back) to Clustal in the GUI
 - <!-- JAL-4014 --> Spanish translations added for gecos colour schemes introduced in 2.11.2.4
 - <!-- JAL-3612 --> Overview doesn't colour nested features the same as in the alignment view 
index 2dec559..d3a6ba9 100755 (executable)
@@ -343,7 +343,7 @@ public class FileParse
     }
     String encoding = _conn.getContentEncoding();
     String contentType = _conn.getContentType();
-    boolean isgzipped = "application/x-gzip".equalsIgnoreCase(contentType)
+    boolean isgzipped = "application/x-gzip".equalsIgnoreCase(contentType) || contentType.endsWith("gzip")
             || "gzip".equals(encoding);
     Exception e = null;
     InputStream inputStream = _conn.getInputStream();
index 5d645ca..a3f7531 100644 (file)
@@ -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
     {
index 2587bac..93001a4 100644 (file)
  */
 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
@@ -36,14 +38,23 @@ 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";
+  public static final String FULL = "full", RP35 = "rp35", RP15 = "rp15",
+          RP75 = "rp75", RP55 = "rp55", SEED = "seed";
 
-  static final String PFAM_BASEURL_KEY = "PFAM_BASEURL";
+  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 +65,13 @@ abstract public class Pfam extends Xfam
     super();
   }
 
+  @Override
+  String getURL(String queries)
+  {
+    return getPfamDownloadURL(queries.trim().toUpperCase(Locale.ROOT),
+            alignmentType);
+  }
+
   /*
    * (non-Javadoc)
    * 
@@ -132,5 +150,4 @@ abstract public class Pfam extends Xfam
   {
     return DBRefSource.PFAM;
   }
-
 }
index d71892b..6cf5fda 100644 (file)
@@ -29,12 +29,7 @@ public class PfamFull extends Pfam
   public PfamFull()
   {
     super();
-  }
-
-  @Override
-  public String getURLSuffix()
-  {
-    return "/alignment/full" + GZIPPED;
+    alignmentType = FULL;
   }
 
   /*
index f64d07f..45a1840 100644 (file)
@@ -31,12 +31,7 @@ public class PfamSeed extends Pfam
   public PfamSeed()
   {
     super();
-  }
-
-  @Override
-  public String getURLSuffix()
-  {
-    return "/alignment/seed" + GZIPPED;
+    alignmentType = SEED;
   }
 
   /*
index 23cceb2..fd59ef3 100644 (file)
@@ -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 = "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);
   }
index 451810b..d228c35 100644 (file)
@@ -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);
   }