/*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, 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 program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
*
- * This program 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 PURPOSE. See the
- * GNU General Public License for more details.
+ * 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.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * 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
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
*/
package jalview.appletgui;
MenuItem revealAll = new MenuItem();
+ MenuItem revealSeq = new MenuItem();
+ /**
+ * index of sequence to be revealed
+ */
+ int revealSeq_index=-1;
Menu menu1 = new Menu();
public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)
if (sg != null && sg.getSize() > 0)
{
- editGroupName.setLabel(sg.getName());
+ editGroupName.setLabel("Name: "+sg.getName());
showText.setState(sg.getDisplayText());
showColourText.setState(sg.getColourText());
showBoxes.setState(sg.getDisplayBoxes());
- displayNonconserved.setState(sg.getShowunconserved());
- if (!ap.av.alignment.getGroups().contains(sg))
+ displayNonconserved.setState(sg.getShowNonconserved());
+ if (!ap.av.getAlignment().getGroups().contains(sg))
{
groupMenu.remove(unGroupMenuItem);
}
final String target = urlLink.getTarget(); // link.substring(0,
// link.indexOf("|"));
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[]
- { target });
+ DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
+ seq.getDBRef(), new String[]
+ { target });
// collect id string too
String id = seq.getName();
String descr = seq.getDescription();
}
}
}
+ // TODO: add group link menu entry here
if (seq != null)
{
seqMenu.setLabel(seq.getName());
remove(seqMenu);
}
- if (!ap.av.hasHiddenRows)
+ if (!ap.av.hasHiddenRows())
{
remove(revealAll);
+ remove(revealSeq);
+ } else {
+ final int index = ap.av.getAlignment().findIndex(seq);
+
+ if (ap.av.adjustForHiddenSeqs(index)
+ - ap.av.adjustForHiddenSeqs(index - 1) > 1)
+ {
+ revealSeq_index=index;
+ } else {
+ remove(revealSeq);
+ }
}
}
{
hideSequences(true);
}
+ else if (source == revealSeq)
+ {
+ ap.av.showSequence(revealSeq_index);
+ }
else if (source == revealAll)
{
ap.av.showAllHiddenSeqs();
{
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);
Vector regions = new Vector();
if (sg != null)
{
- int start = sg.getStartRes();
- int end = sg.getEndRes() + 1;
-
- do
- {
- if (ap.av.hasHiddenColumns)
- {
- if (start == 0)
- {
- start = ap.av.colSel.adjustForHiddenColumns(start);
- }
-
- end = ap.av.colSel.getHiddenBoundaryRight(start);
- if (start == end)
- {
- end = sg.getEndRes() + 1;
- }
- if (end > sg.getEndRes())
- {
- end = sg.getEndRes() + 1;
- }
- }
-
- regions.addElement(new int[]
- { start, end });
-
- if (ap.av.hasHiddenColumns)
- {
- start = ap.av.colSel.adjustForHiddenColumns(end);
- start = ap.av.colSel.getHiddenBoundaryLeft(start) + 1;
- }
- } while (end < sg.getEndRes());
-
- int[][] startEnd = new int[regions.size()][2];
- for (int i = 0; i < regions.size(); i++)
- {
- startEnd[i] = (int[]) regions.elementAt(i);
- }
+ int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
+ sg.getEndRes() + 1);
String description;
int caseChange;
}
ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
- sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
+ sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), startEnd,
caseChange);
ap.alignFrame.addHistoryItem(caseCommand);
return;
}
-
- int rsize=0,gSize = sg.getSize();
- SequenceI[] rseqs,seqs = new SequenceI[gSize];
- SequenceFeature[] tfeatures,features = new SequenceFeature[gSize];
-
+ int rsize = 0, gSize = sg.getSize();
+ SequenceI[] rseqs, seqs = new SequenceI[gSize];
+ SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
+
for (int i = 0; i < gSize; i++)
{
int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
int end = sg.findEndRes(sg.getSequenceAt(i));
- if (start<=end)
+ if (start <= end)
{
seqs[rsize] = sg.getSequenceAt(i);
- features[rsize] = new SequenceFeature(null, null, null, start, end,
- "Jalview");
+ features[rsize] = new SequenceFeature(null, null, null, start,
+ end, "Jalview");
rsize++;
}
}
rseqs = new SequenceI[rsize];
tfeatures = new SequenceFeature[rsize];
- System.arraycopy(seqs,0,rseqs, 0, rsize);
+ System.arraycopy(seqs, 0, rseqs, 0, rsize);
System.arraycopy(features, 0, tfeatures, 0, rsize);
features = tfeatures;
seqs = rseqs;
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, "Selection output - "
- + e.getActionCommand(), 600, 500);
+ jalview.bin.JalviewLite.addFrame(frame,
+ "Selection output - " + e.getActionCommand(), 600, 500);
+ // JBPNote: getSelectionAsNewSequence behaviour has changed - this method now returns a full copy of sequence data
+ // TODO consider using getSequenceSelection instead here
- cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(e
- .getActionCommand(), new Alignment(ap.av
- .getSelectionAsNewSequence()), ap.av.showJVSuffix));
+ cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
+ e.getActionCommand(),
+ new Alignment(ap.av.getSelectionAsNewSequence()),
+ ap.av.showJVSuffix));
}
void editName()
{
- EditNameDialog dialog = new EditNameDialog(seq.getName(), seq
- .getDescription(), " Sequence Name",
+ EditNameDialog dialog = new EditNameDialog(seq.getName(),
+ seq.getDescription(), " Sequence Name",
"Sequence Description", ap.alignFrame,
"Edit Sequence Name / Description", 500, 100, true);
cap.setPDBImport(seq);
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, "Paste PDB file ", 400, 300);
+ jalview.bin.JalviewLite.addFrame(frame, "Paste PDB file for sequence "+seq.getName(), 400, 300);
}
}
hideSeqs.setLabel("Hide Sequences");
repGroup.setLabel("Represent Group with");
revealAll.setLabel("Reveal All");
+ revealSeq.setLabel("Reveal Sequences");
menu1.setLabel("Group");
add(groupMenu);
this.add(seqMenu);
this.add(hideSeqs);
+ this.add(revealSeq);
this.add(revealAll);
groupMenu.add(editGroupName);
groupMenu.add(editMenu);
toLower.addActionListener(this);
editMenu.add(toggleCase);
seqMenu.add(sequenceName);
- seqMenu.add(pdb);
+ if (!ap.av.applet.useXtrnalSviewer)
+ {
+ seqMenu.add(pdb);
+ }
seqMenu.add(repGroup);
menu1.add(unGroupMenuItem);
menu1.add(colourMenu);
hideSeqs.addActionListener(this);
repGroup.addActionListener(this);
revealAll.addActionListener(this);
+ revealSeq.addActionListener(this);
}
void refresh()
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.getHiddenRepSequences()),
+ ap.av.getAlignment().getWidth());
refresh();
}
if (abovePIDColour.getState())
{
- sg.cs.setConsensus(AAFrequency.calculate(sg
- .getSequences(ap.av.hiddenRepSequences), 0, ap.av.alignment
- .getWidth()));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+ ap.av.getAlignment().getWidth()));
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), 0, ap.av.alignment
- .getWidth()));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+ ap.av.getAlignment().getWidth()));
refresh();
}
sg.cs = new Blosum62ColourScheme();
- sg.cs.setConsensus(AAFrequency.calculate(sg
- .getSequences(ap.av.hiddenRepSequences), 0, ap.av.alignment
- .getWidth()));
+ sg.cs.setConsensus(AAFrequency.calculate(
+ sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+ ap.av.getAlignment().getWidth()));
refresh();
}
if (conservationMenuItem.getState())
{
- Conservation c = new Conservation("Group",
- ResidueProperties.propHash, 3, sg
- .getSequences(ap.av.hiddenRepSequences), 0,
- ap.av.alignment.getWidth());
-
- c.calculate();
- c.verdict(false, ap.av.ConsPercGaps);
-
- sg.cs.setConservation(c);
-
+ sg.cs.setConservation(Conservation.calculateConservation("Group",
+ ResidueProperties.propHash, 3,
+ sg.getSequences(ap.av.getHiddenRepSequences()), 0,
+ ap.av.getAlignment().getWidth(),
+ false, ap.av.getConsPercGaps(),false));
SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
SliderPanel.showConservationSlider();
}
// 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 unGroupMenuItem_actionPerformed()
{
SequenceGroup sg = ap.av.getSelectionGroup();
- ap.av.alignment.deleteGroup(sg);
+ ap.av.getAlignment().deleteGroup(sg);
ap.av.setSelectionGroup(null);
ap.paintAlignment(true);
}
public void showNonconserved_itemStateChanged()
{
- getGroup().setShowunconserved(this.displayNonconserved.getState());
+ getGroup().setShowNonconserved(this.displayNonconserved.getState());
refresh();
}
}
ap.av.hideSequence(hseqs);
+ ap.av.sendSelection();
}
}