Merge branch 'develop' into features/r2_11_2/JAL-3829_3dbeacons
[jalview.git] / src / jalview / datamodel / PDBEntry.java
index 97fb08d..672a59e 100755 (executable)
@@ -46,11 +46,21 @@ public class PDBEntry
 
   public enum Type
   {
-    // TODO is FILE needed; if not is this needed or can we
+    // TODO is FILE needed; if not is this enum needed, or can we
     // use FileFormatI for PDB, MMCIF?
-    PDB("pdb", "xml"), MMCIF("mmcif", "mmcif"), FILE("?", "?");
+    PDB("pdb", "pdb"), MMCIF("mmcif", "cif"), FILE("?", "?");
+
+    /*
+     * file extension for cached structure file; must be one that
+     * is recognised by Chimera 'open' command
+     * @see https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/filetypes.html
+     */
     String ext;
 
+    /*
+     * format specifier used in dbfetch request
+     * @see http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/dbfetch.databases#pdb
+     */
     String format;
 
     private Type(String fmt, String ex)
@@ -63,6 +73,7 @@ public class PDBEntry
     {
       return format;
     }
+
     public String getExtension()
     {
       return ext;
@@ -141,7 +152,6 @@ public class PDBEntry
   {
   }
 
-
   public PDBEntry(String pdbId, String chain, PDBEntry.Type type,
           String filePath)
   {
@@ -154,7 +164,8 @@ public class PDBEntry
    * @param entryType
    * @param filePath
    */
-  void init(String pdbId, String chain, PDBEntry.Type entryType, String filePath)
+  void init(String pdbId, String chain, PDBEntry.Type entryType,
+          String filePath)
   {
     this.id = pdbId;
     this.type = entryType == null ? null : entryType.toString();
@@ -189,8 +200,8 @@ public class PDBEntry
   {
     if (!DBRefSource.PDB.equals(dbr.getSource()))
     {
-      throw new IllegalArgumentException("Invalid source: "
-              + dbr.getSource());
+      throw new IllegalArgumentException(
+              "Invalid source: " + dbr.getSource());
     }
 
     String pdbId = dbr.getAccessionId();
@@ -449,4 +460,27 @@ public class PDBEntry
     }
     return true;
   }
+  
+
+  private static final String RETRIEVE_FROM="RETRIEVE_FROM";
+  /**
+   * Permanent URI for retrieving the original structure data
+   * @param urlStr
+   */
+  public void setRetrievalUrl(String urlStr)
+  {
+    setProperty(RETRIEVE_FROM, urlStr);
+  }
+  /**
+   * get the Permanent URI for retrieving the original structure data
+   */
+  public String getRetrievalUrl()
+  {
+    return (String) getProperty(RETRIEVE_FROM);
+  }
+
+  public boolean hasRetrievalUrl()
+  {
+    return (properties!=null && properties.containsKey(RETRIEVE_FROM));
+  }
 }