JAL-1551 formatting
[jalview.git] / src / jalview / ws / dbsources / Pfam.java
index 6cec4ef..93001a4 100644 (file)
  */
 package jalview.ws.dbsources;
 
-import jalview.bin.Cache;
-import jalview.datamodel.DBRefSource;
+import java.util.Locale;
 
 import com.stevesoft.pat.Regex;
 
+import jalview.bin.Cache;
+import jalview.datamodel.DBRefSource;
+import jalview.util.Platform;
+
 /**
  * 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
@@ -35,14 +38,40 @@ import com.stevesoft.pat.Regex;
  */
 abstract public class Pfam extends Xfam
 {
-  private static final String PFAM_DOMAIN_KEY = "PFAM_DOMAIN";
-  private static final String DEFAULT_PFAM_DOMAIN = "http://pfam.xfam.org";
+  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
+  {
+    Platform.addJ2SDirectDatabaseCall(DEFAULT_PFAM_BASEURL);
+  }
 
   public Pfam()
   {
     super();
   }
 
+  @Override
+  String getURL(String queries)
+  {
+    return getPfamDownloadURL(queries.trim().toUpperCase(Locale.ROOT),
+            alignmentType);
+  }
+
   /*
    * (non-Javadoc)
    * 
@@ -96,9 +125,9 @@ abstract public class Pfam extends Xfam
   }
 
   @Override
-  protected String getDomain()
+  protected String getURLPrefix()
   {
-    return Cache.getDefault(PFAM_DOMAIN_KEY, DEFAULT_PFAM_DOMAIN);
+    return Cache.getDefault(PFAM_BASEURL_KEY, DEFAULT_PFAM_BASEURL);
   }
 
   /*
@@ -121,5 +150,4 @@ abstract public class Pfam extends Xfam
   {
     return DBRefSource.PFAM;
   }
-
 }