Jalview 2.6 source licence
[jalview.git] / src / jalview / ws / dbsources / Pdb.java
index e6d46da..ae1f794 100644 (file)
@@ -1,5 +1,19 @@
-/**\r
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
+ * \r
+ * This file is part of Jalview.\r
+ * \r
+ * Jalview is free software: you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License \r
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
+ * \r
+ * Jalview is distributed in the hope that it will be useful, but \r
+ * WITHOUT ANY WARRANTY; without even the implied warranty \r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
+ * PURPOSE.  See the GNU General Public License for more details.\r
  * \r
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
  */\r
 package jalview.ws.dbsources;\r
 \r
@@ -27,16 +41,19 @@ import jalview.ws.seqfetcher.DbSourceProxyImpl;
 \r
 /**\r
  * @author JimP\r
- *\r
+ * \r
  */\r
 public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy\r
 {\r
-  public Pdb() {\r
+  public Pdb()\r
+  {\r
     super();\r
     addDbSourceProperty(DBRefSource.PROTSEQDB);\r
   }\r
 \r
-  /* (non-Javadoc)\r
+  /*\r
+   * (non-Javadoc)\r
+   * \r
    * @see jalview.ws.DbSourceProxy#getAccessionSeparator()\r
    */\r
   public String getAccessionSeparator()\r
@@ -45,7 +62,9 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
     return null;\r
   }\r
 \r
-  /* (non-Javadoc)\r
+  /*\r
+   * (non-Javadoc)\r
+   * \r
    * @see jalview.ws.DbSourceProxy#getAccessionValidator()\r
    */\r
   public Regex getAccessionValidator()\r
@@ -53,7 +72,9 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
     return new Regex("([1-9][0-9A-Za-z]{3}):?([ _A-Za-z0-9]?)");\r
   }\r
 \r
-  /* (non-Javadoc)\r
+  /*\r
+   * (non-Javadoc)\r
+   * \r
    * @see jalview.ws.DbSourceProxy#getDbSource()\r
    */\r
   public String getDbSource()\r
@@ -61,14 +82,19 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
     return DBRefSource.PDB;\r
   }\r
 \r
-  /* (non-Javadoc)\r
+  /*\r
+   * (non-Javadoc)\r
+   * \r
    * @see jalview.ws.DbSourceProxy#getDbVersion()\r
    */\r
   public String getDbVersion()\r
   {\r
     return "0";\r
   }\r
-  /* (non-Javadoc)\r
+\r
+  /*\r
+   * (non-Javadoc)\r
+   * \r
    * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[])\r
    */\r
   public AlignmentI getSequenceRecords(String queries) throws Exception\r
@@ -88,18 +114,17 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
     }\r
     if (queries.length() > 4 && chain == null)\r
     {\r
-      chain = queries.substring(4,5);\r
+      chain = queries.substring(4, 5);\r
       id = queries.substring(0, 4);\r
     }\r
     if (!isValidReference(id))\r
     {\r
-      System.err.println("Ignoring invalid pdb query: '"+id+"'");\r
+      System.err.println("Ignoring invalid pdb query: '" + id + "'");\r
       stopQuery();\r
       return null;\r
     }\r
     EBIFetchClient ebi = new EBIFetchClient();\r
-    file = ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw")\r
-            .getAbsolutePath();\r
+    file = ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw").getAbsolutePath();\r
     stopQuery();\r
     if (file == null)\r
     {\r
@@ -107,7 +132,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
     }\r
     try\r
     {\r
-      \r
+\r
       PDBfile pdbfile = new PDBfile(file,\r
               jalview.io.AppletFormatAdapter.FILE);\r
       for (int i = 0; i < pdbfile.chains.size(); i++)\r
@@ -117,27 +142,27 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
                         .toUpperCase().equals(chain))\r
         {\r
           PDBChain pdbchain = (PDBChain) pdbfile.chains.elementAt(i);\r
-          // Get the Chain's Sequence - who's dataset includes any special features added from the PDB file\r
+          // Get the Chain's Sequence - who's dataset includes any special\r
+          // features added from the PDB file\r
           SequenceI sq = pdbchain.sequence;\r
-          // Specially formatted name for the PDB chain sequences retrieved from the PDB\r
-          sq.setName(jalview.datamodel.DBRefSource.PDB+"|" + id + "|" + sq.getName());\r
+          // Specially formatted name for the PDB chain sequences retrieved from\r
+          // the PDB\r
+          sq.setName(jalview.datamodel.DBRefSource.PDB + "|" + id + "|"\r
+                  + sq.getName());\r
           // Might need to add more metadata to the PDBEntry object\r
           // like below\r
           /*\r
-           * PDBEntry entry = new PDBEntry();\r
-           // Construct the PDBEntry\r
-           entry.setId(id);\r
-           if (entry.getProperty() == null)\r
-           entry.setProperty(new Hashtable());\r
-           entry.getProperty().put("chains",\r
-           pdbchain.id\r
-           + "=" + sq.getStart()\r
-           + "-" + sq.getEnd());\r
-           sq.getDatasetSequence().addPDBId(entry);\r
+           * PDBEntry entry = new PDBEntry(); // Construct the PDBEntry\r
+           * entry.setId(id); if (entry.getProperty() == null)\r
+           * entry.setProperty(new Hashtable());\r
+           * entry.getProperty().put("chains", pdbchain.id + "=" + sq.getStart()\r
+           * + "-" + sq.getEnd()); sq.getDatasetSequence().addPDBId(entry);\r
            */\r
           // Add PDB DB Refs\r
-          // We make a DBRefEtntry because we have obtained the PDB file from a verifiable source\r
-          // JBPNote - PDB DBRefEntry should also carry the chain and mapping information\r
+          // We make a DBRefEtntry because we have obtained the PDB file from a\r
+          // verifiable source\r
+          // JBPNote - PDB DBRefEntry should also carry the chain and mapping\r
+          // information\r
           DBRefEntry dbentry = new DBRefEntry(getDbSource(),\r
                   getDbVersion(), id + pdbchain.id);\r
           sq.addDBRef(dbentry);\r
@@ -166,7 +191,9 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy
     return new Alignment(results);\r
   }\r
 \r
-  /* (non-Javadoc)\r
+  /*\r
+   * (non-Javadoc)\r
+   * \r
    * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String)\r
    */\r
   public boolean isValidReference(String accession)\r