X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FSequenceFetcher.java;h=b20ebbb5f2d611b1a6d20f3e31fcc958cd525d13;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=0d93cb82902834cbec7e09fbc49efd48235ff556;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index 0d93cb8..b20ebbb 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.ws; import java.util.ArrayList; @@ -19,7 +37,8 @@ import jalview.ws.seqfetcher.DbSourceProxy; /** * This is the the concrete implementation of the sequence retrieval interface * and abstract class in jalview.ws.seqfetcher. This implements the run-time - * discovery of sequence database clients, and provides a hardwired main for testing all registered handlers. + * discovery of sequence database clients, and provides a hardwired main for + * testing all registered handlers. * */ public class SequenceFetcher extends ASequenceFetcher @@ -38,17 +57,22 @@ public class SequenceFetcher extends ASequenceFetcher addDBRefSourceImpl(jalview.ws.dbsources.UnprotName.class); addDBRefSourceImpl(jalview.ws.dbsources.Pdb.class); addDBRefSourceImpl(jalview.ws.dbsources.PfamFull.class); - addDBRefSourceImpl(jalview.ws.dbsources.PfamSeed.class); // ensures Seed alignment is 'default' for PFAM + addDBRefSourceImpl(jalview.ws.dbsources.PfamSeed.class); // ensures Seed + // alignment is + // 'default' for + // PFAM registerDasSequenceSources(); } + /** - * return an ordered list of database sources suitable for using in a GUI element + * return an ordered list of database sources suitable for using in a GUI + * element */ - public String[] getOrderedSupportedSources() { + public String[] getOrderedSupportedSources() + { String[] srcs = this.getSupportedDb(); - ArrayList dassrc = new ArrayList(), - nondas=new ArrayList(); - for (int i=0;i=0; j--,i++) + int i = 0; + for (int j = sorted.length - 1; j >= 0; j--, i++) { srcs[i] = ((String[]) sorted[j])[0]; sorted[j] = null; @@ -80,20 +108,22 @@ public class SequenceFetcher extends ASequenceFetcher sorted = dassrc.toArray(); tosort = new String[sorted.length]; dassrc.clear(); - for (int j=0;j=0; j--,i++) + for (int j = sorted.length - 1; j >= 0; j--, i++) { srcs[i] = ((String[]) sorted[j])[0]; sorted[j] = null; } return srcs; } + /** * simple run method to test dbsources. + * * @param argv */ public static void main(String[] argv) @@ -101,12 +131,12 @@ public class SequenceFetcher extends ASequenceFetcher AlignmentI ds = null; Vector noProds = new Vector(); String usage = "SequenceFetcher.main [ ]\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 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."; if (argv != null && argv.length > 0) { DbSourceProxy sp = new SequenceFetcher().getSourceProxy(argv[0]); - if (sp!=null) + if (sp != null) { AlignmentI al = null; try @@ -115,40 +145,46 @@ public class SequenceFetcher extends ASequenceFetcher } catch (Exception e) { e.printStackTrace(); - System.err.println("Error when retrieving "+argv[1]+" from "+argv[0]+"\nUsage: "+usage); + System.err.println("Error when retrieving " + argv[1] + " from " + + argv[0] + "\nUsage: " + usage); } SequenceI[] prod = al.getSequencesArray(); - if (al!=null) + if (al != null) { for (int p = 0; p < prod.length; p++) { System.out.println("Prod " + p + ": " - + prod[p].getDisplayId(true) + " : "+prod[p].getDescription()); + + prod[p].getDisplayId(true) + " : " + + prod[p].getDescription()); } } return; - } else { - System.err.println("Can't resolve "+argv[0]+" as a database name. Allowed values are :\n"+new SequenceFetcher().getSupportedDb()); } - System.out - .println(usage); + else + { + System.err.println("Can't resolve " + argv[0] + + " as a database name. Allowed values are :\n" + + new SequenceFetcher().getSupportedDb()); + } + System.out.println(usage); } ASequenceFetcher sfetcher = new SequenceFetcher(); String[] dbSources = sfetcher.getSupportedDb(); - for (int dbsource=0; dbsource 0 && sp.getDbSourceProperties()!=null) + if (al != null && al.getHeight() > 0 + && sp.getDbSourceProperties() != null) { boolean dna = sp.getDbSourceProperties().containsKey( DBRefSource.DNACODINGSEQDB) @@ -248,7 +284,8 @@ public class SequenceFetcher extends ASequenceFetcher Alignment prodal = jalview.analysis.CrossRef.findXrefSequences( seqs, dna, null, ds); System.out.println("Found " - + ((prodal == null) ? "no" : "" + prodal.getHeight()) + " products"); + + ((prodal == null) ? "no" : "" + prodal.getHeight()) + + " products"); if (prodal != null) { SequenceI[] prod = prodal.getSequencesArray(); // note @@ -262,7 +299,7 @@ public class SequenceFetcher extends ASequenceFetcher // mapping // (if // present) - for (int p = 0; p < prod.length; p++) + for (int p = 0; p < prod.length; p++) { System.out.println("Prod " + p + ": " + prod[p].getDisplayId(true)); @@ -272,53 +309,67 @@ public class SequenceFetcher extends ASequenceFetcher } } + /** - * query the currently defined DAS source registry for sequence sources and add a DasSequenceSource instance for each source to the SequenceFetcher source list. + * query the currently defined DAS source registry for sequence sources and + * add a DasSequenceSource instance for each source to the SequenceFetcher + * source list. */ - public void registerDasSequenceSources() { - DasSource[] sources = jalview.ws.DasSequenceFeatureFetcher.getDASSources(); - for (int s=0;s