import jalview.io.JalviewFileView;
import jalview.io.JnetAnnotationMaker;
import jalview.io.NewickFile;
+import jalview.io.TCoffeeScoreFile;
import jalview.jbgui.GAlignFrame;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.NucleotideColourScheme;
import jalview.schemes.PIDColourScheme;
import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.RNAHelicesColourChooser;
import jalview.schemes.ResidueProperties;
import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TCoffeeColourScheme;
import jalview.schemes.TaylorColourScheme;
import jalview.schemes.TurnColourScheme;
import jalview.schemes.UserColourScheme;
import jalview.schemes.ZappoColourScheme;
-import jalview.ws.WSMenuEntryProviderI;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.seqfetcher.DbSourceProxy;
import java.awt.BorderLayout;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Vector;
import javax.swing.JButton;
AlignViewport viewport;
Vector alignPanels = new Vector();
-
+
/**
* Last format used to load or save alignments in this window
*/
*/
void init()
{
- if (viewport.getAlignmentConservationAnnotation()== null)
+ if (viewport.getAlignmentConservationAnnotation() == null)
{
BLOSUM62Colour.setEnabled(false);
conservationMenuItem.setEnabled(false);
|| evt.isShiftDown() || evt.isAltDown());
}
break;
-
- //case KeyEvent.VK_A:
- // if (viewport.cursorMode)
- // {
- // alignPanel.seqPanel.insertNucAtCursor(false,"A");
- // //System.out.println("A");
- // }
- // break;
- /*
- case KeyEvent.VK_CLOSE_BRACKET:
- if (viewport.cursorMode)
- {
- System.out.println("closing bracket");
- }
- break;
+
+ // case KeyEvent.VK_A:
+ // if (viewport.cursorMode)
+ // {
+ // alignPanel.seqPanel.insertNucAtCursor(false,"A");
+ // //System.out.println("A");
+ // }
+ // break;
+ /*
+ * case KeyEvent.VK_CLOSE_BRACKET: if (viewport.cursorMode) {
+ * System.out.println("closing bracket"); } break;
*/
case KeyEvent.VK_DELETE:
case KeyEvent.VK_BACK_SPACE:
rnahelicesColour.setEnabled(nucleotide);
purinePyrimidineColour.setEnabled(nucleotide);
// Remember AlignFrame always starts as protein
- //if (!nucleotide)
- // {
- // showTr
- // calculateMenu.remove(calculateMenu.getItemCount() - 2);
- // }
+ // if (!nucleotide)
+ // {
+ // showTr
+ // calculateMenu.remove(calculateMenu.getItemCount() - 2);
+ // }
}
/**
showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
showSequenceLogo.setSelected(av.isShowSequenceLogo());
normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
-
+
setColourSelected(ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
sortByTree.setSelected(av.sortByTree);
listenToViewSelections.setSelected(av.followSelection);
rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
- rnahelicesColour.setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
+ rnahelicesColour
+ .setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
setShowProductsEnabled();
updateEditMenuBar();
{
if (fileName != null)
{
+ // TODO: JAL-1108 - ensure all associated frames are closed regardless of originating file's format
// TODO: work out how to recover feature settings for correct view(s) when
// file is reloaded.
if (currentFileFormat.equals("Jalview"))
}
}
FormatAdapter f = new FormatAdapter();
- String output = f.formatSequences(format,
+ String output = f.formatSequences(
+ format,
(Alignment) viewport.getAlignment(), // class cast exceptions will
// occur in the distant future
- omitHidden, f.getCacheSuffixDefault(format), viewport.getColumnSelection());
+ omitHidden, f.getCacheSuffixDefault(format),
+ viewport.getColumnSelection());
if (output == null)
{
try
{
cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
- viewport.getAlignment(), omitHidden, viewport.getColumnSelection()));
+ viewport.getAlignment(), omitHidden,
+ viewport.getColumnSelection()));
Desktop.addInternalFrame(cap,
"Alignment output - " + e.getActionCommand(), 600, 500);
} catch (OutOfMemoryError oom)
public void exportAnnotations_actionPerformed(ActionEvent e)
{
- new AnnotationExporter().exportAnnotations(
- alignPanel,
+ new AnnotationExporter().exportAnnotations(alignPanel,
viewport.showAnnotation ? viewport.getAlignment()
- .getAlignmentAnnotation() : null, viewport.getAlignment()
- .getGroups(),
- ((Alignment) viewport.getAlignment()).alignmentProperties);
+ .getAlignmentAnnotation() : null, viewport
+ .getAlignment().getGroups(), ((Alignment) viewport
+ .getAlignment()).alignmentProperties);
}
public void associatedData_actionPerformed(ActionEvent e)
viewport.redoList.clear();
updateEditMenuBar();
viewport.updateHiddenColumns();
-// viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
-// && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
-// .getHiddenColumns().size() > 0);
+ // viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
+ // && viewport.getColumnSelection().getHiddenColumns() != null &&
+ // viewport.getColumnSelection()
+ // .getHiddenColumns().size() > 0);
}
}
if (originalSource != null)
{
- if (originalSource!=viewport)
+ if (originalSource != viewport)
{
- Cache.log.warn("Implementation worry: mismatch of viewport origin for undo");
+ Cache.log
+ .warn("Implementation worry: mismatch of viewport origin for undo");
}
originalSource.updateHiddenColumns();
-// originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
-// && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
-// .getHiddenColumns().size() > 0);
- originalSource.firePropertyChange("alignment", null,
- originalSource.getAlignment().getSequences());
+ // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
+ // null
+ // && viewport.getColumnSelection().getHiddenColumns() != null &&
+ // viewport.getColumnSelection()
+ // .getHiddenColumns().size() > 0);
+ originalSource.firePropertyChange("alignment", null, originalSource
+ .getAlignment().getSequences());
}
}
if (originalSource != null)
{
- if (originalSource!=viewport)
+ if (originalSource != viewport)
{
- Cache.log.warn("Implementation worry: mismatch of viewport origin for redo");
+ Cache.log
+ .warn("Implementation worry: mismatch of viewport origin for redo");
}
originalSource.updateHiddenColumns();
- //originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
- // && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
- // .getHiddenColumns().size() > 0);
- originalSource.firePropertyChange("alignment", null,
- originalSource.getAlignment().getSequences());
+ // originalSource.hasHiddenColumns = (viewport.getColumnSelection() !=
+ // null
+ // && viewport.getColumnSelection().getHiddenColumns() != null &&
+ // viewport.getColumnSelection()
+ // .getHiddenColumns().size() > 0);
+ originalSource.firePropertyChange("alignment", null, originalSource
+ .getAlignment().getSequences());
}
}
Vector sg = new Vector();
if (viewport.cursorMode)
{
- sg.addElement(viewport.getAlignment()
- .getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
+ sg.addElement(viewport.getAlignment().getSequenceAt(
+ alignPanel.seqPanel.seqCanvas.cursorY));
}
else if (viewport.getSelectionGroup() != null
- && viewport.getSelectionGroup().getSize() != viewport.getAlignment()
- .getHeight())
+ && viewport.getSelectionGroup().getSize() != viewport
+ .getAlignment().getHeight())
{
sg = viewport.getSelectionGroup().getSequences(
viewport.getHiddenRepSequences());
}
RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
- "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());
+ "Remove Gapped Columns", seqs, start, end,
+ viewport.getAlignment());
addHistoryItem(removeGapCols);
// Hide everything by the current selection - this is a hack - we do the
// invert and then hide
// first check that there will be visible columns after the invert.
- if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()
- .getSelected().size() > 0)
+ if ((viewport.getColumnSelection() != null
+ && viewport.getColumnSelection().getSelected() != null && viewport
+ .getColumnSelection().getSelected().size() > 0)
|| (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
.getEndRes()))
{
hideSelSequences_actionPerformed(null);
hide = true;
}
- else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))
+ else if (!(toggleCols && viewport.getColumnSelection().getSelected()
+ .size() > 0))
{
showAllSeqs_actionPerformed(null);
}
*/
public void clustalColour_actionPerformed(ActionEvent e)
{
- changeColour(new ClustalxColourScheme(
- viewport.getAlignment().getSequences(),
- viewport.getAlignment().getWidth()));
+ changeColour(new ClustalxColourScheme(viewport.getAlignment()
+ .getSequences(), viewport.getAlignment().getWidth()));
}
/**
{
changeColour(new PurinePyrimidineColourScheme());
}
+
/*
- public void covariationColour_actionPerformed(ActionEvent e)
- {
- changeColour(new CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation()[0]));
- }
- */
+ * public void covariationColour_actionPerformed(ActionEvent e) {
+ * changeColour(new
+ * CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation
+ * ()[0])); }
+ */
public void annotationColour_actionPerformed(ActionEvent e)
{
new AnnotationColourChooser(viewport, alignPanel);
}
-
+
public void rnahelicesColour_actionPerformed(ActionEvent e)
{
new RNAHelicesColourChooser(viewport, alignPanel);
*/
public void changeColour(ColourSchemeI cs)
{
+ // TODO: compare with applet and pull up to model method
int threshold = 0;
if (cs != null)
if (cs instanceof ClustalxColourScheme)
{
- sg.cs = new ClustalxColourScheme(
- sg.getSequences(viewport.getHiddenRepSequences()),
- sg.getWidth());
+ sg.cs = new ClustalxColourScheme(sg.getSequences(viewport
+ .getHiddenRepSequences()), sg.getWidth());
}
else if (cs instanceof UserColourScheme)
{
{
try
{
- sg.cs = (ColourSchemeI) cs.getClass().newInstance();
+ sg.cs = cs.getClass().newInstance();
} catch (Exception ex)
{
}
if (viewport.getConservationSelected())
{
Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3,
- sg.getSequences(viewport.getHiddenRepSequences()),
- sg.getStartRes(), sg.getEndRes() + 1);
+ ResidueProperties.propHash, 3, sg.getSequences(viewport
+ .getHiddenRepSequences()), sg.getStartRes(),
+ sg.getEndRes() + 1);
c.calculate();
c.verdict(false, viewport.getConsPercGaps());
sg.cs.setConservation(c);
protected void modifyConservation_actionPerformed(ActionEvent e)
{
if (viewport.getConservationSelected()
- && viewport.getGlobalColourScheme()!= null)
+ && viewport.getGlobalColourScheme() != null)
{
SliderPanel.setConservationSlider(alignPanel,
viewport.getGlobalColourScheme(), "Background");
{
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByID(viewport.getAlignment());
- addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
+ addHistoryItem(new OrderCommand("ID Sort", oldOrder,
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
.getAlignment().getSequences());
}
}
+
public void sortByTreeOption_actionPerformed(ActionEvent e)
{
viewport.sortByTree = sortByTree.isSelected();
{
viewport.followSelection = listenToViewSelections.isSelected();
}
+
/**
* DOCUMENT ME!
*
// pointers
AlignmentSorter.sortBy(viewport.getAlignment(), order);
- addHistoryItem(new OrderCommand(order.getName(), oldOrder,
- viewport.getAlignment()));
+ addHistoryItem(new OrderCommand(order.getName(), oldOrder, viewport
+ .getAlignment()));
alignPanel.paintAlignment(true);
}
{
tp.sortByTree_actionPerformed(null);
addHistoryItem(tp.sortAlignmentIn(alignPanel));
-
+
}
});
}
}
+ @Override
+ protected void tcoffeeColorScheme_actionPerformed(ActionEvent e)
+ {
+ changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
+ }
+
public TreePanel ShowNewickTree(NewickFile nf, String title)
{
return ShowNewickTree(nf, title, 600, 500, 4, 5);
// TODO: group services by location as well as function and/or
// introduce
// object broker mechanism.
- final Vector wsmenu = new Vector();
+ final Vector<JMenu> wsmenu = new Vector<JMenu>();
final IProgressIndicator af = me;
final JMenu msawsmenu = new JMenu("Alignment");
final JMenu secstrmenu = new JMenu(
"Secondary Structure Prediction");
- final JMenu seqsrchmenu = new JMenu(
- "Sequence Database Search");
- final JMenu analymenu = new JMenu(
- "Analysis");
- // JAL-940 - only show secondary structure prediction services from the legacy server
+ final JMenu seqsrchmenu = new JMenu("Sequence Database Search");
+ final JMenu analymenu = new JMenu("Analysis");
+ final JMenu dismenu = new JMenu("Disorder");
+ // JAL-940 - only show secondary structure prediction services from
+ // the legacy server
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
- // &&
- Discoverer.services != null
- && (Discoverer.services.size() > 0))
+ // &&
+ Discoverer.services != null && (Discoverer.services.size() > 0))
{
// TODO: refactor to allow list of AbstractName/Handler bindings to
// be
Vector msaws = null; // (Vector) Discoverer.services.get("MsaWS");
Vector secstrpr = (Vector) Discoverer.services
.get("SecStrPred");
- Vector seqsrch = null; // (Vector) Discoverer.services.get("SeqSearch");
+ Vector seqsrch = null; // (Vector)
+ // Discoverer.services.get("SeqSearch");
// TODO: move GUI generation code onto service implementation - so a
// client instance attaches itself to the GUI with method call like
// jalview.ws.MsaWSClient.bind(servicehandle, Desktop.instance,
}
}
- // TODO: move into separate menu builder class.
- if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
- {
- Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
- if (jws2servs != null)
- {
- if (jws2servs.hasServices())
- {
- jws2servs.attachWSMenuEntry(msawsmenu, me);
- }
- }
- }
- // Add all submenus in the order they should appear on the web services menu
+ // Add all submenus in the order they should appear on the web
+ // services menu
wsmenu.add(msawsmenu);
wsmenu.add(secstrmenu);
+ wsmenu.add(dismenu);
wsmenu.add(analymenu);
+ // final ArrayList<JMenu> submens=new ArrayList<JMenu>();
+ // submens.add(msawsmenu);
+ // submens.add(secstrmenu);
+ // submens.add(dismenu);
+ // submens.add(analymenu);
+
// No search services yet
// wsmenu.add(seqsrchmenu);
{
webService.add(me.webServiceNoServices);
}
+ // TODO: move into separate menu builder class.
+ if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ if (jws2servs != null)
+ {
+ if (jws2servs.hasServices())
+ {
+ jws2servs.attachWSMenuEntry(webService, me);
+ }
+ if (jws2servs.isRunning())
+ {
+ JMenuItem tm = new JMenuItem(
+ "Still discovering JABA Services");
+ tm.setEnabled(false);
+ webService.add(tm);
+ }
+ }
+ }
+
build_urlServiceMenu(me.webService);
build_fetchdbmenu(webService);
+ for (JMenu item : wsmenu)
+ {
+ if (item.getItemCount() == 0)
+ {
+ item.setEnabled(false);
+ }
+ else
+ {
+ item.setEnabled(true);
+ }
+ }
} catch (Exception e)
{
}
}
-
/**
* construct any groupURL type service menu entries.
*
* AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
*
* @Override public void actionPerformed(ActionEvent e) {
- * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.getAlignment(),
+ * jalview.datamodel.AlignmentView
+ * .testSelectionViews(af.viewport.getAlignment(),
* af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
*
* }); webService.add(testAlView);
// rest-style services with other types of analysis/calculation service
// SHmmr test client - still being implemented.
// DEBUG - alignmentView
-
- for (jalview.ws.rest.RestClient client: jalview.ws.rest.RestClient.getRestClients()) {
- client.attachWSMenuEntry(JvSwingUtils.findOrCreateMenu(webService, client.getAction()), this);
+
+ for (jalview.ws.rest.RestClient client : jalview.ws.rest.RestClient
+ .getRestClients())
+ {
+ client.attachWSMenuEntry(
+ JvSwingUtils.findOrCreateMenu(webService, client.getAction()),
+ this);
}
if (Cache.getDefault("SHOW_ENFIN_SERVICES", true))
boolean featuresFile = false;
try
{
- featuresFile = new FeaturesFile(file, type)
- .parse(viewport.getAlignment().getDataset(),
- alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
- false, jalview.bin.Cache.getDefault(
- "RELAXEDSEQIDMATCHING", false));
+ featuresFile = new FeaturesFile(file, type).parse(viewport
+ .getAlignment().getDataset(), alignPanel.seqPanel.seqCanvas
+ .getFeatureRenderer().featureColours, false,
+ jalview.bin.Cache.getDefault("RELAXEDSEQIDMATCHING", false));
} catch (Exception ex)
{
ex.printStackTrace();
int l = 0, c = pdbfn.indexOf(".");
while (mtch == null && c != -1)
{
- do
+ do
{
l = c;
} while ((c = pdbfn.indexOf(".", l)) > l);
// try and associate
// TODO: may want to set a standard ID naming formalism for
// associating PDB files which have no IDs.
- for (SequenceI toassoc: (SequenceI[])fm[2]) {
- PDBEntry pe = new AssociatePdbFileWithSeq()
- .associatePdbWithSeq((String) fm[0], (String) fm[1],
- toassoc, false);
- if (pe != null)
+ for (SequenceI toassoc : (SequenceI[]) fm[2])
{
- System.err
- .println("Associated file : " + ((String) fm[0])
- + " with "
- + toassoc.getDisplayId(true));
- assocfiles++;
- }
+ PDBEntry pe = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq((String) fm[0],
+ (String) fm[1], toassoc, false);
+ if (pe != null)
+ {
+ System.err.println("Associated file : "
+ + ((String) fm[0]) + " with "
+ + toassoc.getDisplayId(true));
+ assocfiles++;
+ }
}
alignPanel.paintAlignment(true);
}
if (!isAnnotation)
{
- // try to see if its a JNet 'concise' style annotation file *before* we
- // try to parse it as a features file
- if (format == null)
+ // first see if its a T-COFFEE score file
+ TCoffeeScoreFile tcf = null;
+ try
{
- format = new IdentifyFile().Identify(file, protocol);
- }
- if (format.equalsIgnoreCase("JnetFile"))
+ tcf = new TCoffeeScoreFile(file, protocol);
+ if (tcf.isValid())
+ {
+ if (tcf.annotateAlignment(viewport.getAlignment(), true))
+ {
+ tcoffeeColour.setEnabled(true);
+ tcoffeeColour.setSelected(true);
+ changeColour(new TCoffeeColourScheme(viewport.getAlignment()));
+ isAnnotation = true;
+ statusBar
+ .setText("Successfully pasted T-Coffee scores to alignment.");
+ }
+ else
+ {
+ // some problem - if no warning its probable that the ID matching process didn't work
+ JOptionPane.showMessageDialog(Desktop.desktop,
+ tcf.getWarningMessage()==null ? "Check that the file matches sequence IDs in the alignment." : tcf.getWarningMessage(),
+ "Problem reading T-COFFEE score file",
+ JOptionPane.WARNING_MESSAGE);
+ }
+ }
+ else
+ {
+ tcf = null;
+ }
+ } catch (Exception x)
{
- jalview.io.JPredFile predictions = new jalview.io.JPredFile(file,
- protocol);
- new JnetAnnotationMaker().add_annotation(predictions,
- viewport.getAlignment(), 0, false);
- isAnnotation = true;
+ Cache.log.debug("Exception when processing data source as T-COFFEE score file",x);
+ tcf = null;
}
- else
+ if (tcf == null)
{
- /*
- * if (format.equalsIgnoreCase("PDB")) {
- *
- * String pdbfn = ""; // try to match up filename with sequence id try
- * { if (protocol == jalview.io.FormatAdapter.FILE) { File fl = new
- * File(file); pdbfn = fl.getName(); } else if (protocol ==
- * jalview.io.FormatAdapter.URL) { URL url = new URL(file); pdbfn =
- * url.getFile(); } } catch (Exception e) { } ; if (assocSeq == null)
- * { SequenceIdMatcher idm = new SequenceIdMatcher(viewport
- * .getAlignment().getSequencesArray()); if (pdbfn.length() > 0) { //
- * attempt to find a match in the alignment SequenceI mtch =
- * idm.findIdMatch(pdbfn); int l = 0, c = pdbfn.indexOf("."); while
- * (mtch == null && c != -1) { while ((c = pdbfn.indexOf(".", l)) > l)
- * { l = c; } if (l > -1) { pdbfn = pdbfn.substring(0, l); } mtch =
- * idm.findIdMatch(pdbfn); } if (mtch != null) { // try and associate
- * // prompt ? PDBEntry pe = new AssociatePdbFileWithSeq()
- * .associatePdbWithSeq(file, protocol, mtch, true); if (pe != null) {
- * System.err.println("Associated file : " + file + " with " +
- * mtch.getDisplayId(true)); alignPanel.paintAlignment(true); } } //
- * TODO: maybe need to load as normal otherwise return; } }
- */
+ // try to see if its a JNet 'concise' style annotation file *before*
+ // we
// try to parse it as a features file
- boolean isGroupsFile = parseFeaturesFile(file, protocol);
- // if it wasn't a features file then we just treat it as a general
- // alignment file to load into the current view.
- if (!isGroupsFile)
+ if (format == null)
{
- new FileLoader().LoadFile(viewport, file, protocol, format);
+ format = new IdentifyFile().Identify(file, protocol);
+ }
+ if (format.equalsIgnoreCase("JnetFile"))
+ {
+ jalview.io.JPredFile predictions = new jalview.io.JPredFile(
+ file, protocol);
+ new JnetAnnotationMaker().add_annotation(predictions,
+ viewport.getAlignment(), 0, false);
+ isAnnotation = true;
}
else
{
- alignPanel.paintAlignment(true);
+ /*
+ * if (format.equalsIgnoreCase("PDB")) {
+ *
+ * String pdbfn = ""; // try to match up filename with sequence id
+ * try { if (protocol == jalview.io.FormatAdapter.FILE) { File fl =
+ * new File(file); pdbfn = fl.getName(); } else if (protocol ==
+ * jalview.io.FormatAdapter.URL) { URL url = new URL(file); pdbfn =
+ * url.getFile(); } } catch (Exception e) { } ; if (assocSeq ==
+ * null) { SequenceIdMatcher idm = new SequenceIdMatcher(viewport
+ * .getAlignment().getSequencesArray()); if (pdbfn.length() > 0) {
+ * // attempt to find a match in the alignment SequenceI mtch =
+ * idm.findIdMatch(pdbfn); int l = 0, c = pdbfn.indexOf("."); while
+ * (mtch == null && c != -1) { while ((c = pdbfn.indexOf(".", l)) >
+ * l) { l = c; } if (l > -1) { pdbfn = pdbfn.substring(0, l); } mtch
+ * = idm.findIdMatch(pdbfn); } if (mtch != null) { // try and
+ * associate // prompt ? PDBEntry pe = new AssociatePdbFileWithSeq()
+ * .associatePdbWithSeq(file, protocol, mtch, true); if (pe != null)
+ * { System.err.println("Associated file : " + file + " with " +
+ * mtch.getDisplayId(true)); alignPanel.paintAlignment(true); } } //
+ * TODO: maybe need to load as normal otherwise return; } }
+ */
+ // try to parse it as a features file
+ boolean isGroupsFile = parseFeaturesFile(file, protocol);
+ // if it wasn't a features file then we just treat it as a general
+ // alignment file to load into the current view.
+ if (!isGroupsFile)
+ {
+ new FileLoader().LoadFile(viewport, file, protocol, format);
+ }
+ else
+ {
+ alignPanel.paintAlignment(true);
+ }
}
}
}
{
final jalview.ws.SequenceFetcher sf = SequenceFetcher
.getSequenceFetcherSingleton(me);
- final String[] otherdb = sf.getOrderedSupportedSources();
- // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
- // jalview.util.QuickSort.sort(otherdb, otherdb);
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
-
+ String[] dbclasses = sf.getOrderedSupportedSources();
+ // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
+ // jalview.util.QuickSort.sort(otherdb, otherdb);
+ List<DbSourceProxy> otherdb;
JMenu dfetch = new JMenu();
- JMenuItem fetchr;
- rfetch.add(dfetch);
- int comp = 0, mcomp = 15;
+ JMenu ifetch = new JMenu();
+ JMenuItem fetchr = null;
+ int comp = 0, icomp = 0, mcomp = 15;
String mname = null;
- if (otherdb != null && otherdb.length > 0)
+ int dbi = 0;
+ for (String dbclass : dbclasses)
{
- for (int i = 0; i < otherdb.length; i++)
+ otherdb = sf.getSourceProxy(dbclass);
+ // add a single entry for this class, or submenu allowing 'fetch
+ // all' or pick one
+ if (otherdb == null || otherdb.size() < 1)
{
- 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] };
+ continue;
+ }
+ // List<DbSourceProxy> dbs=otherdb;
+ // otherdb=new ArrayList<DbSourceProxy>();
+ // for (DbSourceProxy db:dbs)
+ // {
+ // if (!db.isA(DBRefSource.ALIGNMENTDB)
+ // }
+ if (mname == null)
+ {
+ mname = "From " + dbclass;
+ }
+ if (otherdb.size() == 1)
+ {
+ final DbSourceProxy[] dassource = otherdb
+ .toArray(new DbSourceProxy[0]);
+ DbSourceProxy src = otherdb.get(0);
+ fetchr = new JMenuItem(src.getDbSource());
fetchr.addActionListener(new ActionListener()
{
}
});
- fetchr.setToolTipText("Retrieve from " + dbname);
+ fetchr.setToolTipText("<html>"
+ + JvSwingUtils.wrapTooltip("Retrieve from "
+ + src.getDbName()) + "<html>");
dfetch.add(fetchr);
- if (comp++ == mcomp || i == (otherdb.length - 1))
+ comp++;
+ }
+ else
+ {
+ final DbSourceProxy[] dassource = otherdb
+ .toArray(new DbSourceProxy[0]);
+ // fetch all entry
+ DbSourceProxy src = otherdb.get(0);
+ fetchr = new JMenuItem("Fetch All '" + src.getDbSource()
+ + "'");
+ fetchr.addActionListener(new ActionListener()
{
- dfetch.setText(mname + " to '" + dbname + "'");
- rfetch.add(dfetch);
- dfetch = new JMenu();
- mname = null;
- comp = 0;
+ 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("<html>"
+ + JvSwingUtils.wrapTooltip("Retrieve from all "
+ + otherdb.size() + " sources in "
+ + src.getDbSource() + "<br>First is :"
+ + src.getDbName()) + "<html>");
+ dfetch.add(fetchr);
+ comp++;
+ // and then build the rest of the individual menus
+ ifetch = new JMenu("Sources from " + src.getDbSource());
+ icomp = 0;
+ String imname = null;
+ int i = 0;
+ for (DbSourceProxy sproxy : otherdb)
+ {
+ String dbname = sproxy.getDbName();
+ String sname = dbname.length() > 5 ? dbname.substring(0,
+ 5) + "..." : dbname;
+ String msname = dbname.length() > 10 ? dbname.substring(
+ 0, 10) + "..." : dbname;
+ if (imname == null)
+ {
+ imname = "from '" + sname + "'";
+ }
+ fetchr = new JMenuItem(msname);
+ final DbSourceProxy[] dassrc =
+ { sproxy };
+ 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, dassrc)
+ .fetchDBRefs(false);
+ }
+ }).start();
+ }
+
+ });
+ fetchr.setToolTipText("<html>"
+ + JvSwingUtils.wrapTooltip("Retrieve from "
+ + dbname) + "</html>");
+ ifetch.add(fetchr);
+ ++i;
+ if (++icomp >= mcomp || i == (otherdb.size()))
+ {
+ ifetch.setText(imname + " to '" + sname + "'");
+ dfetch.add(ifetch);
+ ifetch = new JMenu();
+ imname = null;
+ icomp = 0;
+ comp++;
+ }
}
}
+ ++dbi;
+ if (comp >= mcomp || dbi >= (dbclasses.length))
+ {
+ dfetch.setText(mname + " to '" + dbclass + "'");
+ rfetch.add(dfetch);
+ dfetch = new JMenu();
+ mname = null;
+ comp = 0;
+ }
}
}
});
viewport.setShowSequenceLogo(showSequenceLogo.getState());
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
}
+
protected void normaliseSequenceLogo_actionPerformed(ActionEvent e)
{
viewport.setNormaliseSequenceLogo(normaliseSequenceLogo.getState());
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
}
+
protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e)
{
alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState());
SequenceGroup[] gps = jalview.analysis.Grouping.makeGroupsFrom(
viewport.getSequenceSelection(),
viewport.getAlignmentView(true).getSequenceStrings(
- viewport.getGapCharacter()),
- viewport.getAlignment().getGroups());
+ viewport.getGapCharacter()), viewport.getAlignment()
+ .getGroups());
viewport.getAlignment().deleteAllGroups();
viewport.sequenceColours = null;
viewport.setSelectionGroup(null);
"Implementation error: cannot show a view from another alignment in an AlignFrame.");
}
if (tabbedPane != null
- & alignPanels.indexOf(alignmentPanel) != tabbedPane.getSelectedIndex())
+ & alignPanels.indexOf(alignmentPanel) != tabbedPane
+ .getSelectedIndex())
{
tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
}