X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAlignFrame.java;h=6876984c03889f4e18426bbb27ccc50ad405b54a;hb=a7f8fa9c06d82efbbdbc6a0bf1054bb21610b353;hp=efb0f4c8ef979f6fcf1aecae963375d602c40551;hpb=125c5ec00162cae434cdc5ca073e40ce089d21a1;p=jalview.git
diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java
index efb0f4c..6876984 100644
--- a/src/jalview/appletgui/AlignFrame.java
+++ b/src/jalview/appletgui/AlignFrame.java
@@ -1,18 +1,18 @@
/*
* Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
* Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
- *
+ *
* This file is part of Jalview.
- *
+ *
* Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
+ * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * Jalview is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License along with Jalview. If not, see .
*/
package jalview.appletgui;
@@ -35,6 +35,7 @@ import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.io.AnnotationFile;
@@ -87,9 +88,18 @@ import java.net.URL;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+
+import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
+import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
+import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
+
public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemListener, KeyListener
{
public AlignmentPanel alignPanel;
@@ -101,7 +111,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
int DEFAULT_HEIGHT = 500;
String jalviewServletURL;
-
+
public AlignFrame(AlignmentI al, jalview.bin.JalviewLite applet, String title, boolean embedded)
{
@@ -231,25 +241,28 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* Load a features file onto the alignment
- *
+ *
* @param file file URL, content, or other resolvable path
* @param type is protocol for accessing data referred to by file
*/
- public void parseFeaturesFile(String file, String type)
+ public boolean parseFeaturesFile(String file, String type)
{
- parseFeaturesFile(file, type, true);
+ return parseFeaturesFile(file, type, true);
}
-
+
/**
* Load a features file onto the alignment
- *
+ *
* @param file file URL, content, or other resolvable path
* @param type is protocol for accessing data referred to by file
* @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded
+ * @return true if data parsed as a features file
*/
- public void parseFeaturesFile(String file, String type, boolean autoenabledisplay)
- {
+ public boolean parseFeaturesFile(String file, String type, boolean autoenabledisplay)
+ {
+ // TODO: test if importing a features file onto an alignment which already has features with links overwrites the original links.
+
Hashtable featureLinks = new Hashtable();
boolean featuresFile = false;
try
@@ -279,10 +292,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
viewport.featureSettings.refreshTable();
}
alignPanel.paintAlignment(true);
+ statusBar.setText("Successfully added features to alignment.");
}
-
+ return featuresFile;
}
+ @Override
public void keyPressed(KeyEvent evt)
{
if (viewport.cursorMode
@@ -296,8 +311,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
{
case 27: // escape key
deselectAllSequenceMenuItem_actionPerformed();
-
- alignPanel.alabels.cancelDrag();
+
+ alignPanel.alabels.cancelDrag();
break;
case KeyEvent.VK_X:
if (evt.isControlDown() || evt.isMetaDown())
@@ -544,7 +559,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* called by key handler and the hide all/show all menu items
- *
+ *
* @param toggleSeqs
* @param toggleCols
*/
@@ -609,14 +624,17 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
}
}
+ @Override
public void keyReleased(KeyEvent evt)
{
}
+ @Override
public void keyTyped(KeyEvent evt)
{
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == displayNonconservedMenuItem)
@@ -733,6 +751,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
this.alignPanel.annotationPanel.repaint();
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
Object source = evt.getSource();
@@ -753,9 +772,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
{
loadAnnotations();
}
- else if( source == loadScores ) {
- loadScores();
- }
else if (source == outputAnnotations)
{
outputAnnotations(true);
@@ -955,9 +971,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
else if (source == clustalColour)
{
abovePIDThreshold.setState(false);
- changeColour(new ClustalxColourScheme(
- viewport.getAlignment().getSequences(),
- viewport.getAlignment().getWidth()));
+ changeColour(new ClustalxColourScheme(viewport.getAlignment(),null));
}
else if (source == zappoColour)
{
@@ -1104,18 +1118,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
public void loadAnnotations()
{
CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
- cap.setText("Paste your features / annotations file here.");
+ cap.setText("Paste your features / annotations / T-coffee score file here.");
cap.setAnnotationImport();
Frame frame = new Frame();
frame.add(cap);
jalview.bin.JalviewLite.addFrame(frame, "Paste Annotations ", 400, 300);
}
-
- public void loadScores() {
- //TODO
-
- }
public String outputAnnotations(boolean displayTextbox)
{
@@ -1178,7 +1187,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
features = "# No features visible - paste some and import them here.";
frimport=true;
}
-
+
CutAndPasteTransfer cap = new CutAndPasteTransfer(frimport, this);
if (frimport)
{
@@ -1290,8 +1299,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
public void closeMenuItem_actionPerformed()
{
PaintRefresher.RemoveComponent(alignPanel);
- PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
- PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
+ if (alignPanel.seqPanel!=null && alignPanel.seqPanel.seqCanvas!=null)
+ {
+ PaintRefresher.RemoveComponent(alignPanel.seqPanel.seqCanvas);
+ }
+ if (alignPanel.idPanel!=null && alignPanel.idPanel.idCanvas!=null) {
+ PaintRefresher.RemoveComponent(alignPanel.idPanel.idCanvas);
+ }
if (PaintRefresher.components.size() == 0 && viewport.applet == null)
{
@@ -1352,7 +1366,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* TODO: JAL-1104
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
@@ -1381,7 +1395,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* TODO: JAL-1104
* DOCUMENT ME!
- *
+ *
* @param e
* DOCUMENT ME!
*/
@@ -1456,57 +1470,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
{
return;
}
-
- if (up)
- {
- for (int i = 1; i < viewport.getAlignment().getHeight(); i++)
- {
- SequenceI seq = viewport.getAlignment().getSequenceAt(i);
- if (!sg.getSequences(null).contains(seq))
- {
- continue;
- }
-
- SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);
- if (sg.getSequences(null).contains(temp))
- {
- continue;
- }
-
- viewport.getAlignment().getSequences().setElementAt(temp, i);
- viewport.getAlignment().getSequences().setElementAt(seq, i - 1);
- }
- }
- else
- {
- for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)
- {
- SequenceI seq = viewport.getAlignment().getSequenceAt(i);
- if (!sg.getSequences(viewport.getHiddenRepSequences()).contains(seq))
- {
- continue;
- }
-
- SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);
- if (sg.getSequences(viewport.getHiddenRepSequences()).contains(temp))
- {
- continue;
- }
-
- viewport.getAlignment().getSequences().setElementAt(temp, i);
- viewport.getAlignment().getSequences().setElementAt(seq, i + 1);
- }
- }
-
+ viewport.getAlignment().moveSelectedSequencesByOne(sg, up ? null : viewport.getHiddenRepSequences(), up);
alignPanel.paintAlignment(true);
}
synchronized void slideSequences(boolean right, int size)
{
- Vector sg = new Vector();
+ Listsg = new Vector();
if (viewport.cursorMode)
{
- sg.addElement(viewport.getAlignment()
+ sg.add(viewport.getAlignment()
.getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
}
else if (viewport.getSelectionGroup() != null
@@ -1522,7 +1495,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
return;
}
- Vector invertGroup = new Vector();
+ Vector invertGroup = new Vector();
for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
{
@@ -1530,13 +1503,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
invertGroup.addElement(viewport.getAlignment().getSequenceAt(i));
}
- SequenceI[] seqs1 = new SequenceI[sg.size()];
- for (int i = 0; i < sg.size(); i++)
- seqs1[i] = (SequenceI) sg.elementAt(i);
+ SequenceI[] seqs1 = sg.toArray(new SequenceI[sg.size()]);
- SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
+ SequenceI[] seqs2 = invertGroup.toArray(new SequenceI[invertGroup.size()]);
for (int i = 0; i < invertGroup.size(); i++)
- seqs2[i] = (SequenceI) invertGroup.elementAt(i);
+ seqs2[i] = invertGroup.elementAt(i);
SlideSequencesCommand ssc;
if (right)
@@ -1828,7 +1799,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* group consensus toggled
- *
+ *
*/
protected void showGroupConsensus_actionPerformed()
{
@@ -1848,7 +1819,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showConsensusHistogram_actionPerformed(java.awt
* .event.ActionEvent)
@@ -1860,7 +1831,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
}
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.jbgui.GAlignFrame#showConsensusProfile_actionPerformed(java.awt
* .event.ActionEvent)
@@ -1897,9 +1868,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
Color col = new Color((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255));
col = col.brighter();
- for (Enumeration sq = gps[g].getSequences(null).elements(); sq
- .hasMoreElements(); viewport.setSequenceColour(
- (SequenceI) sq.nextElement(), col))
+ for (SequenceI sq : gps[g].getSequences(null))
+ viewport.setSequenceColour(
+ sq, col)
;
}
PaintRefresher.Refresh(this, viewport.getSequenceSetId());
@@ -2016,12 +1987,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
addHistoryItem(trimRegion);
- Vector groups = viewport.getAlignment().getGroups();
- for (int i = 0; i < groups.size(); i++)
- {
- SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
+ for (SequenceGroup sg:viewport.getAlignment().getGroups())
+ {
if ((trimLeft && !sg.adjustForRemoveLeft(column))
|| (!trimLeft && !sg.adjustForRemoveRight(column)))
{
@@ -2113,7 +2082,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* create a new view derived from the current view
- *
+ *
* @param viewtitle
* @return frame for the new view
*/
@@ -2186,7 +2155,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
}
/**
- *
+ *
* @return list of feature groups on the view
*/
public String[] getFeatureGroups()
@@ -2202,7 +2171,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* get sequence feature groups that are hidden or shown
- *
+ *
* @param visible
* true is visible
* @return list
@@ -2220,7 +2189,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* Change the display state for the given feature groups
- *
+ *
* @param groups
* list of group strings
* @param state
@@ -2288,11 +2257,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
overview.getPreferredSize().height + 50);
frame.pack();
+ final AlignmentPanel ap=alignPanel;
frame.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent e)
{
- alignPanel.setOverviewPanel(null);
+ if (ap!=null) {
+ ap.setOverviewPanel(null);
+ }
};
});
@@ -2344,71 +2317,9 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
cs.setConsensus(viewport.getSequenceConsensusHash());
- }
+ }
viewport.setGlobalColourScheme(cs);
- if (viewport.getColourAppliesToAllGroups())
- {
- Vector groups = viewport.getAlignment().getGroups();
- for (int i = 0; i < groups.size(); i++)
- {
- SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
-
- if (cs == null)
- {
- sg.cs = null;
- continue;
- }
- if (cs instanceof ClustalxColourScheme)
- {
- sg.cs = new ClustalxColourScheme(
- sg.getSequences(viewport.getHiddenRepSequences()),
- sg.getWidth());
- }
- else
- {
- try
- {
- sg.cs = cs.getClass().newInstance();
- } catch (Exception ex)
- {
- ex.printStackTrace();
- sg.cs = cs;
- }
- }
-
- if (viewport.getAbovePIDThreshold()
- || cs instanceof PIDColourScheme
- || cs instanceof Blosum62ColourScheme)
- {
- sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
- sg.cs.setConsensus(AAFrequency.calculate(
- sg.getSequences(viewport.getHiddenRepSequences()), 0,
- sg.getWidth()));
- }
- else
- {
- sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
- }
-
- if (viewport.getConservationSelected())
- {
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3,
- sg.getSequences(viewport.getHiddenRepSequences()), 0,
- viewport.getAlignment().getWidth() - 1);
- c.calculate();
- c.verdict(false, viewport.getConsPercGaps());
- sg.cs.setConservation(c);
- }
- else
- {
- sg.cs.setConservation(null);
- sg.cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
- }
-
- }
- }
if (alignPanel.getOverviewPanel() != null)
{
@@ -2633,7 +2544,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* sort the alignment using the given treePanel
- *
+ *
* @param treePanel
* tree used to sort view
* @param title
@@ -2654,7 +2565,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* Do any automatic reordering of the alignment and add the necessary bits to
* the menu structure for the new tree
- *
+ *
* @param treePanel
* @param title
*/
@@ -2665,14 +2576,16 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
sortByTreeMenu.add(item);
item.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent evt)
{
sortByTree(treePanel, title); // treePanel.getTitle());
}
});
-
+
treePanel.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowOpened(WindowEvent e)
{
if (viewport.sortByTree)
@@ -2682,6 +2595,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
super.windowOpened(e);
}
+ @Override
public void windowClosing(WindowEvent e)
{
sortByTreeMenu.remove(item);
@@ -2725,6 +2639,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
this.builddate = builddate;
}
+ @Override
public void paint(Graphics g)
{
g.setColor(Color.white);
@@ -2794,8 +2709,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
MenuItem loadTree = new MenuItem("Load Associated Tree ...");
MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ...");
-
- MenuItem loadScores = new MenuItem("Load Associated T-Coffee scores ...");
MenuItem outputFeatures = new MenuItem("Export Features ...");
@@ -2871,13 +2784,13 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
MenuItem purinePyrimidineColour = new MenuItem();
MenuItem RNAHelixColour = new MenuItem();
-
+
MenuItem userDefinedColour = new MenuItem();
MenuItem PIDColour = new MenuItem();
MenuItem BLOSUM62Colour = new MenuItem();
-
+
MenuItem tcoffeeColour = new MenuItem();
MenuItem njTreeBlosumMenuItem = new MenuItem();
@@ -2965,7 +2878,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
CheckboxMenuItem seqLimits = new CheckboxMenuItem();
CheckboxMenuItem centreColumnLabelFlag = new CheckboxMenuItem();
-
+
CheckboxMenuItem followMouseOverFlag = new CheckboxMenuItem();
Menu autoAnnMenu=new Menu();
CheckboxMenuItem showSequenceLogo= new CheckboxMenuItem();
@@ -2990,6 +2903,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
item.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
outputText_actionPerformed(e);
@@ -3003,7 +2917,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
loadTree.addActionListener(this);
loadAnnotations.addActionListener(this);
- loadScores.addActionListener(this);
outputFeatures.addActionListener(this);
outputAnnotations.addActionListener(this);
selectAllSequenceMenuItem.addActionListener(this);
@@ -3191,7 +3104,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
applyAutoAnnotationSettings.setLabel("Apply to all groups");
applyAutoAnnotationSettings.setState(true);
autoAnnMenu.setLabel("Autocalculated Annotation");
-
+
invertColSel.addActionListener(this);
showColumns.addActionListener(this);
showSeqs.addActionListener(this);
@@ -3221,8 +3134,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
fileMenu.add(inputText);
fileMenu.add(loadTree);
fileMenu.add(loadAnnotations);
- fileMenu.add(loadScores);
-
+
fileMenu.addSeparator();
fileMenu.add(outputTextboxMenu);
fileMenu.add(outputFeatures);
@@ -3380,7 +3292,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
* Attach the alignFrame panels after embedding menus, if necessary. This used
* to be called setEmbedded, but is now creates the dropdown menus in a
* platform independent manner to avoid OSX/Mac menu appendage daftness.
- *
+ *
* @param reallyEmbedded
* true to attach the view to the applet area on the page rather than
* in a new window
@@ -3408,14 +3320,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
final AlignFrame me = this;
viewport.applet.addFocusListener(new FocusListener()
{
-
+
@Override
public void focusLost(FocusEvent e)
{
if (me.viewport.applet.currentAlignFrame==me) {
me.viewport.applet.currentAlignFrame = null;
}}
-
+
@Override
public void focusGained(FocusEvent e)
{
@@ -3450,7 +3362,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
* structures in the original jmol window. Note This method doesn't work
* without an additional javascript library to exchange messages between the
* distinct applets. See http://issues.jalview.org/browse/JAL-621
- *
+ *
* @param viewer
* JmolViewer instance
* @param sequenceIds
@@ -3515,7 +3427,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
}
/**
* bind a pdb file to a sequence in the current view
- *
+ *
* @param sequenceId
* - sequenceId within the dataset.
* @param pdbEntryString
@@ -3687,7 +3599,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
/**
* modify the current selection, providing the user has not made a selection already.
- * @param sel - sequences from this alignment
+ * @param sel - sequences from this alignment
* @param csel - columns to be selected on the alignment
*/
public void select(SequenceGroup sel, ColumnSelection csel)
@@ -3697,15 +3609,15 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
public void scrollTo(int row, int column)
{
- alignPanel.seqPanel.scrollTo(row, column);
+ alignPanel.seqPanel.scrollTo(row, column);
}
public void scrollToRow(int row)
{
- alignPanel.seqPanel.scrollToRow(row);
+ alignPanel.seqPanel.scrollToRow(row);
}
public void scrollToColumn(int column)
{
- alignPanel.seqPanel.scrollToColumn(column);
+ alignPanel.seqPanel.scrollToColumn(column);
}
/**
* @return the alignments unique ID.
@@ -3713,41 +3625,56 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, ItemLis
public String getSequenceSetId() {
return viewport.getSequenceSetId();
}
-
-
+
+
/**
- * Load the (T-Coffee) score file from the specified url
- *
- * @param url The absolute path from where download and read the score file
- * @throws IOException
+ * Load the (T-Coffee) score file from the specified url
+ *
+ * @param source File/URL/T-COFFEE score file contents
+ * @throws IOException
+ * @return true if alignment was annotated with data from source
+ * @throws SAXException
+ * @throws ParserConfigurationException
+ * @throws ExceptionFileFormatOrSyntax
+ * @throws ExceptionLoadingFailed
+ * @throws ExceptionPermissionDenied
*/
- public void loadScoreFile( URL url ) throws IOException {
- // TODO: refactor to string/standard jalview data importer
- TCoffeeScoreFile file = TCoffeeScoreFile.load( new InputStreamReader( url.openStream() ) );
- if( file == null ) {
- // TODO: raise a dialog box here rather than bomb out.
-
- throw new RuntimeException("The file provided does not match the T-Coffee scores file format");
+ public boolean loadScoreFile( String source ) throws IOException, ExceptionFileFormatOrSyntax, ParserConfigurationException, SAXException, ExceptionPermissionDenied, ExceptionLoadingFailed {
+
+ TCoffeeScoreFile file = new TCoffeeScoreFile(source, AppletFormatAdapter.checkProtocol(source));
+ if( !file.isValid()) {
+ // TODO: raise dialog for gui
+ System.err.println("Problems parsing T-Coffee scores: "+file.getWarningMessage());
+ System.err.println("Origin was:\n"+source);
+ return false;
}
-
+
/*
* check that the score matrix matches the alignment dimensions
*/
- AlignmentI aln;
+ AlignmentI aln;
if( (aln=viewport.getAlignment()) != null && (aln.getHeight() != file.getHeight() || aln.getWidth() != file.getWidth()) ) {
// TODO: raise a dialog box here rather than bomb out.
- throw new RuntimeException("The scores matrix does not match the alignment dimensions");
-
+ System.err.println("The scores matrix does not match the alignment dimensions");
+
}
-
+
// TODO add parameter to indicate if matching should be done
if (file.annotateAlignment(alignPanel.getAlignment(), false))
{
- tcoffeeColour.setEnabled(true);
+ alignPanel.fontChanged();
+ tcoffeeColour.setEnabled(true);
// switch to this color
changeColour(new TCoffeeColourScheme(alignPanel.getAlignment()));
+ return true;
+ } else {
+ System.err.println("Problems resolving T-Coffee scores:");
+ if (file.getWarningMessage()!=null) {
+ System.err.println(file.getWarningMessage());
+ }
}
+ return false;
}
-
-
+
+
}