+ // both nucleotide or both protein
+ return false;
+ }
+ AlignmentI protein = thisAlignment.isNucleotide() ? al : thisAlignment;
+ AlignmentI dna = thisAlignment.isNucleotide() ? thisAlignment : al;
+ boolean mapped = AlignmentUtils.mapProteinAlignmentToCdna(protein, dna);
+ if (!mapped)
+ {
+ return false;
+ }
+
+ /*
+ * A mapping is possible; ask user if they want a split frame.
+ */
+ String title = MessageManager.getString("label.open_split_window");
+ final JVDialog dialog = new JVDialog((Frame) this.getParent(), title,
+ true, 100, 400);
+ dialog.ok.setLabel(MessageManager.getString("action.yes"));
+ dialog.cancel.setLabel(MessageManager.getString("action.no"));
+ Panel question = new Panel(new BorderLayout());
+ final String text = MessageManager
+ .getString("label.open_split_window?");
+ question.add(new Label(text, Label.CENTER), BorderLayout.CENTER);
+ dialog.setMainPanel(question);
+ dialog.setVisible(true);
+ dialog.toFront();
+
+ if (!dialog.accept)
+ {
+ return false;
+ }
+
+ /*
+ * 'align' the added alignment to match the current one
+ */
+ al.alignAs(thisAlignment);
+
+ /*
+ * Open SplitFrame with DNA above and protein below, including the alignment
+ * from textbox and a copy of the original.
+ */
+ final JalviewLite applet = this.alignFrame.viewport.applet;
+ AlignFrame copyFrame = new AlignFrame(
+ this.alignFrame.viewport.getAlignment(), applet,
+ alignFrame.getTitle(), false, false);
+ AlignFrame newFrame = new AlignFrame(al, alignFrame.viewport.applet,
+ "Cut & Paste input - " + format, false, false);
+ AlignFrame dnaFrame = al.isNucleotide() ? newFrame : copyFrame;
+ AlignFrame proteinFrame = al.isNucleotide() ? copyFrame : newFrame;
+ SplitFrame sf = new SplitFrame(dnaFrame, proteinFrame);
+ sf.addToDisplay(false, applet);
+ return true;
+ }
+
+ /**
+ * Parse the text as a TCoffee score file, if successful add scores as
+ * alignment annotations.
+ */
+ protected void loadAnnotations()
+ {
+ TCoffeeScoreFile tcf = null;
+ try
+ {
+ tcf = new TCoffeeScoreFile(textarea.getText(),
+ jalview.io.DataSourceType.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(MessageManager.getString(
+ "label.successfully_pasted_tcoffee_scores_to_alignment"));
+ }
+ else
+ {
+ // file valid but didn't get added to alignment for some reason
+ alignFrame.statusBar.setText(MessageManager.formatMessage(
+ "label.failed_add_tcoffee_scores", new Object[]
+ { (tcf.getWarningMessage() != null
+ ? tcf.getWarningMessage()
+ : "") }));
+ }
+ }
+ else
+ {
+ tcf = null;
+ }
+ } catch (Exception x)
+ {
+ tcf = null;
+ }
+ if (tcf == null)
+ {
+ if (new AnnotationFile().annotateAlignmentView(alignFrame.viewport,
+ textarea.getText(), jalview.io.DataSourceType.PASTE))
+ {
+ alignFrame.alignPanel.fontChanged();
+ alignFrame.alignPanel.setScrollValues(0, 0);
+ alignFrame.statusBar.setText(MessageManager.getString(
+ "label.successfully_pasted_annotation_to_alignment"));
+
+ }
+ else
+ {
+ if (!alignFrame.parseFeaturesFile(textarea.getText(),
+ jalview.io.DataSourceType.PASTE))
+ {
+ alignFrame.statusBar.setText(MessageManager.getString(
+ "label.couldnt_parse_pasted_text_as_valid_annotation_feature_GFF_tcoffee_file"));
+ }
+ }
+ }
+ }
+
+ /**
+ * Open a Jmol viewer (if available), failing that the built-in PDB viewer,
+ * passing the input text as the PDB file data.
+ *
+ * @param text
+ */
+ protected void openPdbViewer(String text)
+ {
+ PDBEntry pdb = new PDBEntry();
+ pdb.setFile(text);
+
+ if (alignFrame.alignPanel.av.applet.jmolAvailable)
+ {
+ new jalview.appletgui.AppletJmol(pdb, new SequenceI[] { seq }, null,
+ alignFrame.alignPanel, DataSourceType.PASTE);