import java.io.*;\r
import java.util.*;\r
\r
+import org.biojava.dasobert.dasregistry.DasSource;\r
import org.exolab.castor.mapping.*;\r
import org.exolab.castor.xml.*;\r
import jalview.analysis.*;\r
}\r
\r
/**\r
- * Creates a new SequenceFeatureFetcher object.\r
+ * Creates a new SequenceFeatureFetcher object and fetches from the\r
+ * currently selected set of databases.\r
* \r
* @param seqs\r
* fetch references for these sequences\r
*/\r
public DBRefFetcher(SequenceI[] seqs, AlignFrame af)\r
{\r
+ this(seqs, af, null);\r
+ }\r
+ /**\r
+ * Creates a new SequenceFeatureFetcher object and fetches from the\r
+ * currently selected set of databases.\r
+ * \r
+ * @param seqs\r
+ * fetch references for these sequences\r
+ * @param af\r
+ * the parent alignframe for progress bar monitoring.\r
+ * @param sources array of database source strings to query references from\r
+ */\r
+ public DBRefFetcher(SequenceI[] seqs, AlignFrame af, String[] sources)\r
+ {\r
this.af = af;\r
SequenceI[] ds = new SequenceI[seqs.length];\r
for (int i = 0; i < seqs.length; i++)\r
this.dataset = ds;\r
// TODO Jalview 2.5 lots of this code should be in the gui package!\r
sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af);\r
- // select appropriate databases based on alignFrame context.\r
- if (af.getViewport().getAlignment().isNucleotide())\r
+ if (sources==null)\r
{\r
- dbSources = DBRefSource.DNACODINGDBS;\r
+ // af.featureSettings_actionPerformed(null);\r
+ String[] defdb=null,otherdb = sfetcher.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);\r
+ Vector selsources = new Vector(), dasselsrc= (af.featureSettings!=null) ? af.featureSettings.getSelectedSources()\r
+ : new jalview.gui.DasSourceBrowser().getSelectedSources();\r
+ Enumeration en = dasselsrc.elements();\r
+ while (en.hasMoreElements())\r
+ {\r
+ DasSource src = (DasSource) en.nextElement();\r
+ selsources.addElement(src.getNickname());\r
+ }\r
+ int osel = 0;\r
+ for (int o=0;otherdb!=null && o<otherdb.length;o++)\r
+ {\r
+ if (!selsources.contains(otherdb[o]))\r
+ {\r
+ otherdb[o] = null;\r
+ } else {\r
+ osel++;\r
+ }\r
+ }\r
+ // select appropriate databases based on alignFrame context.\r
+ if (af.getViewport().getAlignment().isNucleotide())\r
+ {\r
+ defdb = DBRefSource.DNACODINGDBS;\r
+ }\r
+ else\r
+ {\r
+ defdb = DBRefSource.PROTEINDBS;\r
+ }\r
+ // append the selected sequence sources to the default dbs \r
+ dbSources = new String[defdb.length+osel];\r
+ System.arraycopy(defdb, 0, dbSources, 0, defdb.length);\r
+ for (int o=0,op=defdb.length; otherdb!=null && o<otherdb.length; o++)\r
+ {\r
+ if (otherdb[o]!=null)\r
+ {\r
+ dbSources[op++] = otherdb[o];\r
+ }\r
+ }\r
+ } else {\r
+ // we assume the caller knows what they're doing and ensured that all the db source names are valid\r
+ dbSources = sources;\r
}\r
- else\r
+ }\r
+ /**\r
+ * retrieve all the das sequence sources and add them to the list of db sources to retrieve from \r
+ */\r
+ public void appendAllDasSources()\r
+ {\r
+ if (dbSources == null)\r
+ {\r
+ dbSources = new String[] {};\r
+ }\r
+ // append additional sources\r
+ String[] otherdb = sfetcher.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);\r
+ if (otherdb!=null && otherdb.length>0)\r
{\r
- dbSources = DBRefSource.PROTEINDBS;\r
+ String[] newsrc = new String[dbSources.length+otherdb.length];\r
+ System.arraycopy(dbSources, 0, newsrc,0,dbSources.length);\r
+ System.arraycopy(otherdb, 0, newsrc,dbSources.length, otherdb.length);\r
+ dbSources = newsrc;\r
}\r
}\r
-\r
/**\r
* start the fetcher thread\r
* \r