* @param type is protocol for accessing data referred to by file\r
*/\r
\r
- public void parseFeaturesFile(String file, String type)\r
+ public boolean parseFeaturesFile(String file, String type)\r
{\r
- parseFeaturesFile(file, type, true);\r
+ return parseFeaturesFile(file, type, true);\r
}\r
\r
/**\r
* @param file file URL, content, or other resolvable path\r
* @param type is protocol for accessing data referred to by file\r
* @param autoenabledisplay when true, display features flag will be automatically enabled if features are loaded\r
+ * @return true if data parsed as a features file\r
*/\r
- public void parseFeaturesFile(String file, String type, boolean autoenabledisplay)\r
+ public boolean parseFeaturesFile(String file, String type, boolean autoenabledisplay)\r
{ \r
+ // TODO: test if importing a features file onto an alignment which already has features with links overwrites the original links.\r
+ \r
Hashtable featureLinks = new Hashtable();\r
boolean featuresFile = false;\r
try\r
viewport.featureSettings.refreshTable();\r
}\r
alignPanel.paintAlignment(true);\r
+ statusBar.setText("Successfully added features to alignment.");\r
}\r
-\r
+ return featuresFile;\r
}\r
\r
public void keyPressed(KeyEvent evt)\r
{\r
loadAnnotations();\r
}\r
- else if( source == loadScores ) {\r
- loadScores();\r
- }\r
else if (source == outputAnnotations)\r
{\r
outputAnnotations(true);\r
public void loadAnnotations()\r
{\r
CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);\r
- cap.setText("Paste your features / annotations file here.");\r
+ cap.setText("Paste your features / annotations / T-coffee score file here.");\r
cap.setAnnotationImport();\r
Frame frame = new Frame();\r
frame.add(cap);\r
\r
}\r
\r
- public void loadScores() {\r
- //TODO\r
- \r
- }\r
-\r
public String outputAnnotations(boolean displayTextbox)\r
{\r
String annotation = new AnnotationFile().printAnnotations(\r
overview.getPreferredSize().height + 50);\r
\r
frame.pack();\r
+ final AlignmentPanel ap=alignPanel;\r
frame.addWindowListener(new WindowAdapter()\r
{\r
public void windowClosing(WindowEvent e)\r
{\r
- alignPanel.setOverviewPanel(null);\r
+ if (ap!=null) {\r
+ ap.setOverviewPanel(null);\r
+ }\r
};\r
});\r
\r
\r
MenuItem loadAnnotations = new MenuItem("Load Features/Annotations ...");\r
\r
- MenuItem loadScores = new MenuItem("Load Associated T-Coffee scores ...");\r
-\r
MenuItem outputFeatures = new MenuItem("Export Features ...");\r
\r
MenuItem outputAnnotations = new MenuItem("Export Annotations ...");\r
\r
loadTree.addActionListener(this);\r
loadAnnotations.addActionListener(this);\r
- loadScores.addActionListener(this);\r
outputFeatures.addActionListener(this);\r
outputAnnotations.addActionListener(this);\r
selectAllSequenceMenuItem.addActionListener(this);\r
fileMenu.add(inputText);\r
fileMenu.add(loadTree);\r
fileMenu.add(loadAnnotations);\r
- fileMenu.add(loadScores);\r
\r
fileMenu.addSeparator();\r
fileMenu.add(outputTextboxMenu);\r
import jalview.datamodel.*;
import jalview.io.*;
+import jalview.schemes.TCoffeeColourScheme;
public class CutAndPasteTransfer extends Panel implements ActionListener,
MouseListener
}
else if (annotationImport)
{
- if (new AnnotationFile().readAnnotationFile(
- alignFrame.viewport.getAlignment(), textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE))
+ TCoffeeScoreFile tcf = null;
+ try
{
- alignFrame.alignPanel.fontChanged();
- alignFrame.alignPanel.setScrollValues(0, 0);
-
+ tcf = new TCoffeeScoreFile(textarea.getText(),
+ jalview.io.AppletFormatAdapter.PASTE);
+ if (tcf.isValid())
+ {
+ if (tcf.annotateAlignment(alignFrame.viewport.getAlignment(),
+ true))
+ {
+ alignFrame.tcoffeeColour.setEnabled(true);
+ alignFrame.alignPanel.fontChanged();
+ alignFrame.changeColour(new TCoffeeColourScheme(
+ alignFrame.viewport.getAlignment()));
+ alignFrame.statusBar
+ .setText("Successfully pasted T-Coffee scores to alignment.");
+ }
+ else
+ {
+ // file valid but didn't get added to alignment for some reason
+ alignFrame.statusBar.setText("Failed to add T-Coffee scores: "+(tcf.getWarningMessage()!=null ? tcf.getWarningMessage():""));
+ }
+ }
+ else
+ {
+ tcf = null;
+ }
+ } catch (Exception x)
+ {
+ tcf = null;
}
- else
+ if (tcf == null)
{
- alignFrame.parseFeaturesFile(textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE);
+ if (new AnnotationFile().readAnnotationFile(
+ alignFrame.viewport.getAlignment(), textarea.getText(),
+ jalview.io.AppletFormatAdapter.PASTE))
+ {
+ alignFrame.alignPanel.fontChanged();
+ alignFrame.alignPanel.setScrollValues(0, 0);
+ alignFrame.statusBar
+ .setText("Successfully pasted annotation to alignment.");
+
+ }
+ else
+ {
+ if (!alignFrame.parseFeaturesFile(textarea.getText(),
+ jalview.io.AppletFormatAdapter.PASTE))
+ {
+ alignFrame.statusBar.setText("Couldn't parse pasted text as a valid annotation, feature, GFF, or T-Coffee score file.");
+ }
+ }
}
}
else if (alignFrame != null)