private void resetWebServiceMenu()
{
webService.removeAll();
- // Temporary hack - DBRef Fetcher always top level ws entry.
- JMenuItem rfetch = new JMenuItem("Fetch DB References");
- rfetch
- .setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
- webService.add(rfetch);
- rfetch.addActionListener(new ActionListener()
- {
-
- public void actionPerformed(ActionEvent e)
- {
- new Thread(new Runnable()
- {
-
- public void run()
- {
- new jalview.ws.DBRefFetcher(alignPanel.av
- .getSequenceSelection(), alignPanel.alignFrame)
- .fetchDBRefs(false);
- }
- }).start();
-
- }
-
- });
+ build_fetchdbmenu(webService);
}
/*
}
return false;
}
+ protected void build_fetchdbmenu(JMenu webService) {
+ // Temporary hack - DBRef Fetcher always top level ws entry.
+ // TODO We probably want to store a sequence database checklist in preferences and have checkboxes.. rather than individual sources selected here
+ JMenu rfetch = new JMenu("Fetch DB References");
+ rfetch
+ .setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
+ webService.add(rfetch);
+
+ JMenuItem fetchr = new JMenuItem("Standard Databases");
+ fetchr.setToolTipText("Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources");
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(), alignPanel.alignFrame)
+ .fetchDBRefs(false);
+ }
+ }).start();
+
+ }
+
+ });
+ rfetch.add(fetchr);
+ JMenu dfetch = new JMenu();
+ rfetch.add(dfetch);
+ jalview.ws.SequenceFetcher sf = SequenceFetcher.getSequenceFetcherSingleton(this);
+ String[] otherdb = sf.getOrderedSupportedSources();
+ // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
+ // jalview.util.QuickSort.sort(otherdb, otherdb);
+ int comp=0,mcomp=15;
+ String mname=null;
+ if (otherdb!=null && otherdb.length>0)
+ {
+ for (int i=0; i<otherdb.length; i++)
+ {
+ String dbname =sf.getSourceProxy(otherdb[i]).getDbName();
+ if (mname == null)
+ {
+ mname = "from '"+dbname+"'";
+ }
+ fetchr = new JMenuItem(otherdb[i]);
+ final String[] dassource = new String[] { otherdb[i] };
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(), alignPanel.alignFrame, dassource)
+ .fetchDBRefs(false);
+ }
+ }).start();
+ }
+
+ });
+ fetchr.setToolTipText("Retrieve from "+dbname);
+ dfetch.add(fetchr);
+ if (comp++==mcomp || i==(otherdb.length-1))
+ {
+ dfetch.setText(mname+" to '"+dbname+"'");
+ rfetch.add(dfetch);
+ dfetch = new JMenu();
+ mname = null;
+ comp=0;
+ }
+ }
+ }
+ }
}
class PrintThread extends Thread
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