X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fseqfetcher%2FASequenceFetcher.java;h=8a8cf445571aba433882a710202331bc03c8cf63;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=0785ea2c044be3aeff136c4930d611cd8a6db9d9;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/jalview/ws/seqfetcher/ASequenceFetcher.java b/src/jalview/ws/seqfetcher/ASequenceFetcher.java index 0785ea2..8a8cf44 100644 --- a/src/jalview/ws/seqfetcher/ASequenceFetcher.java +++ b/src/jalview/ws/seqfetcher/ASequenceFetcher.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.seqfetcher; import jalview.datamodel.AlignmentI; @@ -86,10 +104,10 @@ public class ASequenceFetcher "Don't know how to fetch from this database :" + db); DbSourceProxy fetcher = getSourceProxy(db); boolean doMultiple = fetcher.getAccessionSeparator() != null; // No - // separator - // - no - // Multiple - // Queries + // separator + // - no + // Multiple + // Queries Enumeration qs = query.elements(); while (qs.hasMoreElements()) { @@ -98,20 +116,22 @@ public class ASequenceFetcher { qsb.append((String) qs.nextElement()); if (qs.hasMoreElements() && doMultiple) // and not reached limit for - // multiple queries at one - // time for this source + // multiple queries at one + // time for this source { qsb.append(fetcher.getAccessionSeparator()); } } while (doMultiple && qs.hasMoreElements()); - - AlignmentI seqset=null; - try { + + AlignmentI seqset = null; + try + { // create a fetcher and go to it seqset = fetcher.getSequenceRecords(qsb.toString()); } catch (Exception ex) { - System.err.println("Failed to retrieve the following from "+db); + System.err.println("Failed to retrieve the following from " + + db); System.err.println(qsb); ex.printStackTrace(System.err); } @@ -176,7 +196,7 @@ public class ASequenceFetcher { ret = new SequenceI[rseqs.size()]; Enumeration sqs = rseqs.elements(); - int si=0; + int si = 0; while (sqs.hasMoreElements()) { SequenceI s = (SequenceI) sqs.nextElement(); @@ -191,8 +211,8 @@ public class ASequenceFetcher * Retrieve an instance of the proxy for the given source * * @param db - * database source string TODO: add version string/wildcard for - * retrieval of specific DB source/version combinations. + * database source string TODO: add version string/wildcard for + * retrieval of specific DB source/version combinations. * @return an instance of DbSourceProxy for that db. */ public DbSourceProxy getSourceProxy(String db) @@ -215,11 +235,11 @@ public class ASequenceFetcher protected void addDBRefSourceImpl(Class dbSourceProxy) throws java.lang.IllegalArgumentException { - DbSourceProxy proxy = null; + DbSourceProxy proxy = null; try { - Object proxyObj = dbSourceProxy.getConstructor( - null).newInstance(null); + Object proxyObj = dbSourceProxy.getConstructor(null) + .newInstance(null); if (!DbSourceProxy.class.isInstance(proxyObj)) { throw new IllegalArgumentException( @@ -227,20 +247,21 @@ public class ASequenceFetcher + " does not implement the jalview.ws.seqfetcher.DbSourceProxy"); } proxy = (DbSourceProxy) proxyObj; - } - catch (IllegalArgumentException e) + } catch (IllegalArgumentException e) { throw e; - } - catch (Exception e) + } catch (Exception e) { // Serious problems if this happens. throw new Error("DBRefSource Implementation Exception", e); } addDbRefSourceImpl(proxy); } + /** - * add the properly initialised DbSourceProxy object 'proxy' to the list of sequence fetchers + * add the properly initialised DbSourceProxy object 'proxy' to the list of + * sequence fetchers + * * @param proxy */ protected void addDbRefSourceImpl(DbSourceProxy proxy) @@ -257,6 +278,7 @@ public class ASequenceFetcher /** * test if the database handler for dbName contains the given dbProperty + * * @param dbName * @param dbProperty * @return true if proxy has the given property @@ -265,9 +287,9 @@ public class ASequenceFetcher { // TODO: decide if invalidDbName exception is thrown here. DbSourceProxy proxy = getSourceProxy(dbName); - if (proxy!=null) + if (proxy != null) { - if (proxy.getDbSourceProperties()!=null) + if (proxy.getDbSourceProperties() != null) { return proxy.getDbSourceProperties().containsKey(dbProperty); } @@ -275,4 +297,4 @@ public class ASequenceFetcher return false; } -} \ No newline at end of file +}