X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FSequenceFetcher.java;h=14b69972a1276bd20bff2ac2425acb3c1103549f;hb=c330d4dad8fc78c8ec1d5c35e5fc137836c9776d;hp=b1d3f3c01d4b8793588efadda07a65cffa8f1bf3;hpb=92f7b5ee3bbdb5456d498f1c2780d90420491342;p=jalview.git diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index b1d3f3c..14b6997 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -1,20 +1,20 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) - * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . - */ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) + * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + */ package jalview.ws; import jalview.datamodel.Alignment; @@ -22,7 +22,6 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefSource; import jalview.datamodel.SequenceI; import jalview.ws.dbsources.das.api.jalviewSourceI; -import jalview.ws.dbsources.das.datamodel.DasSequenceSource; import jalview.ws.seqfetcher.ASequenceFetcher; import jalview.ws.seqfetcher.DbSourceProxy; @@ -48,6 +47,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 +63,9 @@ public class SequenceFetcher extends ASequenceFetcher // PFAM addDBRefSourceImpl(jalview.ws.dbsources.RfamFull.class); addDBRefSourceImpl(jalview.ws.dbsources.RfamSeed.class); - registerDasSequenceSources(); + if (addDas) { + registerDasSequenceSources(); + } } /** @@ -73,15 +78,18 @@ public class SequenceFetcher extends ASequenceFetcher ArrayList dassrc = new ArrayList(), nondas = new ArrayList(); for (int i = 0; i < srcs.length; i++) { - boolean das = false,skip=false; + boolean das = false, skip = false; String nm; for (DbSourceProxy dbs : getSourceProxy(srcs[i])) { - // Skip the alignment databases for the moment - they're not useful for verifying a single sequence against its reference source + // Skip the alignment databases for the moment - they're not useful for + // verifying a single sequence against its reference source if (dbs.isA(DBRefSource.ALIGNMENTDB)) { - skip=true; - } else { + skip = true; + } + else + { nm = dbs.getDbName(); if (getSourceProxy(srcs[i]) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) { @@ -208,12 +216,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 +241,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 +270,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++) {