X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FDasSequenceSource.java;h=f03665daaa45aa03a7f191cf18b97758efbe11cf;hb=a45774ee31d9f35d4eff46d54d7deab719afb092;hp=accb0b9bf17450c2ff50d79e7638acafa8676c5b;hpb=54e003f9b2fff47dbfea6401c3944afdb7bd37b3;p=jalview.git diff --git a/src/jalview/ws/dbsources/DasSequenceSource.java b/src/jalview/ws/dbsources/DasSequenceSource.java index accb0b9..f03665d 100644 --- a/src/jalview/ws/dbsources/DasSequenceSource.java +++ b/src/jalview/ws/dbsources/DasSequenceSource.java @@ -1,3 +1,20 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, 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.dbsources; import java.util.Hashtable; @@ -17,38 +34,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 +88,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 +110,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 +149,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 +165,7 @@ public class DasSequenceSource extends DbSourceProxyImpl implements { return source; } + /** * @return the coordsys */