JAL-636 tweak main() based test to allow DAS sources to be excluded from basic Sequen...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 4 Oct 2012 15:12:25 +0000 (16:12 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 4 Oct 2012 15:12:25 +0000 (16:12 +0100)
src/jalview/ws/SequenceFetcher.java

index b1d3f3c..111c510 100644 (file)
@@ -48,6 +48,10 @@ public class SequenceFetcher extends ASequenceFetcher
    */\r
   public SequenceFetcher()\r
   {\r
+    this(true);\r
+  }\r
+  public SequenceFetcher(boolean addDas)\r
+  {\r
     addDBRefSourceImpl(jalview.ws.dbsources.EmblSource.class);\r
     addDBRefSourceImpl(jalview.ws.dbsources.EmblCdsSouce.class);\r
     addDBRefSourceImpl(jalview.ws.dbsources.Uniprot.class);\r
@@ -60,7 +64,9 @@ public class SequenceFetcher extends ASequenceFetcher
     // PFAM\r
     addDBRefSourceImpl(jalview.ws.dbsources.RfamFull.class);\r
     addDBRefSourceImpl(jalview.ws.dbsources.RfamSeed.class);\r
-    registerDasSequenceSources();\r
+    if (addDas) {\r
+      registerDasSequenceSources();\r
+    }\r
   }\r
 \r
   /**\r
@@ -208,12 +214,22 @@ public class SequenceFetcher extends ASequenceFetcher
   {\r
     AlignmentI ds = null;\r
     Vector noProds = new Vector();\r
-    String usage = "SequenceFetcher.main [<DBNAME> <ACCNO>]\n"\r
+    String usage = "SequenceFetcher.main [-nodas] [<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
+            + "With one argument, the argument will be resolved to one or more db sources and each will be queried with their test accession only.\n"\r
+            + "If given two arguments, SequenceFetcher will try to find the DbFetcher corresponding to <DBNAME> and retrieve <ACCNO> from it.\n"\r
+            + "The -nodas option will exclude DAS sources from the database fetchers Jalview will try to use.";\r
+    boolean withDas=true;\r
+    if (argv!=null && argv.length>0 && argv[0].toLowerCase().startsWith("-nodas"))\r
+    {\r
+      withDas=false;\r
+      String targs[] = new String[argv.length-1];\r
+      System.arraycopy(argv, 1, targs, 0, targs.length);\r
+      argv=targs;\r
+    }\r
     if (argv != null && argv.length > 0)\r
     {\r
-      List<DbSourceProxy> sps = new SequenceFetcher()\r
+      List<DbSourceProxy> sps = new SequenceFetcher(withDas)\r
               .getSourceProxy(argv[0]);\r
 \r
       if (sps != null)\r
@@ -223,11 +239,11 @@ public class SequenceFetcher extends ASequenceFetcher
           AlignmentI al = null;\r
           try\r
           {\r
-            al = sp.getSequenceRecords(argv[1]);\r
+            al = sp.getSequenceRecords(argv.length>1 ? argv[1] : sp.getTestQuery());\r
           } catch (Exception e)\r
           {\r
             e.printStackTrace();\r
-            System.err.println("Error when retrieving " + argv[1]\r
+            System.err.println("Error when retrieving " + (argv.length>1 ? argv[1] : sp.getTestQuery())\r
                     + " from " + argv[0] + "\nUsage: " + usage);\r
           }\r
           SequenceI[] prod = al.getSequencesArray();\r
@@ -252,7 +268,7 @@ public class SequenceFetcher extends ASequenceFetcher
       System.out.println(usage);\r
       return;\r
     }\r
-    ASequenceFetcher sfetcher = new SequenceFetcher();\r
+    ASequenceFetcher sfetcher = new SequenceFetcher(withDas);\r
     String[] dbSources = sfetcher.getSupportedDb();\r
     for (int dbsource = 0; dbsource < dbSources.length; dbsource++)\r
     {\r