X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPopupMenu.java;h=6bc8daf13d004da5f60e1715df51e7ba47b8ea07;hb=a137c9f323a2f2ed7994419e904c8d40b2b25d07;hp=9a0def1eabe77ae26d42083e6007c3894ff47ead;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git
diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java
old mode 100755
new mode 100644
index 9a0def1..6bc8daf
--- a/src/jalview/gui/PopupMenu.java
+++ b/src/jalview/gui/PopupMenu.java
@@ -1,13 +1,13 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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
* 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
@@ -21,9 +21,17 @@ import java.util.*;
import java.awt.*;
import java.awt.event.*;
+
import javax.swing.*;
+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;
+import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
-import MCview.*;
import jalview.analysis.*;
import jalview.commands.*;
import jalview.datamodel.*;
@@ -37,7 +45,7 @@ import jalview.util.UrlLink;
* DOCUMENT ME!
*
* @author $author$
- * @version $Revision$
+ * @version $Revision: 1.118 $
*/
public class PopupMenu extends JPopupMenu
{
@@ -69,6 +77,12 @@ public class PopupMenu extends JPopupMenu
protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
+ protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
+ protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
+
+ // protected JRadioButtonMenuItem covariationColour = new
+ // JRadioButtonMenuItem();
+
JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
@@ -79,7 +93,11 @@ public class PopupMenu extends JPopupMenu
JMenuItem sequenceName = new JMenuItem();
- Sequence sequence;
+ JMenuItem sequenceDetails = new JMenuItem();
+
+ JMenuItem sequenceSelDetails = new JMenuItem();
+
+ SequenceI sequence;
JMenuItem unGroupMenuItem = new JMenuItem();
@@ -112,7 +130,11 @@ public class PopupMenu extends JPopupMenu
JMenu pdbMenu = new JMenu();
JMenuItem pdbFromFile = new JMenuItem();
-
+ // JBPNote: Commented these out - Should add these services via the web services menu system.
+ // JMenuItem ContraFold = new JMenuItem();
+
+ // JMenuItem RNAFold = new JMenuItem();
+
JMenuItem enterPDB = new JMenuItem();
JMenuItem discoverPDB = new JMenuItem();
@@ -156,8 +178,8 @@ public class PopupMenu extends JPopupMenu
* @param links
* @param groupLinks
*/
- public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links,
- Vector groupLinks)
+ public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
+ Vector links, Vector groupLinks)
{
// /////////////////////////////////////////////////////////
// If this is activated from the sequence panel, the user may want to
@@ -182,6 +204,9 @@ public class PopupMenu extends JPopupMenu
colours.add(userDefinedColour);
colours.add(PIDColour);
colours.add(BLOSUM62Colour);
+ colours.add(purinePyrimidineColour);
+ colours.add(RNAInteractionColour);
+ // colours.add(covariationColour);
for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
{
@@ -207,11 +232,11 @@ public class PopupMenu extends JPopupMenu
e.printStackTrace();
}
+ JMenuItem menuItem;
if (seq != null)
{
sequenceMenu.setText(sequence.getName());
- JMenuItem menuItem;
if (seq.getDatasetSequence().getPDBId() != null
&& seq.getDatasetSequence().getPDBId().size() > 0)
{
@@ -228,33 +253,13 @@ public class PopupMenu extends JPopupMenu
{
public void actionPerformed(ActionEvent e)
{
- Vector seqs = new Vector();
- for (int i = 0; i < ap.av.alignment.getHeight(); i++)
- {
- Vector pdbs = ap.av.alignment.getSequenceAt(i)
- .getDatasetSequence().getPDBId();
- if (pdbs == null)
- continue;
-
- for (int p = 0; p < pdbs.size(); p++)
- {
- PDBEntry p1 = (PDBEntry) pdbs.elementAt(p);
- if (p1.getId().equals(pdb.getId()))
- {
- if (!seqs.contains(ap.av.alignment.getSequenceAt(i)))
- seqs.addElement(ap.av.alignment.getSequenceAt(i));
-
- continue;
- }
- }
- }
-
- SequenceI[] seqs2 = new SequenceI[seqs.size()];
- seqs.toArray(seqs2);
-
- new AppJmol(pdb, seqs2, null, ap);
+ // TODO re JAL-860: optionally open dialog or provide a menu entry
+ // allowing user to open just one structure per sequence
+ new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
+ { pdb })[0], null, ap);
// new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
}
+
});
viewStructureMenu.add(menuItem);
@@ -269,10 +274,81 @@ public class PopupMenu extends JPopupMenu
}
else
{
- structureMenu.remove(viewStructureMenu);
+ if (ap.av.getAlignment().isNucleotide() == false)
+ {
+ structureMenu.remove(viewStructureMenu);
+ }
// structureMenu.remove(colStructureMenu);
}
+ if (ap.av.getAlignment().isNucleotide() == true)
+ {
+ AlignmentAnnotation[] aa = ap.av.getAlignment()
+ .getAlignmentAnnotation();
+ for (int i = 0; i < aa.length; i++)
+ {
+ if (aa[i].getRNAStruc() != null)
+ {
+ final String rnastruc = aa[i].getRNAStruc();
+ final String structureLine = aa[i].label;
+ menuItem = new JMenuItem();
+ menuItem.setText("2D RNA " + structureLine);
+ menuItem.addActionListener(new java.awt.event.ActionListener()
+
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ //System.out.println("1:"+structureLine);
+ System.out.println("1:sname"+seq.getName());
+ System.out.println("2:seq"+seq);
+
+ //System.out.println("3:"+seq.getSequenceAsString());
+ System.out.println("3:strucseq"+rnastruc);
+ //System.out.println("4:struc"+seq.getRNA());
+ System.out.println("5:name"+seq.getName());
+ System.out.println("6:ap"+ap);
+ new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
+ .getName(), ap);
+ //new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(), seq.getName(), ap);
+ System.out.println("end");
+ }
+ });
+ viewStructureMenu.add(menuItem);
+ }
+ }
+
+ // SequenceFeatures[] test = seq.getSequenceFeatures();
+
+ if (seq.getAnnotation() != null)
+ {
+ AlignmentAnnotation seqAnno[] = seq.getAnnotation();
+ for (int i = 0; i < seqAnno.length; i++)
+ {
+ if (seqAnno[i].getRNAStruc() != null)
+ {
+ final String rnastruc = seqAnno[i].getRNAStruc();
+
+ // TODO: make rnastrucF a bit more nice
+ menuItem = new JMenuItem();
+ menuItem.setText("2D RNA - " + seq.getName());
+ menuItem.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ // TODO: VARNA does'nt print gaps in the sequence
+
+ new AppVarna(seq.getName() + " structure", seq, seq
+ .getSequenceAsString(), rnastruc, seq.getName(),
+ ap);
+ }
+ });
+ viewStructureMenu.add(menuItem);
+ }
+ }
+ }
+
+ }
+
menuItem = new JMenuItem("Hide Sequences");
menuItem.addActionListener(new java.awt.event.ActionListener()
{
@@ -297,9 +373,9 @@ public class PopupMenu extends JPopupMenu
sequenceMenu.add(menuItem);
}
- if (ap.av.hasHiddenRows)
+ if (ap.av.hasHiddenRows())
{
- final int index = ap.av.alignment.findIndex(seq);
+ final int index = ap.av.getAlignment().findIndex(seq);
if (ap.av.adjustForHiddenSeqs(index)
- ap.av.adjustForHiddenSeqs(index - 1) > 1)
@@ -318,7 +394,12 @@ public class PopupMenu extends JPopupMenu
});
add(menuItem);
}
-
+ }
+ }
+ // for the case when no sequences are even visible
+ if (ap.av.hasHiddenRows())
+ {
+ {
menuItem = new JMenuItem("Reveal All");
menuItem.addActionListener(new ActionListener()
{
@@ -339,9 +420,10 @@ public class PopupMenu extends JPopupMenu
SequenceGroup sg = ap.av.getSelectionGroup();
- if (sg != null)
+ if (sg != null && sg.getSize() > 0)
{
- groupName.setText(sg.getName());
+ groupName.setText("Name: " + sg.getName());
+ groupName.setText("Edit name and description of current group.");
if (sg.cs instanceof ZappoColourScheme)
{
@@ -387,6 +469,16 @@ public class PopupMenu extends JPopupMenu
{
clustalColour.setSelected(true);
}
+ else if (sg.cs instanceof PurinePyrimidineColourScheme)
+ {
+ purinePyrimidineColour.setSelected(true);
+ }
+
+
+ /*
+ * else if (sg.cs instanceof CovariationColourScheme) {
+ * covariationColour.setSelected(true); }
+ */
else
{
noColourmenuItem.setSelected(true);
@@ -405,6 +497,51 @@ public class PopupMenu extends JPopupMenu
{
buildGroupURLMenu(sg, groupLinks);
}
+ // Add a 'show all structures' for the current selection
+ HashtableAnnotation for " + seq.getDisplayId(true)
+ + "
"); + new SequenceAnnotationReport(null) + .createSequenceAnnotationReport( + contents, + seq, + true, + true, + false, + (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax + : null); + contents.append("
"); + } + cap.setText("" + contents.toString() + ""); + + Desktop.instance.addInternalFrame(cap, "Sequence Details for " + + (sequences.length == 1 ? sequences[0].getDisplayId(true) + : "Selection"), 500, 400); + + } + protected void showNonconserved_actionPerformed() { getGroup().setShowNonconserved(displayNonconserved.isSelected()); @@ -1175,9 +1425,7 @@ public class PopupMenu extends JPopupMenu protected void clustalColour_actionPerformed() { SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg - .getSequences(ap.av.hiddenRepSequences), ap.av.alignment - .getWidth()); + sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences()); refresh(); } @@ -1277,6 +1525,17 @@ public class PopupMenu extends JPopupMenu refresh(); } + protected void purinePyrimidineColour_actionPerformed() + { + getGroup().cs = new PurinePyrimidineColourScheme(); + refresh(); + } + + + /* + * protected void covariationColour_actionPerformed() { getGroup().cs = new + * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); } + */ /** * DOCUMENT ME! * @@ -1293,9 +1552,9 @@ public class PopupMenu extends JPopupMenu if (abovePIDColour.isSelected()) { - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg - .getEndRes() + 1)); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.getHiddenRepSequences()), + sg.getStartRes(), sg.getEndRes() + 1)); int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup() .getName()); @@ -1347,9 +1606,9 @@ public class PopupMenu extends JPopupMenu { SequenceGroup sg = getGroup(); sg.cs = new PIDColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg - .getEndRes() + 1)); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.getHiddenRepSequences()), + sg.getStartRes(), sg.getEndRes() + 1)); refresh(); } @@ -1365,9 +1624,9 @@ public class PopupMenu extends JPopupMenu sg.cs = new Blosum62ColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg - .getSequences(ap.av.hiddenRepSequences), sg.getStartRes(), sg - .getEndRes() + 1)); + sg.cs.setConsensus(AAFrequency.calculate( + sg.getSequences(ap.av.getHiddenRepSequences()), + sg.getStartRes(), sg.getEndRes() + 1)); refresh(); } @@ -1401,12 +1660,12 @@ public class PopupMenu extends JPopupMenu if (conservationMenuItem.isSelected()) { Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, sg - .getSequences(ap.av.hiddenRepSequences), sg - .getStartRes(), sg.getEndRes() + 1); + ResidueProperties.propHash, 3, sg.getSequences(ap.av + .getHiddenRepSequences()), sg.getStartRes(), + sg.getEndRes() + 1); c.calculate(); - c.verdict(false, ap.av.ConsPercGaps); + c.verdict(false, ap.av.getConsPercGaps()); sg.cs.setConservation(c); @@ -1430,8 +1689,8 @@ public class PopupMenu extends JPopupMenu return; } - AnnotationColourGradient acg = new AnnotationColourGradient(sequence - .getAnnotation()[0], null, + AnnotationColourGradient acg = new AnnotationColourGradient( + sequence.getAnnotation()[0], null, AnnotationColourGradient.NO_THRESHOLD); acg.predefinedColours = true; @@ -1450,9 +1709,10 @@ public class PopupMenu extends JPopupMenu { SequenceGroup sg = getGroup(); - EditNameDialog dialog = new EditNameDialog(sg.getName(), sg - .getDescription(), " Group Name ", "Group Description ", - "Edit Group Name/Description", ap.alignFrame); + EditNameDialog dialog = new EditNameDialog(sg.getName(), + sg.getDescription(), " Group Name ", + "Group Description ", "Edit Group Name/Description", + ap.alignFrame); if (!dialog.accept) { @@ -1475,7 +1735,7 @@ public class PopupMenu extends JPopupMenu // this method won't add a new group if it already exists if (sg != null) { - ap.av.alignment.addGroup(sg); + ap.av.getAlignment().addGroup(sg); } return sg; @@ -1489,9 +1749,10 @@ public class PopupMenu extends JPopupMenu */ void sequenceName_actionPerformed() { - EditNameDialog dialog = new EditNameDialog(sequence.getName(), sequence - .getDescription(), " Sequence Name ", - "Sequence Description ", "Edit Sequence Name/Description", ap.alignFrame); + EditNameDialog dialog = new EditNameDialog(sequence.getName(), + sequence.getDescription(), " Sequence Name ", + "Sequence Description ", "Edit Sequence Name/Description", + ap.alignFrame); if (!dialog.accept) { @@ -1528,7 +1789,7 @@ public class PopupMenu extends JPopupMenu void unGroupMenuItem_actionPerformed() { SequenceGroup sg = ap.av.getSelectionGroup(); - ap.av.alignment.deleteGroup(sg); + ap.av.getAlignment().deleteGroup(sg); ap.av.setSelectionGroup(null); refresh(); } @@ -1681,9 +1942,9 @@ public class PopupMenu extends JPopupMenu caseChange = ChangeCaseCommand.TO_LOWER; } - ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, sg - .getSequencesAsArray(ap.av.hiddenRepSequences), startEnd, - caseChange); + ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, + sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), + startEnd, caseChange); ap.alignFrame.addHistoryItem(caseCommand); @@ -1697,8 +1958,8 @@ public class PopupMenu extends JPopupMenu { CutAndPasteTransfer cap = new CutAndPasteTransfer(); cap.setForInput(null); - Desktop.addInternalFrame(cap, "Alignment output - " - + e.getActionCommand(), 600, 500); + Desktop.addInternalFrame(cap, + "Alignment output - " + e.getActionCommand(), 600, 500); String[] omitHidden = null; @@ -1709,8 +1970,10 @@ public class PopupMenu extends JPopupMenu ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection()); omitHidden = ap.av.getViewAsString(true); Alignment oal = new Alignment(ap.av.getSequenceSelection()); - AlignmentAnnotation[] nala = ap.av.alignment.getAlignmentAnnotation(); - if (nala!=null) { + AlignmentAnnotation[] nala = ap.av.getAlignment() + .getAlignmentAnnotation(); + if (nala != null) + { for (int i = 0; i < nala.length; i++) { AlignmentAnnotation na = nala[i]; @@ -1722,56 +1985,39 @@ public class PopupMenu extends JPopupMenu oal = null; } - public void pdbFromFile_actionPerformed() + public void pdbFromFile_actionPerformed() throws Exception { jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( jalview.bin.Cache.getProperty("LAST_DIRECTORY")); chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Select a PDB file"); - chooser.setToolTipText("Load a PDB file"); + chooser.setDialogTitle("Select a PDB file for " + + sequence.getDisplayId(false)); + chooser.setToolTipText("Load a PDB file and associate it with sequence '" + + sequence.getDisplayId(false) + "'"); int value = chooser.showOpenDialog(null); if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION) { - PDBEntry entry = new PDBEntry(); String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - try - { - MCview.PDBfile pdbfile = new MCview.PDBfile(choice, - jalview.io.AppletFormatAdapter.FILE); - - if (pdbfile.id == null) - { - String reply = JOptionPane - .showInternalInputDialog( - Desktop.desktop, - "Couldn't find a PDB id in the file supplied." - + "Please enter an Id to identify this structure.", - "No PDB Id in File", JOptionPane.QUESTION_MESSAGE); - if (reply == null) - { - return; - } - - entry.setId(reply); - } - else - { - entry.setId(pdbfile.id); - } - } catch (java.io.IOException ex) - { - ex.printStackTrace(); - } - - entry.setFile(choice); - sequence.getDatasetSequence().addPDBId(entry); + new AssociatePdbFileWithSeq().associatePdbWithSeq(choice, + jalview.io.AppletFormatAdapter.FILE, sequence, true); } } - + // JBNote: commented out - these won't be instantiated here...! +// public void RNAFold_actionPerformed() throws Exception +// { +// Predict2D P2D = new Predict2D(); +// P2D.getStructure2DFromRNAFold("toto"); +// } +// +// public void ContraFold_actionPerformed() throws Exception +// { +// Predict2D P2D = new Predict2D(); +// P2D.getStructure2DFromContraFold("toto"); +// } public void enterPDB_actionPerformed() { String id = JOptionPane.showInternalInputDialog(Desktop.desktop, @@ -1788,9 +2034,9 @@ public class PopupMenu extends JPopupMenu public void discoverPDB_actionPerformed() { - final SequenceI[] sequences = ((ap.av.selectionGroup == null) ? new Sequence[] + final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[] { sequence } - : ap.av.selectionGroup.getSequencesInOrder(ap.av.alignment)); + : ap.av.getSequenceSelection()); Thread discpdb = new Thread(new Runnable() { public void run() @@ -1853,17 +2099,16 @@ public class PopupMenu extends JPopupMenu public void colourByStructure(String pdbid) { - Annotation[] anots = jalview.structure.StructureSelectionManager - .getStructureSelectionManager().colourSequenceFromStructure( - sequence, pdbid); + Annotation[] anots = ap.av.getStructureSelectionManager() + .colourSequenceFromStructure(sequence, pdbid); AlignmentAnnotation an = new AlignmentAnnotation("Structure", "Coloured by " + pdbid, anots); - ap.av.alignment.addAnnotation(an); + ap.av.getAlignment().addAnnotation(an); an.createSequenceMapping(sequence, 0, true); // an.adjustForAlignment(); - ap.av.alignment.setAnnotationIndex(an, 0); + ap.av.getAlignment().setAnnotationIndex(an, 0); ap.adjustAnnotationHeight(); @@ -1880,17 +2125,18 @@ public class PopupMenu extends JPopupMenu if (sequence == null) sequence = (Sequence) sg.getSequenceAt(0); - EditNameDialog dialog = new EditNameDialog(sequence - .getSequenceAsString(sg.getStartRes(), sg.getEndRes() + 1), - null, "Edit Sequence ", null, "Edit Sequence", ap.alignFrame); + EditNameDialog dialog = new EditNameDialog( + sequence.getSequenceAsString(sg.getStartRes(), + sg.getEndRes() + 1), null, "Edit Sequence ", null, + "Edit Sequence", ap.alignFrame); if (dialog.accept) { EditCommand editCommand = new EditCommand("Edit Sequences", EditCommand.REPLACE, dialog.getName().replace(' ', - ap.av.getGapCharacter()), sg - .getSequencesAsArray(ap.av.hiddenRepSequences), sg - .getStartRes(), sg.getEndRes() + 1, ap.av.alignment); + ap.av.getGapCharacter()), + sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), + sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment()); ap.alignFrame.addHistoryItem(editCommand);