From: jprocter Date: Thu, 4 Oct 2012 15:12:25 +0000 (+0100) Subject: JAL-636 tweak main() based test to allow DAS sources to be excluded from basic Sequen... X-Git-Tag: Jalview_2_9~270 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a049d57f4693f1b60ab02fdf2c9403a2e9c59444;p=jalview.git JAL-636 tweak main() based test to allow DAS sources to be excluded from basic SequenceFetcher testing --- diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index b1d3f3c..111c510 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -48,6 +48,10 @@ public class SequenceFetcher extends ASequenceFetcher */ public SequenceFetcher() { + this(true); + } + public SequenceFetcher(boolean addDas) + { addDBRefSourceImpl(jalview.ws.dbsources.EmblSource.class); addDBRefSourceImpl(jalview.ws.dbsources.EmblCdsSouce.class); addDBRefSourceImpl(jalview.ws.dbsources.Uniprot.class); @@ -60,7 +64,9 @@ public class SequenceFetcher extends ASequenceFetcher // PFAM addDBRefSourceImpl(jalview.ws.dbsources.RfamFull.class); addDBRefSourceImpl(jalview.ws.dbsources.RfamSeed.class); - registerDasSequenceSources(); + if (addDas) { + registerDasSequenceSources(); + } } /** @@ -208,12 +214,22 @@ public class SequenceFetcher extends ASequenceFetcher { AlignmentI ds = null; Vector noProds = new Vector(); - String usage = "SequenceFetcher.main [ ]\n" + String usage = "SequenceFetcher.main [-nodas] [ []]\n" + "With no arguments, all DbSources will be queried with their test Accession number.\n" - + "If given two arguments, SequenceFetcher will try to find the DbFetcher corresponding to and retrieve from it."; + + "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" + + "If given two arguments, SequenceFetcher will try to find the DbFetcher corresponding to and retrieve from it.\n" + + "The -nodas option will exclude DAS sources from the database fetchers Jalview will try to use."; + boolean withDas=true; + if (argv!=null && argv.length>0 && argv[0].toLowerCase().startsWith("-nodas")) + { + withDas=false; + String targs[] = new String[argv.length-1]; + System.arraycopy(argv, 1, targs, 0, targs.length); + argv=targs; + } if (argv != null && argv.length > 0) { - List sps = new SequenceFetcher() + List sps = new SequenceFetcher(withDas) .getSourceProxy(argv[0]); if (sps != null) @@ -223,11 +239,11 @@ public class SequenceFetcher extends ASequenceFetcher AlignmentI al = null; try { - al = sp.getSequenceRecords(argv[1]); + al = sp.getSequenceRecords(argv.length>1 ? argv[1] : sp.getTestQuery()); } catch (Exception e) { e.printStackTrace(); - System.err.println("Error when retrieving " + argv[1] + System.err.println("Error when retrieving " + (argv.length>1 ? argv[1] : sp.getTestQuery()) + " from " + argv[0] + "\nUsage: " + usage); } SequenceI[] prod = al.getSequencesArray(); @@ -252,7 +268,7 @@ public class SequenceFetcher extends ASequenceFetcher System.out.println(usage); return; } - ASequenceFetcher sfetcher = new SequenceFetcher(); + ASequenceFetcher sfetcher = new SequenceFetcher(withDas); String[] dbSources = sfetcher.getSupportedDb(); for (int dbsource = 0; dbsource < dbSources.length; dbsource++) {