/*
- * 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.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
*
* This file is part of Jalview.
*
JMenuItem sequenceName = new JMenuItem();
- Sequence sequence;
+ SequenceI sequence;
JMenuItem unGroupMenuItem = new JMenuItem();
* @param links
* @param groupLinks
*/
- public PopupMenu(final AlignmentPanel ap, final Sequence seq,
- final Vector links, final 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
e.printStackTrace();
}
+ JMenuItem menuItem;
if (seq != null)
{
sequenceMenu.setText(sequence.getName());
- JMenuItem menuItem;
if (seq.getDatasetSequence().getPDBId() != null
&& seq.getDatasetSequence().getPDBId().size() > 0)
{
{
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);
}
}
else
{
- if (ap.av.alignment.isNucleotide() == false)
+ if (ap.av.getAlignment().isNucleotide() == false)
{
- structureMenu.remove(viewStructureMenu);
+ structureMenu.remove(viewStructureMenu);
}
// structureMenu.remove(colStructureMenu);
}
- if (ap.av.alignment.isNucleotide() == true)
+ if (ap.av.getAlignment().isNucleotide() == true)
{
- AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+ 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("RNA structure - consensus");
+ menuItem.setText("2D RNA "+structureLine);
menuItem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
- new AppVarna(seq.getSequenceAsString(), rnastruc, seq
+ new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
.getName(), ap);
}
});
// TODO: make rnastrucF a bit more nice
menuItem = new JMenuItem();
- menuItem.setText("RNA structure - "+seq.getName());
+ 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.getSequenceAsString(), rnastruc, seq
+ new AppVarna(seq.getName()+" structure",seq,seq.getSequenceAsString(), rnastruc, seq
.getName(), ap);
}
});
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)
});
add(menuItem);
}
-
+ }
+ }
+ // for the case when no sequences are even visible
+ if (ap.av.hasHiddenRows()) {
+ {
menuItem = new JMenuItem("Reveal All");
menuItem.addActionListener(new ActionListener()
{
SequenceGroup sg = ap.av.getSelectionGroup();
- if (sg != null)
+ if (sg != null&& sg.getSize()>0)
{
- groupName.setText("Name: " + sg.getName());
+ groupName.setText("Name: "+sg.getName());
groupName.setText("Edit name and description of current group.");
if (sg.cs instanceof ZappoColourScheme)
buildGroupURLMenu(sg, groupLinks);
}
// Add a 'show all structures' for the current selection
- Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
- for (SequenceI sq : ap.av.getSequenceSelection())
+ Hashtable<String, PDBEntry> pdbe=new Hashtable<String,PDBEntry>();
+ SequenceI sqass=null;
+ for (SequenceI sq: ap.av.getSequenceSelection())
{
- Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
- .getPDBId();
- if (pes != null)
- {
- for (PDBEntry pe : pes)
+ Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence().getPDBId();
+ if (pes!=null) {
+ for (PDBEntry pe: pes)
{
- pdbe.put(pe.getId(), pe);
+ pdbe.put(pe.getId(), pe);
+ if (sqass==null)
+ {
+ sqass = sq;
+ }
}
}
}
- 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.");
+ if (pdbe.size()==1)
+ {
+ structureMenu.add(gpdbview=new JMenuItem("View structure for "+sqass.getDisplayId(false)));
+ } else {
+ structureMenu.add(gpdbview=new JMenuItem("View all "+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)
{
editMenu.setVisible(false);
}
- if (!ap.av.alignment.getGroups().contains(sg))
+ if (!ap.av.getAlignment().getGroups().contains(sg))
{
unGroupMenuItem.setVisible(false);
}
continue;
}
final String label = urlLink.getLabel();
- if (urlLink.isDynamic())
+ if (seq!=null && urlLink.isDynamic())
{
// 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();
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();
}
// 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();
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)
{
}
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)
colourMenu.add(turnColour);
colourMenu.add(buriedColour);
colourMenu.add(nucleotideMenuItem);
- colourMenu.add(purinePyrimidineColour);
+ if (ap.getAlignment().isNucleotide()) {
+ colourMenu.add(purinePyrimidineColour);
+ }
// colourMenu.add(covariationColour);
colourMenu.add(userDefinedColour);
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();
}
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());
{
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();
}
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();
}
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);
return;
}
- AnnotationColourGradient acg = new AnnotationColourGradient(sequence
- .getAnnotation()[0], null,
+ AnnotationColourGradient acg = new AnnotationColourGradient(
+ sequence.getAnnotation()[0], null,
AnnotationColourGradient.NO_THRESHOLD);
acg.predefinedColours = true;
{
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)
{
// 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;
*/
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);
void unGroupMenuItem_actionPerformed()
{
SequenceGroup sg = ap.av.getSelectionGroup();
- ap.av.alignment.deleteGroup(sg);
+ ap.av.getAlignment().deleteGroup(sg);
ap.av.setSelectionGroup(null);
refresh();
}
caseChange = ChangeCaseCommand.TO_LOWER;
}
- ChangeCaseCommand caseCommand = new ChangeCaseCommand(description, sg
- .getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
+ ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
+ sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), startEnd,
caseChange);
ap.alignFrame.addHistoryItem(caseCommand);
{
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;
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();
+ AlignmentAnnotation[] nala = ap.av.getAlignment().getAlignmentAnnotation();
if (nala != null)
{
for (int i = 0; i < nala.length; i++)
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);
{
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);
}
}
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()
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);
- 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();
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);