From: janengelhardt Date: Mon, 15 Aug 2011 23:13:38 +0000 (+0200) Subject: JAL-878; Structures associated to a sequence are available via X-Git-Tag: Jalview_2_9~576^2~6 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7b7397a32734f990b14ea0a3bf49d3a9e1d928c3;hp=4b60f281b768044e3d66289c5ff6d941e6998f0b;p=jalview.git JAL-878; Structures associated to a sequence are available via Popupmenu; Change-Id: I20050a77bf494782893d6383f3d2e901cae7d3f1 --- diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 9de51ea..f2f41a3 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -69,10 +69,11 @@ public class PopupMenu extends JPopupMenu protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); - + protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem(); - - //protected JRadioButtonMenuItem covariationColour = new JRadioButtonMenuItem(); + + // protected JRadioButtonMenuItem covariationColour = new + // JRadioButtonMenuItem(); JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); @@ -161,8 +162,8 @@ public class PopupMenu extends JPopupMenu * @param links * @param groupLinks */ - public PopupMenu(final AlignmentPanel ap, final Sequence seq, final Vector links, - final Vector groupLinks) + public PopupMenu(final AlignmentPanel ap, final Sequence seq, + final Vector links, final Vector groupLinks) { // ///////////////////////////////////////////////////////// // If this is activated from the sequence panel, the user may want to @@ -188,7 +189,7 @@ public class PopupMenu extends JPopupMenu colours.add(PIDColour); colours.add(BLOSUM62Colour); colours.add(purinePyrimidineColour); - //colours.add(covariationColour); + // colours.add(covariationColour); for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++) { @@ -235,8 +236,10 @@ public class PopupMenu extends JPopupMenu { public void actionPerformed(ActionEvent e) { - // 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); + // 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); } @@ -253,41 +256,67 @@ public class PopupMenu extends JPopupMenu } } else - { - if(ap.av.alignment.isNucleotide()==false){ - structureMenu.remove(viewStructureMenu); - } + { + if (ap.av.alignment.isNucleotide() == false) + { + structureMenu.remove(viewStructureMenu); + } // structureMenu.remove(colStructureMenu); } - - if(ap.av.alignment.isNucleotide()==true){ - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - String rnastruc=new String(); - for(int i=0; i pdbe=new Hashtable(); - for (SequenceI sq: ap.av.getSequenceSelection()) + Hashtable pdbe = new Hashtable(); + for (SequenceI sq : ap.av.getSequenceSelection()) { - Vector pes = (Vector) sq.getDatasetSequence().getPDBId(); - if (pes!=null) { - for (PDBEntry pe: pes) + Vector pes = (Vector) sq.getDatasetSequence() + .getPDBId(); + if (pes != null) + { + for (PDBEntry pe : pes) { - pdbe.put(pe.getId(), pe); + pdbe.put(pe.getId(), pe); } } } - if (pdbe.size()>0) + if (pdbe.size() > 0) { - final PDBEntry[] pe = pdbe.values().toArray(new PDBEntry[pdbe.size()]); + final PDBEntry[] pe = pdbe.values().toArray( + new PDBEntry[pdbe.size()]); final JMenuItem gpdbview; - structureMenu.add(gpdbview=new JMenuItem("View "+pdbe.size()+" structures.")); - gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment."); + structureMenu.add(gpdbview = new JMenuItem("View " + pdbe.size() + + " structures.")); + gpdbview + .setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment."); gpdbview.addActionListener(new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { @@ -505,9 +539,9 @@ public class PopupMenu extends JPopupMenu { // collect matching db-refs - DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs( - seq.getDBRef(), new String[] - { urlLink.getTarget() }); + DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq + .getDBRef(), new String[] + { urlLink.getTarget() }); // collect id string too String id = seq.getName(); String descr = seq.getDescription(); @@ -610,7 +644,7 @@ public class PopupMenu extends JPopupMenu JMenu[] linkMenus = new JMenu[] { null, new JMenu("IDS"), new JMenu("Sequences"), new JMenu("IDS and Sequences") }; // three types of url that might be - // created. + // created. SequenceI[] seqs = ap.av.getSelectionAsNewSequence(); String[][] idandseqs = GroupUrlLink.formStrings(seqs); Hashtable commonDbrefs = new Hashtable(); @@ -658,7 +692,7 @@ public class PopupMenu extends JPopupMenu } // now create group links for all distinct ID/sequence sets. boolean addMenu = false; // indicates if there are any group links to give - // to user + // to user for (int i = 0; i < groupLinks.size(); i++) { String link = groupLinks.elementAt(i).toString(); @@ -711,8 +745,8 @@ public class PopupMenu extends JPopupMenu Object[] urlset = null; try { - urlset = urlLink.makeUrlStubs(ids, seqstr, - "FromJalview" + System.currentTimeMillis(), false); + urlset = urlLink.makeUrlStubs(ids, seqstr, "FromJalview" + + System.currentTimeMillis(), false); } catch (UrlStringTooLongException e) { } @@ -795,14 +829,14 @@ public class PopupMenu extends JPopupMenu JMenuItem item = new JMenuItem(label); item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix() + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO: - // put - // in - // info - // about - // what - // is - // being - // sent. + // put + // in + // info + // about + // what + // is + // being + // sent. item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -1041,7 +1075,7 @@ public class PopupMenu extends JPopupMenu colourMenu.add(buriedColour); colourMenu.add(nucleotideMenuItem); colourMenu.add(purinePyrimidineColour); - //colourMenu.add(covariationColour); + // colourMenu.add(covariationColour); colourMenu.add(userDefinedColour); if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null) @@ -1194,22 +1228,20 @@ public class PopupMenu extends JPopupMenu } }); purinePyrimidineColour.setText("Purine/Pyrimidine"); - purinePyrimidineColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - purinePyrimidineColour_actionPerformed(); - } - }); - /* - covariationColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - covariationColour_actionPerformed(); - } - });*/ - + purinePyrimidineColour + .addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + purinePyrimidineColour_actionPerformed(); + } + }); + /* + * covariationColour.addActionListener(new java.awt.event.ActionListener() { + * public void actionPerformed(ActionEvent e) { + * covariationColour_actionPerformed(); } }); + */ + conservationMenuItem.setText("Conservation"); conservationMenuItem .addActionListener(new java.awt.event.ActionListener() @@ -1247,9 +1279,9 @@ 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 + .getSequences(ap.av.hiddenRepSequences), ap.av.alignment + .getWidth()); refresh(); } @@ -1348,19 +1380,17 @@ public class PopupMenu extends JPopupMenu getGroup().cs = new NucleotideColourScheme(); refresh(); } - + protected void purinePyrimidineColour_actionPerformed() { getGroup().cs = new PurinePyrimidineColourScheme(); refresh(); } + /* - protected void covariationColour_actionPerformed() - { - getGroup().cs = new CovariationColourScheme(sequence.getAnnotation()[0]); - refresh(); - } -*/ + * protected void covariationColour_actionPerformed() { getGroup().cs = new + * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); } + */ /** * DOCUMENT ME! * @@ -1377,9 +1407,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.hiddenRepSequences), sg.getStartRes(), sg + .getEndRes() + 1)); int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup() .getName()); @@ -1431,9 +1461,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.hiddenRepSequences), sg.getStartRes(), sg + .getEndRes() + 1)); refresh(); } @@ -1449,9 +1479,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.hiddenRepSequences), sg.getStartRes(), sg + .getEndRes() + 1)); refresh(); } @@ -1485,9 +1515,9 @@ 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.hiddenRepSequences), sg + .getStartRes(), sg.getEndRes() + 1); c.calculate(); c.verdict(false, ap.av.ConsPercGaps); @@ -1514,8 +1544,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; @@ -1534,10 +1564,9 @@ 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) { @@ -1574,8 +1603,8 @@ public class PopupMenu extends JPopupMenu */ void sequenceName_actionPerformed() { - EditNameDialog dialog = new EditNameDialog(sequence.getName(), - sequence.getDescription(), " Sequence Name ", + EditNameDialog dialog = new EditNameDialog(sequence.getName(), sequence + .getDescription(), " Sequence Name ", "Sequence Description ", "Edit Sequence Name/Description", ap.alignFrame); @@ -1767,8 +1796,8 @@ public class PopupMenu extends JPopupMenu caseChange = ChangeCaseCommand.TO_LOWER; } - ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, - sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd, + ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, sg + .getSequencesAsArray(ap.av.hiddenRepSequences), startEnd, caseChange); ap.alignFrame.addHistoryItem(caseCommand); @@ -1783,8 +1812,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; @@ -1814,8 +1843,11 @@ public class PopupMenu extends JPopupMenu 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 for "+sequence.getDisplayId(false)); - chooser.setToolTipText("Load a PDB file and associate it with sequence '"+sequence.getDisplayId(false)+"'"); + 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); @@ -1823,7 +1855,8 @@ public class PopupMenu extends JPopupMenu { String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - new AssociatePdbFileWithSeq().associatePdbWithSeq(choice, jalview.io.AppletFormatAdapter.FILE, sequence, true); + new AssociatePdbFileWithSeq().associatePdbWithSeq(choice, + jalview.io.AppletFormatAdapter.FILE, sequence, true); } } @@ -1909,8 +1942,8 @@ public class PopupMenu extends JPopupMenu public void colourByStructure(String pdbid) { - Annotation[] anots = ap.av.getStructureSelectionManager().colourSequenceFromStructure( - sequence, pdbid); + Annotation[] anots = ap.av.getStructureSelectionManager() + .colourSequenceFromStructure(sequence, pdbid); AlignmentAnnotation an = new AlignmentAnnotation("Structure", "Coloured by " + pdbid, anots); @@ -1935,18 +1968,17 @@ 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.hiddenRepSequences), sg + .getStartRes(), sg.getEndRes() + 1, ap.av.alignment); ap.alignFrame.addHistoryItem(editCommand);