/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
+ * Copyright (C) 2009 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
{
error += "Please select the source database\n";
}
- com.stevesoft.pat.Regex empty = new com.stevesoft.pat.Regex("\\s+", "");
+ // TODO: make this transformation optional and configurable
+ com.stevesoft.pat.Regex empty = new com.stevesoft.pat.Regex("(\\s|[,; ])+",";"); //\\s+", "");
textArea.setText(empty.replaceAll(textArea.getText()));
- if (textArea.getText().length() == 0)
+ // see if there's anthing to search with
+ if (!new com.stevesoft.pat.Regex("[A-Za-z0-9_.]").search(textArea.getText()))
{
error += "Please enter a (semi-colon separated list of) database id(s)";
}
return;
}
AlignmentI aresult = null;
+ Object source = database.getSelectedItem();
+ Enumeration en = new StringTokenizer(textArea.getText(), ";");
try
{
guiWindow.setProgressBar("Fetching Sequences from "
+ database.getSelectedItem(), Thread.currentThread()
.hashCode());
- aresult = sfetch.getSourceProxy(
- (String) sources.get(database.getSelectedItem()))
- .getSequenceRecords(textArea.getText());
+ DbSourceProxy proxy = sfetch.getSourceProxy(
+ (String) sources.get(source));
+ if (proxy.getAccessionSeparator()==null)
+ {
+ while (en.hasMoreElements())
+ {
+ String item = (String) en.nextElement();
+ try {
+ if (aresult!=null)
+ {
+ try {
+ // give the server a chance to breathe
+ Thread.sleep(5);
+ } catch (Exception e)
+ {
+ //
+ }
+
+ }
+ AlignmentI indres = proxy.getSequenceRecords(item);
+ if (indres!=null)
+ {
+ if (aresult == null)
+ {
+ aresult = indres;
+ } else {
+ aresult.append(indres);
+ }
+ }
+ } catch (Exception e)
+ {
+ jalview.bin.Cache.log.info("Error retrieving "+item+" from "+source,e);
+ }
+ }
+ } else {
+ StringBuffer multiacc = new StringBuffer();
+ while (en.hasMoreElements())
+ {
+ multiacc.append(en.nextElement());
+ if (en.hasMoreElements())
+ {
+ multiacc.append(proxy.getAccessionSeparator());
+ }
+ }
+ aresult = proxy
+ .getSequenceRecords(multiacc.toString());
+ }
} catch (Exception e)
{
{
title = "Retrieved from " + database.getSelectedItem();
}
-
+ SequenceFeature[] sfs=null;
+ for (Enumeration sq=al.getSequences().elements(); sq.hasMoreElements();)
+ {
+ if ((sfs=((SequenceI)sq.nextElement()).getDatasetSequence().getSequenceFeatures())!=null)
+ {
+ if (sfs.length>0)
+ {
+ af.setShowSeqFeatures(true);
+ break;
+ }
+ }
+
+ }
Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);