added specific retrieval arguments to SequneceFetcher's main method.
authorjprocter <Jim Procter>
Thu, 31 Jul 2008 10:09:55 +0000 (10:09 +0000)
committerjprocter <Jim Procter>
Thu, 31 Jul 2008 10:09:55 +0000 (10:09 +0000)
src/jalview/ws/SequenceFetcher.java

index 208eb88..da2dab6 100644 (file)
@@ -33,15 +33,46 @@ public class SequenceFetcher extends ASequenceFetcher
     addDBRefSourceImpl(jalview.ws.dbsources.Pdb.class);\r
     addDBRefSourceImpl(jalview.ws.dbsources.Pfam.class);\r
   };\r
-\r
+  /**\r
+   * simple run method to test dbsources.\r
+   * @param argv\r
+   */\r
   public static void main(String[] argv)\r
   {\r
     AlignmentI ds = null;\r
     Vector noProds = new Vector();\r
+    String usage = "SequenceFetcher.main [<DBNAME> <ACCNO>]\n"\r
+      +"With no arguments, all DbSources will be queried with their test Accession number.\n"\r
+      +"If given two arguments, SequenceFetcher will try to find the DbFetcher corresponding to <DBNAME> and retrieve <ACCNO> from it.";\r
     if (argv != null && argv.length > 0)\r
     {\r
+      DbSourceProxy sp = new SequenceFetcher().getSourceProxy(argv[0]);\r
+      if (sp!=null)\r
+      {\r
+        AlignmentI al = null;\r
+        try\r
+        {\r
+          al = sp.getSequenceRecords(argv[1]);\r
+        } catch (Exception e)\r
+        {\r
+          e.printStackTrace();\r
+          System.err.println("Error when retrieving "+argv[1]+" from "+argv[0]+"\nUsage: "+usage);\r
+        }\r
+        SequenceI[] prod = al.getSequencesArray();\r
+        if (al!=null)\r
+        {\r
+          for (int p = 0; p < prod.length; p++)\r
+          {\r
+            System.out.println("Prod " + p + ": "\r
+                    + prod[p].getDisplayId(true) + " : "+prod[p].getDescription());\r
+          }\r
+        }\r
+        return;\r
+      } else {\r
+        System.err.println("Can't resolve "+argv[0]+" as a database name. Allowed values are :\n"+new SequenceFetcher().getSupportedDb());\r
+      }\r
       System.out\r
-              .println("Ignoring arguments. Future Usage = dbname:query1;query2;...");\r
+              .println(usage);\r
     }\r
     ASequenceFetcher sfetcher = new SequenceFetcher();\r
     String[] dbSources = sfetcher.getSupportedDb();\r