label.normalise_logo = Normalise Logo
label.no_colour_selection_in_scheme = Please, make a colour selection before to apply colour scheme
label.no_colour_selection_warn = Error saving colour scheme
-label.open_linked_alignment? = Would you like to open as a separate alignment, with cDNA and protein linked?
-label.open_linked_alignment = Open linked alignment
+label.open_split_window? = Would you like to open as a split window, with cDNA and protein linked?
+label.open_split_window = Open split window
label.no_mappings = No mappings found
label.mapping_failed = No sequence mapping could be made between the alignments.<br>A mapping requires sequence names to match, and equivalent sequence lengths.
action.no = No
+action.yes = Yes
label.for = for
label.select_by_annotation = Select By Annotation
action.select_by_annotation = Select by Annotation...
*/
package jalview.appletgui;
+import jalview.analysis.AlignmentUtils;
+import jalview.analysis.AlignmentUtils.MappingResult;
+import jalview.bin.JalviewLite;
import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.io.AnnotationFile;
import java.awt.Dialog;
import java.awt.Font;
import java.awt.Frame;
+import java.awt.Label;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
if (al != null)
{
- al.setDataset(null);
+ al.setDataset(null); // set dataset on alignment/sequences
+ if (openSplitFrame(al, format))
+ {
+ return;
+ }
if (newWindow)
{
AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet,
}
/**
+ * Check whether the new alignment could be mapped to the current one as
+ * cDNA/protein, if so offer the option to open as split frame view. Returns
+ * true if a split frame view is opened, false if not.
+ *
+ * @param al
+ * @return
+ */
+ protected boolean openSplitFrame(Alignment al, String format)
+ {
+ final AlignmentI thisAlignment = this.alignFrame.getAlignViewport().getAlignment();
+ if (thisAlignment.isNucleotide() == al.isNucleotide())
+ {
+ // both nucleotide or both protein
+ return false;
+ }
+ AlignmentI protein = thisAlignment.isNucleotide() ? al : thisAlignment;
+ AlignmentI dna = thisAlignment.isNucleotide() ? thisAlignment : al;
+ MappingResult mapped = AlignmentUtils.mapProteinToCdna(protein, dna);
+ if (mapped == MappingResult.NotMapped)
+ {
+ 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;
+ }
+
+ /*
+ * 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.
*/
public void init()
{
setMenuBar(null);
- outermost = new Panel();
- outermost.setLayout(new GridLayout(2, 1));
+ outermost = new Panel(new GridLayout(2, 1));
Panel topPanel = new Panel();
Panel bottomPanel = new Panel();
final AlignViewport bottomViewport = bottomFrame.viewport;
final AlignmentI topAlignment = topViewport.getAlignment();
final AlignmentI bottomAlignment = bottomViewport.getAlignment();
- // topAlignment.setDataset(null);
- // bottomAlignment.setDataset(null);
AlignViewport cdna = topAlignment.isNucleotide() ? topViewport
: (bottomAlignment.isNucleotide() ? bottomViewport : null);
AlignViewport protein = !topAlignment.isNucleotide() ? topViewport
: (!bottomAlignment.isNucleotide() ? bottomViewport : null);
+
MappingResult mapped = AlignmentUtils.mapProteinToCdna(
protein.getAlignment(), cdna.getAlignment());
if (mapped != MappingResult.NotMapped)
MessageManager.getString("label.split_window"),
MessageManager.getString("label.new_window"), };
final String question = JvSwingUtils.wrapTooltip(true,
- MessageManager.getString("label.open_linked_alignment?"));
+ MessageManager.getString("label.open_split_window?"));
int response = JOptionPane.showOptionDialog(Desktop.desktop, question,
- MessageManager.getString("label.open_linked_alignment"),
+ MessageManager.getString("label.open_split_window"),
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
options, options[0]);