X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FDasSequenceSource.java;h=9283c66d18f2e4d2196b5c801639c654727ebe47;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=accb0b9bf17450c2ff50d79e7638acafa8676c5b;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/jalview/ws/dbsources/DasSequenceSource.java b/src/jalview/ws/dbsources/DasSequenceSource.java index accb0b9..9283c66 100644 --- a/src/jalview/ws/dbsources/DasSequenceSource.java +++ b/src/jalview/ws/dbsources/DasSequenceSource.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.dbsources; import java.util.Hashtable; @@ -17,38 +35,52 @@ import jalview.ws.seqfetcher.*; import jalview.datamodel.AlignmentI; /** - * an instance of this class is created for each unique DAS Sequence source (ie one capable of handling the 'sequence' for a particular MapMaster) - * + * an instance of this class is created for each unique DAS Sequence source (ie + * one capable of handling the 'sequence' for a particular MapMaster) + * * @author JimP - * + * */ public class DasSequenceSource extends DbSourceProxyImpl implements DbSourceProxy { - protected Das1Source source=null; - protected String dbname="DASCS"; - protected String dbrefname="das:source"; + protected Das1Source source = null; + + protected String dbname = "DASCS"; + + protected String dbrefname = "das:source"; + protected DasCoordinateSystem coordsys = null; + /** * create a new DbSource proxy for a DAS 1 source - * @param dbnbame Human Readable Name to use when fetching from this source - * @param dbrefname DbRefName for DbRefs attached to sequences retrieved from this source - * @param source Das1Source - * @param coordsys specific coordinate system to use for this source - * @throws Exception if source is not capable of the 'sequence' command + * + * @param dbnbame + * Human Readable Name to use when fetching from this source + * @param dbrefname + * DbRefName for DbRefs attached to sequences retrieved from + * this source + * @param source + * Das1Source + * @param coordsys + * specific coordinate system to use for this source + * @throws Exception + * if source is not capable of the 'sequence' command */ - public DasSequenceSource(String dbname, String dbrefname, Das1Source source, - DasCoordinateSystem coordsys) throws Exception + public DasSequenceSource(String dbname, String dbrefname, + Das1Source source, DasCoordinateSystem coordsys) throws Exception { if (!source.hasCapability("sequence")) { - throw new Exception("Source "+source.getNickname()+" does not support the sequence command."); + throw new Exception("Source " + source.getNickname() + + " does not support the sequence command."); } this.source = source; this.dbname = dbname; - this.dbrefname=dbrefname; + this.dbrefname = dbrefname; this.coordsys = coordsys; } + public String getAccessionSeparator() { // cope with single sequences only @@ -57,14 +89,14 @@ public class DasSequenceSource extends DbSourceProxyImpl implements public Regex getAccessionValidator() { - /** ? **/ + /** ? * */ return Regex.perlCode("\\S+"); } public String getDbName() { // TODO: map to - return dbname+" (DAS)"; + return dbname + " (DAS)"; } public String getDbSource() @@ -79,20 +111,37 @@ public class DasSequenceSource extends DbSourceProxyImpl implements public AlignmentI getSequenceRecords(String queries) throws Exception { - SequenceThread seqfetcher = new org.biojava.dasobert.das.SequenceThread(queries, source); - DasSequenceSourceListener ourlistener = new DasSequenceSourceListener(this, queries); + SequenceThread seqfetcher = new org.biojava.dasobert.das.SequenceThread( + queries, source); + DasSequenceSourceListener ourlistener = new DasSequenceSourceListener( + this, queries); seqfetcher.addSequenceListener(ourlistener); seqfetcher.start(); - try { Thread.sleep(5); } catch (Exception e) {}; + try + { + Thread.sleep(5); + } catch (Exception e) + { + } + ; while (ourlistener.isNotCalled() && seqfetcher.isAlive()) { - try { Thread.sleep(5); } catch (Exception e) { }; + try + { + Thread.sleep(5); + } catch (Exception e) + { + } + ; } if (ourlistener.isNotCalled() || ourlistener.hasNoSequences()) { - System.err.println("Sequence Query to "+source.getNickname()+" with '"+queries+"' returned no sequences."); + System.err.println("Sequence Query to " + source.getNickname() + + " with '" + queries + "' returned no sequences."); return null; - } else { + } + else + { return ourlistener.getSequences(); } } @@ -101,13 +150,15 @@ public class DasSequenceSource extends DbSourceProxyImpl implements { return coordsys.getTestCode(); } + public boolean isValidReference(String accession) { // TODO try to validate an accession against source // We don't really know how to do this without querying source - + return true; } + /** * @return the source */ @@ -115,6 +166,7 @@ public class DasSequenceSource extends DbSourceProxyImpl implements { return source; } + /** * @return the coordsys */