Merge branch 'develop' into bug/JAL-1988_JAL-3772_improved_quit_handling
[jalview.git] / src / jalview / ws / dbsources / Pfam.java
index 2587bac..316c1aa 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,26 @@ 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", UNIPROT = "uniprot";
+
+  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";
 
-  static final String PFAM_BASEURL_KEY = "PFAM_BASEURL";
+  protected String alignmentType;
+
+  /**
+   * docs are http://www.ebi.ac.uk/interpro/api/
+   */
+  private static final String DEFAULT_PFAM_BASEURL = "https://www.ebi.ac.uk/interpro/api/entry/pfam/$PFAMID$/?annotation=alignment:$ALTYPE$";
 
-  private static final String DEFAULT_PFAM_BASEURL = "https://pfam.xfam.org";
   static
   {
     Platform.addJ2SDirectDatabaseCall(DEFAULT_PFAM_BASEURL);
@@ -54,6 +68,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 +153,4 @@ abstract public class Pfam extends Xfam
   {
     return DBRefSource.PFAM;
   }
-
 }