+++ /dev/null
-/*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
- * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
- * \r
- * This file is part of Jalview.\r
- * \r
- * Jalview is free software: you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License \r
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
- * \r
- * Jalview is distributed in the hope that it will be useful, but \r
- * WITHOUT ANY WARRANTY; without even the implied warranty \r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
- * PURPOSE. See the GNU General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package jalview.ws.dbsources;\r
-\r
-import java.util.Hashtable;\r
-\r
-import com.stevesoft.pat.Regex;\r
-\r
-import jalview.ws.dbsources.das.DasSequenceSourceListener;\r
-import jalview.ws.seqfetcher.*;\r
-import jalview.datamodel.AlignmentI;\r
-\r
-/**\r
- * an instance of this class is created for each unique DAS Sequence source (ie\r
- * one capable of handling the 'sequence' for a particular MapMaster)\r
- * \r
- * @author JimP\r
- * \r
- */\r
-public class DasSequenceSource extends DbSourceProxyImpl implements\r
- DbSourceProxy\r
-{\r
- protected Das1Source source = null;\r
-\r
- protected String dbname = "DASCS";\r
-\r
- protected String dbrefname = "das:source";\r
-\r
- protected DasCoordinateSystem coordsys = null;\r
-\r
- /**\r
- * create a new DbSource proxy for a DAS 1 source\r
- * \r
- * @param dbnbame\r
- * Human Readable Name to use when fetching from this source\r
- * @param dbrefname\r
- * DbRefName for DbRefs attached to sequences retrieved from this\r
- * source\r
- * @param source\r
- * Das1Source\r
- * @param coordsys\r
- * specific coordinate system to use for this source\r
- * @throws Exception\r
- * if source is not capable of the 'sequence' command\r
- */\r
- public DasSequenceSource(String dbname, String dbrefname,\r
- Das1Source source, DasCoordinateSystem coordsys) throws Exception\r
- {\r
- if (!source.hasCapability("sequence"))\r
- {\r
- throw new Exception("Source " + source.getNickname()\r
- + " does not support the sequence command.");\r
- }\r
- this.source = source;\r
- this.dbname = dbname;\r
- this.dbrefname = dbrefname;\r
- this.coordsys = coordsys;\r
- }\r
-\r
- public String getAccessionSeparator()\r
- {\r
- // cope with single sequences only\r
- return null;\r
- }\r
-\r
- public Regex getAccessionValidator()\r
- {\r
- /** ? * */\r
- return Regex.perlCode("\\S+");\r
- }\r
-\r
- public String getDbName()\r
- {\r
- // TODO: map to\r
- return dbname + " (DAS)";\r
- }\r
-\r
- public String getDbSource()\r
- {\r
- return dbrefname;\r
- }\r
-\r
- public String getDbVersion()\r
- {\r
- return coordsys.getVersion();\r
- }\r
-\r
- public AlignmentI getSequenceRecords(String queries) throws Exception\r
- {\r
- SequenceThread seqfetcher = new org.biojava.dasobert.das.SequenceThread(\r
- queries, source);\r
- DasSequenceSourceListener ourlistener = new DasSequenceSourceListener(\r
- this, queries);\r
- seqfetcher.addSequenceListener(ourlistener);\r
- seqfetcher.start();\r
- try\r
- {\r
- Thread.sleep(5);\r
- } catch (Exception e)\r
- {\r
- }\r
- ;\r
- while (ourlistener.isNotCalled() && seqfetcher.isAlive())\r
- {\r
- try\r
- {\r
- Thread.sleep(5);\r
- } catch (Exception e)\r
- {\r
- }\r
- ;\r
- }\r
- if (ourlistener.isNotCalled() || ourlistener.hasNoSequences())\r
- {\r
- System.err.println("Sequence Query to " + source.getNickname()\r
- + " with '" + queries + "' returned no sequences.");\r
- return null;\r
- }\r
- else\r
- {\r
- return ourlistener.getSequences();\r
- }\r
- }\r
-\r
- public String getTestQuery()\r
- {\r
- return coordsys.getTestCode();\r
- }\r
-\r
- public boolean isValidReference(String accession)\r
- {\r
- // TODO try to validate an accession against source\r
- // We don't really know how to do this without querying source\r
-\r
- return true;\r
- }\r
-\r
- /**\r
- * @return the source\r
- */\r
- public Das1Source getSource()\r
- {\r
- return source;\r
- }\r
-\r
- /**\r
- * @return the coordsys\r
- */\r
- public DasCoordinateSystem getCoordsys()\r
- {\r
- return coordsys;\r
- }\r
-}\r