Introduced DbRefEntry to DasSourceCoordinateSystem check to only call sources for...
authorjprocter <Jim Procter>
Thu, 8 Jun 2006 18:17:35 +0000 (18:17 +0000)
committerjprocter <Jim Procter>
Thu, 8 Jun 2006 18:17:35 +0000 (18:17 +0000)
src/jalview/gui/SequenceFetcher.java
src/jalview/io/DasSequenceFeatureFetcher.java
src/jalview/io/ModellerDescription.java
src/jalview/io/SequenceFeatureFetcher.java
src/jalview/io/WSWUBlastClient.java
src/jalview/util/DBRefUtils.java

index 6bdba4a..e2b5730 100755 (executable)
@@ -437,7 +437,7 @@ public class SequenceFetcher
 \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
-              DBRefEntry dbentry = new DBRefEntry("PDB","0",pdbid);\r
+              DBRefEntry dbentry = new DBRefEntry(jalview.datamodel.DBRefSource.PDB,"0",pdbid);\r
               sequences[i].getDatasetSequence().addDBRef(dbentry);\r
             }\r
             else\r
index 99a2b70..8f104c5 100755 (executable)
@@ -251,7 +251,10 @@ public class DasSequenceFeatureFetcher implements Runnable
       while (seqIndex < sequences.size())\r
       {\r
           Sequence sequence = (Sequence) sequences.get(seqIndex);\r
-          Vector uprefs = jalview.util.DBRefUtils.selectRefs(sequence.getDBRef(), new String[]  {"DBREF"});\r
+          Vector uprefs = jalview.util.DBRefUtils.selectRefs(sequence.getDBRef(),\r
+              new String[]  {\r
+              jalview.datamodel.DBRefSource.PDB,\r
+              jalview.datamodel.DBRefSource.UNIPROT});\r
 \r
           for(int sourceIndex=0; sourceIndex<selectedSources.size(); sourceIndex++)\r
           {\r
@@ -262,11 +265,21 @@ public class DasSequenceFeatureFetcher implements Runnable
               // we know the id for this entry, so don't note its ID in the unknownSequences list\r
               for (int j = 0, k = uprefs.size(); j < k; j++)\r
               {\r
-\r
-                createFeatureFetcher(sequence,\r
-                                     dasSource.getUrl(),\r
-                                     ( (DBRefEntry) uprefs.get(j)).getAccessionId(),\r
-                                     dasSource.getNickname());\r
+                // Will have to pass any mapping information to the fetcher - the start/end for the DBRefEntry may not be the same as the sequence's start/end\r
+                org.biojava.services.das.registry.DasCoordinateSystem cs[] = dasSource.getCoordinateSystem();\r
+                for (int l=0; l<cs.length; l++) {\r
+                  if (jalview.util.DBRefUtils.isDasCoordinateSystem(cs[l].getName(), (DBRefEntry)\r
+                      uprefs.get(j)))\r
+                  {\r
+                    Cache.log.debug("Launched fetcher for coordinate system " +\r
+                                    cs[l].getName());\r
+                    createFeatureFetcher(sequence,\r
+                                         dasSource.getUrl(),\r
+                                         ( (DBRefEntry) uprefs.get(j)).\r
+                                         getAccessionId(),\r
+                                         dasSource.getNickname());\r
+                  }\r
+                }\r
               }\r
             }\r
             else\r
index 62e1fbe..1e4f905 100755 (executable)
@@ -234,7 +234,7 @@ public class ModellerDescription
           {\r
             // JBPNote PDB dbRefEntry needs properties to propagate onto ModellerField\r
             // JBPNote Need to get info from the user about whether the sequence is the one being modelled, or if it is a template.\r
-            if (dref.getSource().equals("PDB"))\r
+            if (dref.getSource().equals(jalview.datamodel.DBRefSource.PDB))\r
             {\r
               fields.put(Fields[LOCALID], dref.getAccessionId());\r
               t = 2;\r
index 9bc214f..edbf862 100755 (executable)
@@ -116,7 +116,8 @@ public class SequenceFeatureFetcher implements Runnable
              seqIndex++, i++)\r
         {\r
           Sequence sequence = (Sequence) sequences.get(seqIndex);\r
-          Vector uprefs = jalview.util.DBRefUtils.selectRefs(sequence.getDBRef(), new String[] { "Uniprot"});\r
+          Vector uprefs = jalview.util.DBRefUtils.selectRefs(sequence.getDBRef(), new String[] {\r
+              jalview.datamodel.DBRefSource.UNIPROT});\r
           if (uprefs!=null)\r
           {\r
             // we know the id for this entry, so don't note its ID in the unknownSequences list\r
index 0906d12..391c9a8 100755 (executable)
@@ -168,7 +168,7 @@ public class WSWUBlastClient
           {\r
             DBRefEntry entry = (DBRefEntry) entries.elementAt(0);\r
             oldseq.addDBRef(new jalview.datamodel.\r
-                                                 DBRefEntry("UNIPROT",\r
+                                                 DBRefEntry(jalview.datamodel.DBRefSource.UNIPROT,\r
                 "0",\r
                 entry.getAccessionId()));\r
           }\r
index 86ab201..2f844da 100755 (executable)
@@ -1,13 +1,20 @@
 package jalview.util;
 
-import java.util.Vector;
-import java.util.Hashtable;
+import java.util.*;
+
+import jalview.datamodel.*;
 
 public class DBRefUtils
 {
     /**
      * Utilities for handling DBRef objects and their collections.
      */
+    /**
+     *
+     * @param dbrefs Vector of DBRef objects to search
+     * @param sources String[] array of source DBRef IDs to retrieve
+     * @return Vector
+     */
     public static Vector selectRefs(java.util.Vector dbrefs, String[] sources) {
       if (dbrefs==null)
         return null;
@@ -29,4 +36,30 @@ public class DBRefUtils
       // there are probable  memory leaks in the hashtable!
       return null;
     }
+
+  /**
+   * isDasCoordinateSystem
+   *
+   * @param string String
+   * @param dBRefEntry DBRefEntry
+   * @return boolean true if Source DBRefEntry is compatible with DAS CoordinateSystem name
+   */
+  public static Hashtable DasCoordinateSystemsLookup = null;
+  public static boolean isDasCoordinateSystem(String string,
+                                              DBRefEntry dBRefEntry)
+  {
+    if (DasCoordinateSystemsLookup==null)
+    { // Initialise
+      DasCoordinateSystemsLookup = new Hashtable();
+      DasCoordinateSystemsLookup.put("pdbresnum",
+                                     jalview.datamodel.DBRefSource.PDB);
+      DasCoordinateSystemsLookup.put("uniprot",
+                                     jalview.datamodel.DBRefSource.UNIPROT);
+    }
+
+    String coordsys = (String) DasCoordinateSystemsLookup.get(string.toLowerCase());
+    if (coordsys!=null)
+      return coordsys.equals(dBRefEntry.getSource());
+    return false;
   }
+}