showColourText.setState(sg.getColourText());
showBoxes.setState(sg.getDisplayBoxes());
displayNonconserved.setState(sg.getShowNonconserved());
- if (!ap.av.alignment.getGroups().contains(sg))
+ if (!ap.av.getAlignment().getGroups().contains(sg))
{
groupMenu.remove(unGroupMenuItem);
}
remove(seqMenu);
}
- if (!ap.av.hasHiddenRows)
+ if (!ap.av.hasHiddenRows())
{
remove(revealAll);
remove(revealSeq);
} else {
- 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)
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);
+ 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);
- }
+ // TODO test change case behaves identically in JvLite
+ 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);
frame.add(cap);
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(),
{
SequenceGroup sg = getGroup();
sg.cs = new ClustalxColourScheme(
- sg.getSequences(ap.av.hiddenRepSequences),
- ap.av.alignment.getWidth());
+ 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.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.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.getSequences(ap.av.getHiddenRepSequences()), 0,
+ ap.av.getAlignment().getWidth()));
refresh();
}
sg.cs.setConservation(Conservation.calculateConservation("Group",
ResidueProperties.propHash, 3,
- sg.getSequences(ap.av.hiddenRepSequences), 0,
- ap.av.alignment.getWidth(),
+ 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);
}
viewport.updateConsensus(alignPanel);\r
\r
annotationPanelMenuItem.setState(viewport.showAnnotation);\r
- displayNonconservedMenuItem.setState(viewport.getShowunconserved());\r
+ displayNonconservedMenuItem.setState(viewport.getShowUnconserved());\r
followMouseOverFlag.setState(viewport.getFollowHighlight());\r
- showGroupConsensus.setState(viewport.showGroupConsensus);\r
- showGroupConservation.setState(viewport.showGroupConservation);\r
- showConsensusHistogram.setState(viewport.showConsensusHistogram);\r
- showSequenceLogo.setState(viewport.showSequenceLogo);\r
+ showGroupConsensus.setState(viewport.isShowGroupConsensus());\r
+ showGroupConservation.setState(viewport.isShowGroupConservation());\r
+ showConsensusHistogram.setState(viewport.isShowConsensusHistogram());\r
+ showSequenceLogo.setState(viewport.isShowSequenceLogo());\r
\r
seqLimits.setState(viewport.showJVSuffix);\r
\r
try\r
{\r
featuresFile = new jalview.io.FeaturesFile(file, type)\r
- .parse(viewport.alignment,\r
+ .parse(viewport.getAlignment(),\r
alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,\r
featureLinks, true, viewport.applet.getDefaultParameter("relaxedidmatch", false));\r
} catch (Exception ex)\r
// Hide everything by the current selection - this is a hack - we do the\r
// invert and then hide\r
// first check that there will be visible columns after the invert.\r
- if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel\r
+ if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()\r
.getSelected().size() > 0)\r
|| (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg\r
.getEndRes()))\r
\r
if (toggleSeqs)\r
{\r
- if (sg != null && sg.getSize() != viewport.alignment.getHeight())\r
+ if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())\r
{\r
hide = true;\r
viewport.hideAllSelectedSeqs();\r
}\r
- else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))\r
+ else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))\r
{\r
viewport.showAllHiddenSeqs();\r
}\r
\r
if (toggleCols)\r
{\r
- if (viewport.colSel.getSelected().size() > 0)\r
+ if (viewport.getColumnSelection().getSelected().size() > 0)\r
{\r
viewport.hideSelectedColumns();\r
if (!toggleSeqs)\r
{\r
- viewport.selectionGroup = sg;\r
+ viewport.setSelectionGroup(sg);\r
}\r
}\r
else if (!hide)\r
}\r
else if (evt.getSource() == autoCalculate)\r
{\r
- viewport.autocalculateConsensus = autoCalculate.getState();\r
+ viewport.autoCalculateConsensus = autoCalculate.getState();\r
}\r
else if (evt.getSource() == sortByTree)\r
{\r
else if (source == alProperties)\r
{\r
StringBuffer contents = new jalview.io.AlignmentProperties(\r
- viewport.alignment).formatAsString();\r
+ viewport.getAlignment()).formatAsString();\r
CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);\r
cap.setText(contents.toString());\r
Frame frame = new Frame();\r
{\r
abovePIDThreshold.setState(false);\r
changeColour(new ClustalxColourScheme(\r
- viewport.alignment.getSequences(),\r
- viewport.alignment.getWidth()));\r
+ viewport.getAlignment().getSequences(),\r
+ viewport.getAlignment().getWidth()));\r
}\r
else if (source == zappoColour)\r
{\r
public String outputAnnotations(boolean displayTextbox)\r
{\r
String annotation = new AnnotationFile().printAnnotations(\r
- viewport.showAnnotation ? viewport.alignment\r
- .getAlignmentAnnotation() : null, viewport.alignment\r
+ viewport.showAnnotation ? viewport.getAlignment()\r
+ .getAlignmentAnnotation() : null, viewport.getAlignment()\r
.getGroups(),\r
- ((Alignment) viewport.alignment).alignmentProperties);\r
+ ((Alignment) viewport.getAlignment()).alignmentProperties);\r
\r
if (displayTextbox)\r
{\r
if (format.equalsIgnoreCase("Jalview"))\r
{\r
features = new FeaturesFile().printJalviewFormat(\r
- viewport.alignment.getSequencesArray(),\r
+ viewport.getAlignment().getSequencesArray(),\r
getDisplayedFeatureCols());\r
}\r
else\r
{\r
features = new FeaturesFile().printGFFFormat(\r
- viewport.alignment.getSequencesArray(),\r
+ viewport.getAlignment().getSequencesArray(),\r
getDisplayedFeatureCols());\r
}\r
\r
viewport.historyList.push(command);\r
viewport.redoList.removeAllElements();\r
updateEditMenuBar();\r
- viewport.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+ viewport.updateHiddenColumns();\r
}\r
}\r
\r
command.undoCommand(null);\r
\r
AlignViewport originalSource = getOriginatingSource(command);\r
-\r
- originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+ // JBPNote Test\r
+ if (originalSource!=viewport) {\r
+ System.err.println("Warning: Viewport object mismatch whilst undoing");\r
+ }\r
+ originalSource.updateHiddenColumns(); // originalSource.hasHiddenColumns = viewport.getColumnSelection().getHiddenColumns() != null;\r
updateEditMenuBar();\r
originalSource.firePropertyChange("alignment", null,\r
- originalSource.alignment.getSequences());\r
+ originalSource.getAlignment().getSequences());\r
}\r
\r
/**\r
command.doCommand(null);\r
\r
AlignViewport originalSource = getOriginatingSource(command);\r
- originalSource.hasHiddenColumns = viewport.colSel.getHiddenColumns() != null;\r
+ // JBPNote Test\r
+ if (originalSource!=viewport) {\r
+ System.err.println("Warning: Viewport object mismatch whilst re-doing");\r
+ }\r
+ originalSource.updateHiddenColumns(); //sethasHiddenColumns(); = viewport.getColumnSelection().getHiddenColumns() != null;\r
\r
updateEditMenuBar();\r
originalSource.firePropertyChange("alignment", null,\r
- originalSource.alignment.getSequences());\r
+ originalSource.getAlignment().getSequences());\r
}\r
\r
AlignViewport getOriginatingSource(CommandI command)\r
{\r
if (comps.elementAt(i) instanceof AlignmentPanel)\r
{\r
- if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment)\r
+ if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())\r
{\r
originalSource = ((AlignmentPanel) comps.elementAt(i)).av;\r
break;\r
// the current view against the closed view first\r
if (al != null)\r
{\r
- PaintRefresher.validateSequences(al, viewport.alignment);\r
+ PaintRefresher.validateSequences(al, viewport.getAlignment());\r
}\r
\r
originalSource = viewport;\r
\r
if (up)\r
{\r
- for (int i = 1; i < viewport.alignment.getHeight(); i++)\r
+ for (int i = 1; i < viewport.getAlignment().getHeight(); i++)\r
{\r
- SequenceI seq = viewport.alignment.getSequenceAt(i);\r
+ SequenceI seq = viewport.getAlignment().getSequenceAt(i);\r
if (!sg.getSequences(null).contains(seq))\r
{\r
continue;\r
}\r
\r
- SequenceI temp = viewport.alignment.getSequenceAt(i - 1);\r
+ SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);\r
if (sg.getSequences(null).contains(temp))\r
{\r
continue;\r
}\r
\r
- viewport.alignment.getSequences().setElementAt(temp, i);\r
- viewport.alignment.getSequences().setElementAt(seq, i - 1);\r
+ viewport.getAlignment().getSequences().setElementAt(temp, i);\r
+ viewport.getAlignment().getSequences().setElementAt(seq, i - 1);\r
}\r
}\r
else\r
{\r
- for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)\r
+ for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)\r
{\r
- SequenceI seq = viewport.alignment.getSequenceAt(i);\r
- if (!sg.getSequences(viewport.hiddenRepSequences).contains(seq))\r
+ SequenceI seq = viewport.getAlignment().getSequenceAt(i);\r
+ if (!sg.getSequences(viewport.getHiddenRepSequences()).contains(seq))\r
{\r
continue;\r
}\r
\r
- SequenceI temp = viewport.alignment.getSequenceAt(i + 1);\r
- if (sg.getSequences(viewport.hiddenRepSequences).contains(temp))\r
+ SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);\r
+ if (sg.getSequences(viewport.getHiddenRepSequences()).contains(temp))\r
{\r
continue;\r
}\r
\r
- viewport.alignment.getSequences().setElementAt(temp, i);\r
- viewport.alignment.getSequences().setElementAt(seq, i + 1);\r
+ viewport.getAlignment().getSequences().setElementAt(temp, i);\r
+ viewport.getAlignment().getSequences().setElementAt(seq, i + 1);\r
}\r
}\r
\r
Vector sg = new Vector();\r
if (viewport.cursorMode)\r
{\r
- sg.addElement(viewport.alignment\r
+ sg.addElement(viewport.getAlignment()\r
.getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));\r
}\r
else if (viewport.getSelectionGroup() != null\r
- && viewport.getSelectionGroup().getSize() != viewport.alignment\r
+ && viewport.getSelectionGroup().getSize() != viewport.getAlignment()\r
.getHeight())\r
{\r
sg = viewport.getSelectionGroup().getSequences(\r
- viewport.hiddenRepSequences);\r
+ viewport.getHiddenRepSequences());\r
}\r
\r
if (sg.size() < 1)\r
\r
Vector invertGroup = new Vector();\r
\r
- for (int i = 0; i < viewport.alignment.getHeight(); i++)\r
+ for (int i = 0; i < viewport.getAlignment().getHeight(); i++)\r
{\r
- if (!sg.contains(viewport.alignment.getSequenceAt(i)))\r
- invertGroup.addElement(viewport.alignment.getSequenceAt(i));\r
+ if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))\r
+ invertGroup.addElement(viewport.getAlignment().getSequenceAt(i));\r
}\r
\r
SequenceI[] seqs1 = new SequenceI[sg.size()];\r
for (int i = 0; i < sg.getSize(); i++)\r
{\r
SequenceI seq = sg.getSequenceAt(i);\r
- int index = viewport.alignment.findIndex(seq);\r
+ int index = viewport.getAlignment().findIndex(seq);\r
orderedSeqs.put(index + "", seq);\r
}\r
\r
int index = 0, startRes, endRes;\r
char ch;\r
\r
- if (viewport.hasHiddenColumns && viewport.getSelectionGroup() != null)\r
+ if (viewport.hasHiddenColumns() && viewport.getSelectionGroup() != null)\r
{\r
copiedHiddenColumns = new Vector();\r
int hiddenOffset = viewport.getSelectionGroup().getStartRes();\r
{\r
for (int i = 0; i < seqs.length; i++)\r
{\r
- viewport.alignment.addSequence(seqs[i]);\r
+ viewport.getAlignment().addSequence(seqs[i]);\r
}\r
\r
// !newAlignment\r
addHistoryItem(new EditCommand("Add sequences", EditCommand.PASTE,\r
- seqs, 0, viewport.alignment.getWidth(), viewport.alignment));\r
+ seqs, 0, viewport.getAlignment().getWidth(), viewport.getAlignment()));\r
\r
- viewport.setEndSeq(viewport.alignment.getHeight());\r
- viewport.alignment.getWidth();\r
+ viewport.setEndSeq(viewport.getAlignment().getHeight());\r
+ viewport.getAlignment().getWidth();\r
viewport.firePropertyChange("alignment", null,\r
- viewport.alignment.getSequences());\r
+ viewport.getAlignment().getSequences());\r
\r
}\r
\r
}\r
\r
// If the cut affects all sequences, remove highlighted columns\r
- if (sg.getSize() == viewport.alignment.getHeight())\r
+ if (sg.getSize() == viewport.getAlignment().getHeight())\r
{\r
viewport.getColumnSelection().removeElements(sg.getStartRes(),\r
sg.getEndRes() + 1);\r
*/\r
addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,\r
sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,\r
- viewport.alignment));\r
+ viewport.getAlignment()));\r
\r
viewport.setSelectionGroup(null);\r
- viewport.alignment.deleteGroup(sg);\r
+ viewport.getAlignment().deleteGroup(sg);\r
\r
viewport.firePropertyChange("alignment", null, viewport.getAlignment()\r
.getSequences());\r
viewport.getSequenceSelection(),\r
viewport.getAlignmentView(true).getSequenceStrings(\r
viewport.getGapCharacter()),\r
- viewport.alignment.getGroups());\r
- viewport.alignment.deleteAllGroups();\r
+ viewport.getAlignment().getGroups());\r
+ viewport.getAlignment().deleteAllGroups();\r
viewport.sequenceColours = null;\r
viewport.setSelectionGroup(null);\r
// set view properties for each group\r
{\r
// gps[g].setShowunconserved(viewport.getShowUnconserved());\r
gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());\r
- viewport.alignment.addGroup(gps[g]);\r
+ viewport.getAlignment().addGroup(gps[g]);\r
Color col = new Color((int) (Math.random() * 255),\r
(int) (Math.random() * 255), (int) (Math.random() * 255));\r
col = col.brighter();\r
\r
protected void deleteGroups_actionPerformed()\r
{\r
- viewport.alignment.deleteAllGroups();\r
+ viewport.getAlignment().deleteAllGroups();\r
viewport.sequenceColours = null;\r
viewport.setSelectionGroup(null);\r
\r
{\r
sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);\r
}\r
- sg.setEndRes(viewport.alignment.getWidth() - 1);\r
+ sg.setEndRes(viewport.getAlignment().getWidth() - 1);\r
viewport.setSelectionGroup(sg);\r
alignPanel.paintAlignment(true);\r
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());\r
if (viewport.getSelectionGroup() != null)\r
{\r
seqs = viewport.getSelectionGroup().getSequencesAsArray(\r
- viewport.hiddenRepSequences);\r
+ viewport.getHiddenRepSequences());\r
}\r
else\r
{\r
- seqs = viewport.alignment.getSequencesArray();\r
+ seqs = viewport.getAlignment().getSequencesArray();\r
}\r
\r
TrimRegionCommand trimRegion;\r
{\r
trimRegion = new TrimRegionCommand("Remove Left",\r
TrimRegionCommand.TRIM_LEFT, seqs, column,\r
- viewport.alignment, viewport.colSel,\r
- viewport.selectionGroup);\r
+ viewport.getAlignment(), viewport.getColumnSelection(),\r
+ viewport.getSelectionGroup());\r
viewport.setStartRes(0);\r
}\r
else\r
{\r
trimRegion = new TrimRegionCommand("Remove Right",\r
TrimRegionCommand.TRIM_RIGHT, seqs, column,\r
- viewport.alignment, viewport.colSel,\r
- viewport.selectionGroup);\r
+ viewport.getAlignment(), viewport.getColumnSelection(),\r
+ viewport.getSelectionGroup());\r
}\r
\r
statusBar.setText("Removed " + trimRegion.getSize() + " columns.");\r
\r
addHistoryItem(trimRegion);\r
\r
- Vector groups = viewport.alignment.getGroups();\r
+ Vector groups = viewport.getAlignment().getGroups();\r
\r
for (int i = 0; i < groups.size(); i++)\r
{\r
if ((trimLeft && !sg.adjustForRemoveLeft(column))\r
|| (!trimLeft && !sg.adjustForRemoveRight(column)))\r
{\r
- viewport.alignment.deleteGroup(sg);\r
+ viewport.getAlignment().deleteGroup(sg);\r
}\r
}\r
\r
\r
public void removeGappedColumnMenuItem_actionPerformed()\r
{\r
- int start = 0, end = viewport.alignment.getWidth() - 1;\r
+ int start = 0, end = viewport.getAlignment().getWidth() - 1;\r
\r
SequenceI[] seqs;\r
if (viewport.getSelectionGroup() != null)\r
{\r
seqs = viewport.getSelectionGroup().getSequencesAsArray(\r
- viewport.hiddenRepSequences);\r
+ viewport.getHiddenRepSequences());\r
start = viewport.getSelectionGroup().getStartRes();\r
end = viewport.getSelectionGroup().getEndRes();\r
}\r
else\r
{\r
- seqs = viewport.alignment.getSequencesArray();\r
+ seqs = viewport.getAlignment().getSequencesArray();\r
}\r
\r
RemoveGapColCommand removeGapCols = new RemoveGapColCommand(\r
- "Remove Gapped Columns", seqs, start, end, viewport.alignment);\r
+ "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());\r
\r
addHistoryItem(removeGapCols);\r
\r
\r
// This is to maintain viewport position on first residue\r
// of first sequence\r
- SequenceI seq = viewport.alignment.getSequenceAt(0);\r
+ SequenceI seq = viewport.getAlignment().getSequenceAt(0);\r
int startRes = seq.findPosition(viewport.startRes);\r
// ShiftList shifts;\r
// viewport.getAlignment().removeGaps(shifts=new ShiftList());\r
\r
public void removeAllGapsMenuItem_actionPerformed()\r
{\r
- int start = 0, end = viewport.alignment.getWidth() - 1;\r
+ int start = 0, end = viewport.getAlignment().getWidth() - 1;\r
\r
SequenceI[] seqs;\r
if (viewport.getSelectionGroup() != null)\r
{\r
seqs = viewport.getSelectionGroup().getSequencesAsArray(\r
- viewport.hiddenRepSequences);\r
+ viewport.getHiddenRepSequences());\r
start = viewport.getSelectionGroup().getStartRes();\r
end = viewport.getSelectionGroup().getEndRes();\r
}\r
else\r
{\r
- seqs = viewport.alignment.getSequencesArray();\r
+ seqs = viewport.getAlignment().getSequencesArray();\r
}\r
\r
// This is to maintain viewport position on first residue\r
// of first sequence\r
- SequenceI seq = viewport.alignment.getSequenceAt(0);\r
+ SequenceI seq = viewport.getAlignment().getSequenceAt(0);\r
int startRes = seq.findPosition(viewport.startRes);\r
\r
addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,\r
- viewport.alignment));\r
+ viewport.getAlignment()));\r
\r
viewport.setStartRes(seq.findIndex(startRes) - 1);\r
\r
public AlignFrame newView(String viewtitle)\r
{\r
AlignmentI newal;\r
- if (viewport.hasHiddenRows)\r
+ if (viewport.hasHiddenRows())\r
{\r
newal = new Alignment(viewport.getAlignment().getHiddenSequences()\r
.getFullAlignment().getSequencesArray());\r
}\r
else\r
{\r
- newal = new Alignment(viewport.alignment.getSequencesArray());\r
+ newal = new Alignment(viewport.getAlignment().getSequencesArray());\r
}\r
\r
- if (viewport.alignment.getAlignmentAnnotation() != null)\r
+ if (viewport.getAlignment().getAlignmentAnnotation() != null)\r
{\r
- for (int i = 0; i < viewport.alignment.getAlignmentAnnotation().length; i++)\r
+ for (int i = 0; i < viewport.getAlignment().getAlignmentAnnotation().length; i++)\r
{\r
- if (!viewport.alignment.getAlignmentAnnotation()[i].autoCalculated)\r
+ if (!viewport.getAlignment().getAlignmentAnnotation()[i].autoCalculated)\r
{\r
- newal.addAnnotation(viewport.alignment.getAlignmentAnnotation()[i]);\r
+ newal.addAnnotation(viewport.getAlignment().getAlignmentAnnotation()[i]);\r
}\r
}\r
}\r
\r
AlignFrame newaf = new AlignFrame(newal, viewport.applet, "", false);\r
\r
- newaf.viewport.sequenceSetID = alignPanel.av.getSequenceSetId();\r
+ newaf.viewport.setSequenceSetId(alignPanel.av.getSequenceSetId());\r
PaintRefresher.Register(alignPanel, alignPanel.av.getSequenceSetId());\r
PaintRefresher.Register(newaf.alignPanel,\r
newaf.alignPanel.av.getSequenceSetId());\r
if (viewport.getConservationSelected())\r
{\r
\r
- Alignment al = (Alignment) viewport.alignment;\r
+ Alignment al = (Alignment) viewport.getAlignment();\r
Conservation c = new Conservation("All",\r
ResidueProperties.propHash, 3, al.getSequences(), 0,\r
al.getWidth() - 1);\r
cs.setConservation(null);\r
}\r
\r
- cs.setConsensus(viewport.hconsensus);\r
+ cs.setConsensus(viewport.getSequenceConsensusHash());\r
\r
}\r
viewport.setGlobalColourScheme(cs);\r
\r
if (viewport.getColourAppliesToAllGroups())\r
{\r
- Vector groups = viewport.alignment.getGroups();\r
+ Vector groups = viewport.getAlignment().getGroups();\r
for (int i = 0; i < groups.size(); i++)\r
{\r
SequenceGroup sg = (SequenceGroup) groups.elementAt(i);\r
if (cs instanceof ClustalxColourScheme)\r
{\r
sg.cs = new ClustalxColourScheme(\r
- sg.getSequences(viewport.hiddenRepSequences),\r
+ sg.getSequences(viewport.getHiddenRepSequences()),\r
sg.getWidth());\r
}\r
else\r
{\r
sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
sg.cs.setConsensus(AAFrequency.calculate(\r
- sg.getSequences(viewport.hiddenRepSequences), 0,\r
+ sg.getSequences(viewport.getHiddenRepSequences()), 0,\r
sg.getWidth()));\r
}\r
else\r
{\r
Conservation c = new Conservation("Group",\r
ResidueProperties.propHash, 3,\r
- sg.getSequences(viewport.hiddenRepSequences), 0,\r
- viewport.alignment.getWidth() - 1);\r
+ sg.getSequences(viewport.getHiddenRepSequences()), 0,\r
+ viewport.getAlignment().getWidth() - 1);\r
c.calculate();\r
c.verdict(false, viewport.getConsPercGaps());\r
sg.cs.setConservation(c);\r
protected void modifyPID_actionPerformed()\r
{\r
if (viewport.getAbovePIDThreshold()\r
- && viewport.globalColourScheme != null)\r
+ && viewport.getGlobalColourScheme() != null)\r
{\r
SliderPanel.setPIDSliderSource(alignPanel,\r
viewport.getGlobalColourScheme(), "Background");\r
protected void modifyConservation_actionPerformed()\r
{\r
if (viewport.getConservationSelected()\r
- && viewport.globalColourScheme != null)\r
+ && viewport.getGlobalColourScheme() != null)\r
{\r
SliderPanel.setConservationSlider(alignPanel,\r
- viewport.globalColourScheme, "Background");\r
+ viewport.getGlobalColourScheme(), "Background");\r
SliderPanel.showConservationSlider();\r
}\r
}\r
.getAlignment().getSequenceAt(0), null);\r
\r
addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,\r
- viewport.alignment));\r
+ viewport.getAlignment()));\r
alignPanel.paintAlignment(true);\r
}\r
\r
{\r
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();\r
AlignmentSorter.sortByID(viewport.getAlignment());\r
- addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));\r
+ addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));\r
alignPanel.paintAlignment(true);\r
}\r
\r
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();\r
AlignmentSorter.sortByLength(viewport.getAlignment());\r
addHistoryItem(new OrderCommand("Length Sort", oldOrder,\r
- viewport.alignment));\r
+ viewport.getAlignment()));\r
alignPanel.paintAlignment(true);\r
}\r
\r
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();\r
AlignmentSorter.sortByGroup(viewport.getAlignment());\r
addHistoryItem(new OrderCommand("Group Sort", oldOrder,\r
- viewport.alignment));\r
+ viewport.getAlignment()));\r
alignPanel.paintAlignment(true);\r
\r
}\r
public void PCAMenuItem_actionPerformed()\r
{\r
// are the sequences aligned?\r
- if (!viewport.alignment.isAligned(false))\r
+ if (!viewport.getAlignment().isAligned(false))\r
{\r
SequenceI current;\r
int Width = viewport.getAlignment().getWidth();\r
void NewTreePanel(String type, String pwType, String title)\r
{\r
// are the sequences aligned?\r
- if (!viewport.alignment.isAligned(false))\r
+ if (!viewport.getAlignment().isAligned(false))\r
{\r
SequenceI current;\r
int Width = viewport.getAlignment().getWidth();\r
\r
if ((viewport.getSelectionGroup() != null && viewport\r
.getSelectionGroup().getSize() > 1)\r
- || (viewport.getSelectionGroup() == null && viewport.alignment\r
+ || (viewport.getSelectionGroup() == null && viewport.getAlignment()\r
.getHeight() > 1))\r
{\r
final TreePanel tp = new TreePanel(alignPanel, type, pwType);\r
// addHistoryItem(new HistoryItem("Sort", viewport.alignment,\r
// HistoryItem.SORT));\r
addHistoryItem(new OrderCommand("Order by " + title, oldOrder,\r
- viewport.alignment));\r
+ viewport.getAlignment()));\r
alignPanel.paintAlignment(true);\r
}\r
\r
AlignmentSorter.sortBy(viewport.getAlignment(), alorder);\r
if (undoname!=null)\r
{\r
- addHistoryItem(new OrderCommand(undoname, oldOrder, viewport.alignment));\r
+ addHistoryItem(new OrderCommand(undoname, oldOrder, viewport.getAlignment()));\r
}\r
alignPanel.paintAlignment(true);\r
return true;\r
import jalview.schemes.*;
import jalview.structure.SelectionSource;
import jalview.structure.VamsasSource;
+import jalview.viewmodel.AlignmentViewport;
import jalview.workers.ConservationThread;
+import jalview.workers.ConsensusThread;
public class AlignViewport extends AlignmentViewport implements AlignViewportI, SelectionSource, VamsasSource
{
boolean colourAppliesToAllGroups = true;
- ColourSchemeI globalColourScheme = null;
-
boolean conservationColourSelected = false;
boolean abovePIDThreshold = false;
- SequenceGroup selectionGroup;
-
int charHeight;
int charWidth;
boolean validCharWidth = true;
- AlignmentI alignment;
-
- ColumnSelection colSel = new ColumnSelection();
-
int threshold;
int increment;
// currently visible, in the correct order or rendering
public Hashtable featuresDisplayed;
- boolean hasHiddenColumns = false;
-
- boolean hasHiddenRows = false;
boolean showHiddenMarkers = true;
- public Hashtable[] hconsensus;
-
- AlignmentAnnotation consensus;
-
- AlignmentAnnotation conservation;
-
- AlignmentAnnotation quality;
-
- AlignmentAnnotation[] groupConsensus;
-
- AlignmentAnnotation[] groupConservation;
-
- boolean autocalculateConsensus = true;
-
- private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
- this);
-
- boolean ignoreGapsInConsensusCalculation = false;
-
public jalview.bin.JalviewLite applet;
Hashtable sequenceColours;
Stack historyList = new Stack();
Stack redoList = new Stack();
-
- String sequenceSetID;
-
- Hashtable hiddenRepSequences;
-
- AlignCalcManagerI calculator=new jalview.workers.AlignCalcManager();
-
+
public void finalize() {
applet=null;
quality=null;
public AlignViewport(AlignmentI al, JalviewLite applet)
{
+ calculator = new jalview.workers.AlignCalcManager();
this.applet = applet;
setAlignment(al);
+ // we always pad gaps
+ this.setPadGaps(true);
this.startRes = 0;
this.endRes = al.getWidth() - 1;
this.startSeq = 0;
}
- ConsensusThread consensusThread;
-
-// StrucConsensusThread strucConsensusThread;
-
-
- boolean consUpdateNeeded = false;
-
- static boolean UPDATING_CONSENSUS = false;
-
- static boolean UPDATING_STRUC_CONSENSUS = false;
-
- static boolean UPDATING_CONSERVATION = false;
-
- boolean updatingConsensus = false;
-
- boolean updatingStrucConsensus = false;
-
- boolean updatingConservation = false;
-
- /**
- * DOCUMENT ME!
- */
- public void updateConservation(final AlignmentPanel ap)
- {
- if (alignment.isNucleotide() || conservation == null)
- {
- return;
- }
-
- calculator.startWorker(new ConservationThread(this, ap));
- }
-
- /**
- * DOCUMENT ME!
- */
- public void updateConsensus(final AlignmentPanel ap)
- {
- consensusThread = new ConsensusThread(ap);
- consensusThread.start();
- }
-
- class ConsensusThread extends Thread
- {
- AlignmentPanel ap;
-
- public ConsensusThread(AlignmentPanel ap)
- {
- this.ap = ap;
- }
-
- public void run()
- {
- updatingConsensus = true;
- while (UPDATING_CONSENSUS)
- {
- try
- {
- if (ap != null)
- {
- ap.paintAlignment(false);
- }
-
- Thread.sleep(200);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- UPDATING_CONSENSUS = true;
-
- try
- {
- int aWidth = alignment==null ? -1 : alignment.getWidth();
- if (aWidth < 0)
- {
- UPDATING_CONSENSUS = false;
- updatingConsensus = false;
- return;
- }
-
- consensus.annotations = null;
- consensus.annotations = new Annotation[aWidth];
-
- hconsensus = new Hashtable[aWidth];
- AAFrequency.calculate(alignment.getSequencesArray(), 0,
- alignment.getWidth(), hconsensus, true); // always calculate the
- // full profile
- updateAnnotation(true);
- //AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
- // ignoreGapsInConsensusCalculation,
- // true);
-
- if (globalColourScheme != null)
- {
- globalColourScheme.setConsensus(hconsensus);
- }
-
- } catch (OutOfMemoryError error)
- {
- alignment.deleteAnnotation(consensus);
-
- consensus = null;
- hconsensus = null;
- System.out.println("Out of memory calculating consensus!!");
- System.gc();
- }
- UPDATING_CONSENSUS = false;
- updatingConsensus = false;
-
- if (ap != null)
- {
- ap.paintAlignment(true);
- }
- }
-
- /**
- * update the consensus annotation from the sequence profile data using
- * current visualization settings.
- */
- public void updateAnnotation()
- {
- updateAnnotation(false);
- }
-
- protected void updateAnnotation(boolean immediate)
- {
- // TODO: make calls thread-safe, so if another thread calls this method,
- // it will either return or wait until one calculation is finished.
- if (immediate
- || (!updatingConsensus && consensus != null && hconsensus != null))
- {
- AAFrequency.completeConsensus(consensus, hconsensus, 0,
- hconsensus.length, ignoreGapsInConsensusCalculation,
- showSequenceLogo);
- }
- }
- }
-
/**
* get the consensus sequence as displayed under the PID consensus annotation
* row.
return sq;
}
- public SequenceGroup getSelectionGroup()
- {
- return selectionGroup;
- }
-
- public void setSelectionGroup(SequenceGroup sg)
- {
- selectionGroup = sg;
- }
-
public boolean getConservationSelected()
{
return conservationColourSelected;
return startSeq;
}
- public void setGlobalColourScheme(ColourSchemeI cs)
- {
- globalColourScheme = cs;
- }
-
- public ColourSchemeI getGlobalColourScheme()
- {
- return globalColourScheme;
- }
-
public void setStartRes(int res)
{
this.startRes = res;
return increment;
}
- public void setHiddenColumns(ColumnSelection colsel)
- {
- this.colSel = colsel;
- if (colSel.getHiddenColumns() != null)
- {
- hasHiddenColumns = true;
- }
- }
-
- public ColumnSelection getColumnSelection()
- {
- return colSel;
- }
-
public void resetSeqLimits(int height)
{
setEndSeq(height / getCharHeight());
}
}
- /**
- * Property change listener for changes in alignment
- *
- * @param listener
- * DOCUMENT ME!
- */
- public void addPropertyChangeListener(
- java.beans.PropertyChangeListener listener)
- {
- changeSupport.addPropertyChangeListener(listener);
- }
- /**
- * DOCUMENT ME!
- *
- * @param listener
- * DOCUMENT ME!
- */
- public void removePropertyChangeListener(
- java.beans.PropertyChangeListener listener)
- {
- changeSupport.removePropertyChangeListener(listener);
- }
+
- /**
- * Property change listener for changes in alignment
- *
- * @param prop
- * DOCUMENT ME!
- * @param oldvalue
- * DOCUMENT ME!
- * @param newvalue
- * DOCUMENT ME!
- */
- public void firePropertyChange(String prop, Object oldvalue,
- Object newvalue)
- {
- changeSupport.firePropertyChange(prop, oldvalue, newvalue);
- }
-
- public boolean getIgnoreGapsConsensus()
- {
- return ignoreGapsInConsensusCalculation;
- }
-
- public void hideSelectedColumns()
- {
- if (colSel.size() < 1)
- {
- return;
- }
-
- colSel.hideSelectedColumns();
- setSelectionGroup(null);
-
- hasHiddenColumns = true;
- }
-
- public void invertColumnSelection()
- {
- for (int i = 0; i < alignment.getWidth(); i++)
- {
- if (colSel.contains(i))
- {
- colSel.removeElement(i);
- }
- else
- {
- if (!hasHiddenColumns || colSel.isVisible(i))
- {
- colSel.addElement(i);
- }
- }
- }
- }
-
- public void hideColumns(int start, int end)
- {
- if (start == end)
- {
- colSel.hideColumns(start);
- }
- else
- {
- colSel.hideColumns(start, end);
- }
-
- hasHiddenColumns = true;
- }
-
- public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
- {
- int sSize = sg.getSize();
- if (sSize < 2)
- {
- return;
- }
-
- if (hiddenRepSequences == null)
- {
- hiddenRepSequences = new Hashtable();
- }
-
- hiddenRepSequences.put(repSequence, sg);
-
- // Hide all sequences except the repSequence
- SequenceI[] seqs = new SequenceI[sSize - 1];
- int index = 0;
- for (int i = 0; i < sSize; i++)
- {
- if (sg.getSequenceAt(i) != repSequence)
- {
- if (index == sSize - 1)
- {
- return;
- }
-
- seqs[index++] = sg.getSequenceAt(i);
- }
- }
-
- hideSequence(seqs);
-
- }
-
- public void hideAllSelectedSeqs()
- {
- if (selectionGroup == null || selectionGroup.getSize() < 1)
- {
- return;
- }
-
- SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
-
- hideSequence(seqs);
-
- setSelectionGroup(null);
- }
-
- public void hideSequence(SequenceI[] seq)
- {
- if (seq != null)
- {
- for (int i = 0; i < seq.length; i++)
- {
- alignment.getHiddenSequences().hideSequence(seq[i]);
- }
-
- hasHiddenRows = true;
- firePropertyChange("alignment", null, alignment.getSequences());
- }
- }
- public void showSequence(int index)
- {
- Vector tmp = alignment.getHiddenSequences().showSequence(index,
- hiddenRepSequences);
- if (tmp.size() > 0)
- {
- if (selectionGroup == null)
- {
- selectionGroup = new SequenceGroup();
- selectionGroup.setEndRes(alignment.getWidth() - 1);
- }
-
- for (int t = 0; t < tmp.size(); t++)
- {
- selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
- }
- firePropertyChange("alignment", null, alignment.getSequences());
- sendSelection();
- }
-
- if (alignment.getHiddenSequences().getSize() < 1)
- {
- hasHiddenRows = false;
- }
- }
- public void showColumn(int col)
- {
- colSel.revealHiddenColumns(col);
- if (colSel.getHiddenColumns() == null)
- {
- hasHiddenColumns = false;
- }
- }
-
- public void showAllHiddenColumns()
- {
- colSel.revealAllHiddenColumns();
- hasHiddenColumns = false;
- }
-
- public void showAllHiddenSeqs()
- {
- if (alignment.getHiddenSequences().getSize() > 0)
- {
- if (selectionGroup == null)
- {
- selectionGroup = new SequenceGroup();
- selectionGroup.setEndRes(alignment.getWidth() - 1);
- }
- Vector tmp = alignment.getHiddenSequences().showAll(
- hiddenRepSequences);
- for (int t = 0; t < tmp.size(); t++)
- {
- selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
- }
- firePropertyChange("alignment", null, alignment.getSequences());
- hasHiddenRows = false;
- hiddenRepSequences = null;
- sendSelection();
- }
- }
-
- public int adjustForHiddenSeqs(int alignmentIndex)
- {
- return alignment.getHiddenSequences().adjustForHiddenSeqs(
- alignmentIndex);
- }
-
- /**
- * This method returns the a new SequenceI [] with the selection sequence and
- * start and end points adjusted
- *
- * @return String[]
- */
- public SequenceI[] getSelectionAsNewSequence()
- {
- SequenceI[] sequences;
-
- if (selectionGroup == null)
- {
- sequences = alignment.getSequencesArray();
- }
- else
- {
- sequences = selectionGroup.getSelectionAsNewSequences(alignment);
- }
-
- return sequences;
- }
-
- /**
- * get the currently selected sequence objects or all the sequences in the
- * alignment.
- *
- * @return array of references to sequence objects
- */
- public SequenceI[] getSequenceSelection()
- {
- SequenceI[] sequences = null;
- if (selectionGroup != null)
- {
- sequences = selectionGroup.getSequencesInOrder(alignment);
- }
- if (sequences == null)
- {
- sequences = alignment.getSequencesArray();
- }
- return sequences;
- }
-
- /**
- * This method returns the visible alignment as text, as seen on the GUI, ie
- * if columns are hidden they will not be returned in the result. Use this for
- * calculating trees, PCA, redundancy etc on views which contain hidden
- * columns.
- *
- * @return String[]
- */
- public jalview.datamodel.CigarArray getViewAsCigars(
- boolean selectedRegionOnly)
- {
- return new jalview.datamodel.CigarArray(alignment, (hasHiddenColumns ? colSel : null), (selectedRegionOnly ? selectionGroup : null));
- }
-
- /**
- * return a compact representation of the current alignment selection to pass
- * to an analysis function
- *
- * @param selectedOnly
- * boolean true to just return the selected view
- * @return AlignmentView
- */
- jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
- {
- return getAlignmentView(selectedOnly, false);
- }
-
- /**
- * return a compact representation of the current alignment selection to pass
- * to an analysis function
- *
- * @param selectedOnly
- * boolean true to just return the selected view
- * @param markGroups
- * boolean true to annotate the alignment view with groups on the alignment (and intersecting with selected region if selectedOnly is true)
- * @return AlignmentView
- */
- public jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups)
- {
- return new AlignmentView(alignment, colSel, selectionGroup, hasHiddenColumns, selectedOnly, markGroups);
- }
- /**
- * This method returns the visible alignment as text, as seen on the GUI, ie
- * if columns are hidden they will not be returned in the result. Use this for
- * calculating trees, PCA, redundancy etc on views which contain hidden
- * columns.
- *
- * @return String[]
- */
- public String[] getViewAsString(boolean selectedRegionOnly)
- {
- String[] selection = null;
- SequenceI[] seqs = null;
- int i, iSize;
- int start = 0, end = 0;
- if (selectedRegionOnly && selectionGroup != null)
- {
- iSize = selectionGroup.getSize();
- seqs = selectionGroup.getSequencesInOrder(alignment);
- start = selectionGroup.getStartRes();
- end = selectionGroup.getEndRes() + 1;
- }
- else
- {
- iSize = alignment.getHeight();
- seqs = alignment.getSequencesArray();
- end = alignment.getWidth();
- }
-
- selection = new String[iSize];
-
- for (i = 0; i < iSize; i++)
- {
- if (hasHiddenColumns)
- {
- StringBuffer visibleSeq = new StringBuffer();
- Vector regions = colSel.getHiddenColumns();
-
- int blockStart = start, blockEnd = end;
- int[] region;
- int hideStart, hideEnd;
-
- for (int j = 0; j < regions.size(); j++)
- {
- region = (int[]) regions.elementAt(j);
- hideStart = region[0];
- hideEnd = region[1];
-
- if (hideStart < start)
- {
- continue;
- }
-
- blockStart = Math.min(blockStart, hideEnd + 1);
- blockEnd = Math.min(blockEnd, hideStart);
-
- if (blockStart > blockEnd)
- {
- break;
- }
-
- visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
-
- blockStart = hideEnd + 1;
- blockEnd = end;
- }
-
- if (end > blockStart)
- {
- visibleSeq.append(seqs[i].getSequence(blockStart, end));
- }
-
- selection[i] = visibleSeq.toString();
- }
- else
- {
- selection[i] = seqs[i].getSequenceAsString(start, end);
- }
- }
-
- return selection;
- }
public boolean getShowHiddenMarkers()
{
}
}
- public String getSequenceSetId()
- {
- if (sequenceSetID == null)
- {
- sequenceSetID = alignment.hashCode() + "";
- }
-
- return sequenceSetID;
- }
- /**
- * unique viewId for synchronizing state (e.g. with stored Jalview Project)
- *
- */
- private String viewId = null;
-
- public String getViewId()
- {
- if (viewId == null)
- {
- viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
- }
- return viewId;
- }
-
- public void alignmentChanged(AlignmentPanel ap)
- {
- alignment.padGaps();
-
- if (hconsensus != null && autocalculateConsensus)
- {
- updateConsensus(ap);
- updateConservation(ap);
- }
-
- // Reset endRes of groups if beyond alignment width
- int alWidth = alignment.getWidth();
- Vector groups = alignment.getGroups();
- if (groups != null)
- {
- for (int i = 0; i < groups.size(); i++)
- {
- SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
- if (sg.getEndRes() > alWidth)
- {
- sg.setEndRes(alWidth - 1);
- }
- }
- }
-
- if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
- {
- selectionGroup.setEndRes(alWidth - 1);
- }
-
- resetAllColourSchemes();
-
- // AW alignment.adjustSequenceAnnotations();
- }
-
- void resetAllColourSchemes()
- {
- ColourSchemeI cs = globalColourScheme;
- if (cs != null)
- {
- if (cs instanceof ClustalxColourScheme)
- {
- ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
- alignment.getWidth());
- }
-
- cs.setConsensus(hconsensus);
- if (cs.conservationApplied())
- {
- cs.setConservation(Conservation.calculateConservation("All",
- ResidueProperties.propHash, 3, alignment.getSequences(), 0,
- alignment.getWidth(), false, getConsPercGaps(), false));
- }
- }
-
- int s, sSize = alignment.getGroups().size();
- for (s = 0; s < sSize; s++)
- {
- SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
- if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
- {
- ((ClustalxColourScheme) sg.cs).resetClustalX(
- sg.getSequences(hiddenRepSequences), sg.getWidth());
- }
- sg.recalcConservation();
- }
- }
-
boolean centreColumnLabels;
public boolean getCentreColumnLabels()
SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
if (sg.idColour != null)
{
- Vector sqs = sg.getSequences(hiddenRepSequences);
+ Vector sqs = sg.getSequences(getHiddenRepSequences());
for (int s = 0, sSize = sqs.size(); s < sSize; s++)
{
this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
{
return followSelection;
}
-
- private long sgrouphash = -1, colselhash = -1;
-
- /**
- * checks current SelectionGroup against record of last hash value, and
- * updates record.
- *
- * @return true if SelectionGroup changed since last call
- */
- boolean isSelectionGroupChanged()
- {
- int hc = (selectionGroup == null) ? -1 : selectionGroup.hashCode();
- if (hc != sgrouphash)
- {
- sgrouphash = hc;
- return true;
- }
- return false;
- }
-
- /**
- * checks current colsel against record of last hash value, and updates
- * record.
- *
- * @return true if colsel changed since last call
- */
- boolean isColSelChanged()
- {
- int hc = (colSel == null) ? -1 : colSel.hashCode();
- if (hc != colselhash)
- {
- colselhash = hc;
- return true;
- }
- return false;
- }
public void sendSelection()
{
jalview.structure.StructureSelectionManager
/**
- * show non-conserved residues only
- */
- public boolean showUnconserved = false;
-
- /**
- * when set, alignment should be reordered according to a newly opened tree
- */
- public boolean sortByTree = false;
-
- /**
- * @return the showUnconserved
- */
- public boolean getShowunconserved()
- {
- return showUnconserved;
- }
-
- /**
- * @param showNonconserved
- * the showUnconserved to set
- */
- public void setShowunconserved(boolean displayNonconserved)
- {
- this.showUnconserved = displayNonconserved;
- }
-
- /**
- * should conservation rows be shown for groups
- */
- boolean showGroupConservation = false;
-
- /**
- * should consensus rows be shown for groups
- */
- boolean showGroupConsensus = false;
-
- /**
- * should consensus profile be rendered by default
- */
- public boolean showSequenceLogo = false;
- /**
- * should consensus profile be rendered normalised to row height
- */
- public boolean normaliseSequenceLogo = false;
-
- /**
- * should consensus histograms be rendered by default
- */
- public boolean showConsensusHistogram = true;
-
- /**
- * @return the showConsensusProfile
- */
- public boolean isShowSequenceLogo()
- {
- return showSequenceLogo;
- }
-
- /**
- * @param showSequenceLogo
- * the new value
- */
- public void setShowSequenceLogo(boolean showSequenceLogo)
- {
- if (showSequenceLogo != this.showSequenceLogo)
- {
- // TODO: decouple settings setting from calculation when refactoring
- // annotation update method from alignframe to viewport
- this.showSequenceLogo = showSequenceLogo;
- if (consensusThread != null)
- {
- consensusThread.updateAnnotation();
- }
- }
- this.showSequenceLogo = showSequenceLogo;
- }
-
- /**
- * @param showConsensusHistogram
- * the showConsensusHistogram to set
- */
- public void setShowConsensusHistogram(boolean showConsensusHistogram)
- {
- this.showConsensusHistogram = showConsensusHistogram;
- }
-
- /**
- * @return the showGroupConservation
- */
- public boolean isShowGroupConservation()
- {
- return showGroupConservation;
- }
-
- /**
- * @param showGroupConservation
- * the showGroupConservation to set
- */
- public void setShowGroupConservation(boolean showGroupConservation)
- {
- this.showGroupConservation = showGroupConservation;
- }
-
- /**
- * @return the showGroupConsensus
- */
- public boolean isShowGroupConsensus()
- {
- return showGroupConsensus;
- }
-
- /**
- * @param showGroupConsensus
- * the showGroupConsensus to set
- */
- public void setShowGroupConsensus(boolean showGroupConsensus)
- {
- this.showGroupConsensus = showGroupConsensus;
- }
-
- /**
- *
- * @return flag to indicate if the consensus histogram should be rendered by
- * default
- */
- public boolean isShowConsensusHistogram()
- {
- return this.showConsensusHistogram;
- }
-
- /**
* synthesize a column selection if none exists so it covers the given
* selection group. if wholewidth is false, no column selection is made if the
* selection group covers the whole alignment width.
normaliseSequenceLogo = state;
}
- public boolean isCalcInProgress()
- {
- // TODO generalise to iterate over all calculators associated with av
- return updatingConsensus || updatingConservation || updatingStrucConsensus;
- }
-
- public boolean isCalculationInProgress(
- AlignmentAnnotation alignmentAnnotation)
- {
- if (!alignmentAnnotation.autoCalculated)
- return false;
- if ((updatingConsensus && consensus==alignmentAnnotation)
- || (updatingConservation && (conservation==alignmentAnnotation || quality==alignmentAnnotation))
- // || (updatingStrucConsensus && strucConsensus==alignmentAnnotation)
- )
- {
- return true;
- }
- return false;
- }
-
/**
*
* @return true if alignment characters should be displayed
return validCharWidth;
}
- @Override
- public Hashtable[] getSequenceConsensusHash()
- {
- return hconsensus;
- }
-
- @Override
- public Hashtable[] getRnaStructureConsensusHash()
- {
- return null; // TODO: JAL-891 port to jvlite : refactor and introduce hStrucConsensus;
- }
-
- @Override
- public AlignmentAnnotation getAlignmentQualityAnnot()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public AlignmentAnnotation getAlignmentConservationAnnotation()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isClosed()
- {
- System.err.println("Alignment is "+alignment==null ? "closed" : "open");
- return alignment==null;
- }
-
- @Override
- public AlignCalcManagerI getCalcManager()
- {
- // TODO Auto-generated method stub
- return null;
- }
}
// do we need to scroll the panel?
if (results != null && results.getSize() > 0)
{
- int seqIndex = av.alignment.findIndex(results);
+ AlignmentI alignment=av.getAlignment();
+ int seqIndex = alignment.findIndex(results);
if (seqIndex == -1)
{
return false;
}
- SequenceI seq = av.alignment.getSequenceAt(seqIndex);
- int[] r = results.getResults(seq, 0,av.alignment.getWidth());
+ SequenceI seq = alignment.getSequenceAt(seqIndex);
+ int[] r = results.getResults(seq, 0,alignment.getWidth());
if (r == null)
{
if (av.applet.debug) {// DEBUG
int startv, endv, starts, ends, width;
int start=-1;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
start = av.getColumnSelection().findColumnPosition(ostart);
end = av.getColumnSelection().findColumnPosition(end);
if (start == end)
{
- if (!scrollToNearest && !av.colSel.isVisible(ostart))
+ if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
{
// don't scroll - position isn't visible
return false;
|| (av.getEndRes() < start)
|| ((av.getStartSeq() > seqIndex) || (av.getEndSeq() < seqIndex)))
{
- if (start > av.alignment.getWidth() - hextent)
+ if (start > av.getAlignment().getWidth() - hextent)
{
- start = av.alignment.getWidth() - hextent;
+ start = av.getAlignment().getWidth() - hextent;
if (start < 0)
{
start = 0;
}
}
- if (seqIndex > av.alignment.getHeight() - vextent)
+ if (seqIndex > av.getAlignment().getHeight() - vextent)
{
- seqIndex = av.alignment.getHeight() - vextent;
+ seqIndex = av.getAlignment().getHeight() - vextent;
if (seqIndex < 0)
{
seqIndex = 0;
public void setScrollValues(int x, int y)
{
- int width = av.alignment.getWidth();
- int height = av.alignment.getHeight();
+ int width = av.getAlignment().getWidth();
+ int height = av.getAlignment().getHeight();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
width = av.getColumnSelection().findColumnPosition(width);
}
av.setStartSeq(y);
int endSeq = y + vextent;
- if (endSeq > av.alignment.getHeight())
+ if (endSeq > av.getAlignment().getHeight())
{
- endSeq = av.alignment.getHeight();
+ endSeq = av.getAlignment().getHeight();
}
av.setEndSeq(endSeq);
if (av.getWrapAlignment())
{
- int maxwidth = av.alignment.getWidth();
+ int maxwidth = av.getAlignment().getWidth();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
// remove old automatic annotation
// add any new annotation
- Vector gr = av.alignment.getGroups(); // OrderedBy(av.alignment.getSequencesArray());
+ Vector gr = av.getAlignment().getGroups(); // OrderedBy(av.alignment.getSequencesArray());
// intersect alignment annotation with alignment groups
- AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aan = av.getAlignment().getAlignmentAnnotation();
Hashtable oldrfs = new Hashtable();
if (aan != null)
{
if (aan[an].autoCalculated && aan[an].groupRef != null)
{
oldrfs.put(aan[an].groupRef, aan[an].groupRef);
- av.alignment.deleteAnnotation(aan[an]);
+ av.getAlignment().deleteAnnotation(aan[an]);
aan[an] = null;
}
}
if (conv)
{
updateCalcs = true;
- av.alignment.addAnnotation(sg.getConservationRow(), 0);
+ av.getAlignment().addAnnotation(sg.getConservationRow(), 0);
}
if (cons)
{
updateCalcs = true;
- av.alignment.addAnnotation(sg.getConsensus(), 0);
+ av.getAlignment().addAnnotation(sg.getConsensus(), 0);
}
// refresh the annotation rows
if (updateCalcs)
@Override
public AlignmentI getAlignment()
{
- return av.alignment;
+ return av.getAlignment();
}
@Override
public StructureSelectionManager getStructureSelectionManager()
}
oldcs = av.getGlobalColourScheme();
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
oldgroupColours = new Hashtable();
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
slider.addAdjustmentListener(this);
slider.addMouseListener(this);
- if (av.alignment.getAlignmentAnnotation() == null)
+ if (av.getAlignment().getAlignmentAnnotation() == null)
{
return;
}
Vector list = new Vector();
int index = 1;
- for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
+ for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
{
- String label = av.alignment.getAlignmentAnnotation()[i].label;
+ String label = av.getAlignment().getAlignmentAnnotation()[i].label;
if (!list.contains(label))
list.addElement(label);
else
return;
}
- currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations
+ currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations
.getSelectedIndex()];
int aboveThreshold = -1;
av.setGlobalColourScheme(acg);
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
void reset()
{
av.setGlobalColourScheme(oldcs);
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
int getSelectedRow(int y)
{
int row = -2;
- AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
public void actionPerformed(ActionEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (evt.getActionCommand().equals(ADDNEW))
{
AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", null,
- new Annotation[ap.av.alignment.getWidth()]);
+ new Annotation[ap.av.getAlignment().getWidth()]);
if (!editLabelDescription(newAnnotation))
{
return;
}
- ap.av.alignment.addAnnotation(newAnnotation);
- ap.av.alignment.setAnnotationIndex(newAnnotation, 0);
+ ap.av.getAlignment().addAnnotation(newAnnotation);
+ ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
}
else if (evt.getActionCommand().equals(EDITNAME))
{
if (row > -1)
{
- ParseHtmlBodyAndLinks phb = new ParseHtmlBodyAndLinks(av.alignment.getAlignmentAnnotation()[row].getDescription(true), true, "\n");
+ ParseHtmlBodyAndLinks phb = new ParseHtmlBodyAndLinks(av.getAlignment().getAlignmentAnnotation()[row].getDescription(true), true, "\n");
if (tooltip == null)
{
tooltip = new Tooltip(phb.getNonHtmlContent(), this);
if (start>-1 && start != end)
{
// Swap these annotations
- AlignmentAnnotation startAA = ap.av.alignment
+ AlignmentAnnotation startAA = ap.av.getAlignment()
.getAlignmentAnnotation()[start];
if (end == -1)
{
- end = ap.av.alignment.getAlignmentAnnotation().length - 1;
+ end = ap.av.getAlignment().getAlignmentAnnotation().length - 1;
}
- AlignmentAnnotation endAA = ap.av.alignment
+ AlignmentAnnotation endAA = ap.av.getAlignment()
.getAlignmentAnnotation()[end];
- ap.av.alignment.getAlignmentAnnotation()[end] = startAA;
- ap.av.alignment.getAlignmentAnnotation()[start] = endAA;
+ ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA;
+ ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA;
}
}
resizePanel = false;
// todo: move below to mouseClicked ?
selectedRow = getSelectedRow(evt.getY() + scrollOffset);
- AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
// DETECT RIGHT MOUSE BUTTON IN AWT
if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
jalview.appletgui.AlignFrame.copiedSequences.append(sq.getName() + "\t"
+ sq.getStart() + "\t" + sq.getEnd() + "\t"
+ sq.getSequenceAsString() + "\n");
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector();
for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++)
g.translate(0, -scrollOffset);
g.setColor(Color.black);
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
int y = 0, fy = g.getFont().getSize();
int x = 0, offset;
*/
public void actionPerformed(ActionEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
return;
}
String label = "";
- if (av.colSel != null && av.colSel.size() > 0
- && anot[av.colSel.getMin()] != null)
+ if (av.getColumnSelection() != null && av.getColumnSelection().size() > 0
+ && anot[av.getColumnSelection().getMin()] != null)
label = anot[av.getColumnSelection().getMin()].displayCharacter;
if (evt.getActionCommand().equals(REMOVE))
{
int index = av.getColumnSelection().columnAt(i);
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
if (anot[index] == null)
{
int index = av.getColumnSelection().columnAt(i);
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
if (anot[index] == null)
{
int index = av.getColumnSelection().columnAt(i);
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
if (anot[index] == null)
public void mousePressed(MouseEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
return;
{
if (graphStretch > -1)
{
- av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
+ av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
- evt.getY();
- if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
+ if (av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight < 0)
{
- av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
+ av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0;
}
graphStretchY = evt.getY();
calcPanelHeight();
public void mouseMoved(MouseEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
return;
int res = evt.getX() / av.getCharWidth() + av.getStartRes();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
public int calcPanelHeight()
{
// setHeight of panels
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
int height = 0;
if (aa != null)
{
if (activeRow == -1)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
return;
public void fastPaint(int horizontal)
{
- if (horizontal == 0 || av.alignment.getAlignmentAnnotation() == null
- || av.alignment.getAlignmentAnnotation().length < 1)
+ if (horizontal == 0 || av.getAlignment().getAlignmentAnnotation() == null
+ || av.getAlignment().getAlignmentAnnotation().length < 1)
{
repaint();
return;
fm = g.getFontMetrics();
}
- if ((av.alignment.getAlignmentAnnotation() == null)
- || (av.alignment.getAlignmentAnnotation().length < 1))
+ if ((av.getAlignment().getAlignmentAnnotation() == null)
+ || (av.getAlignment().getAlignmentAnnotation().length < 1))
{
g.setColor(Color.white);
g.fillRect(0, 0, getSize().width, getSize().height);
else if (annotationImport)
{
if (new AnnotationFile().readAnnotationFile(
- alignFrame.viewport.alignment, textarea.getText(),
+ alignFrame.viewport.getAlignment(), textarea.getText(),
jalview.io.AppletFormatAdapter.PASTE))
{
alignFrame.alignPanel.fontChanged();
av.featuresDisplayed = new Hashtable();
Vector allfeatures = new Vector();
minmax = new Hashtable();
-
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ AlignmentI alignment=av.getAlignment();
+ for (int i = 0; i < alignment.getHeight(); i++)
{
- SequenceFeature[] features = av.alignment.getSequenceAt(i)
+ SequenceFeature[] features = alignment.getSequenceAt(i)
.getSequenceFeatures();
if (features == null)
ArrayList allGroups = new ArrayList();
SequenceFeature[] tmpfeatures;
String group;
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ AlignmentI alignment=av.getAlignment();
+ for (int i = 0; i < alignment.getHeight(); i++)
{
- if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+ if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
{
continue;
}
alignmentHasFeatures = true;
- tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+ tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
int index = 0;
while (index < tmpfeatures.length)
{
Vector allFeatures = new Vector();
SequenceFeature[] tmpfeatures;
String group;
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ AlignmentI alignment=av.getAlignment();
+ for (int i = 0; i < alignment.getHeight(); i++)
{
- if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+ if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
{
continue;
}
alignmentHasFeatures = true;
- tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+ tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
int index = 0;
while (index < tmpfeatures.length)
{
SequenceFeature[] tmpfeatures;
String group = null, type;
Vector visibleChecks = new Vector();
-
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ AlignmentI alignment=av.getAlignment();
+ for (int i = 0; i < alignment.getHeight(); i++)
{
- if (av.alignment.getSequenceAt(i).getSequenceFeatures() == null)
+ if (alignment.getSequenceAt(i).getSequenceFeatures() == null)
{
continue;
}
- tmpfeatures = av.alignment.getSequenceAt(i).getSequenceFeatures();
+ tmpfeatures = alignment.getSequenceAt(i).getSequenceFeatures();
int index = 0;
while (index < tmpfeatures.length)
{
((i - starty) * charHeight) + ypos + charHeight
- (charHeight / 5));
- if (av.hasHiddenRows && av.showHiddenMarkers)
+ if (av.hasHiddenRows() && av.showHiddenMarkers)
{
drawMarker(i, starty, ypos);
}
if (av.getWrapAlignment())
{
- int maxwidth = av.alignment.getWidth();
- int alheight = av.alignment.getHeight();
+ int maxwidth = av.getAlignment().getWidth();
+ int alheight = av.getAlignment().getHeight();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
for (int i = starty; i < alheight; i++)
{
- SequenceI s = av.alignment.getSequenceAt(i);
+ SequenceI s = av.getAlignment().getSequenceAt(i);
gg.setFont(italic);
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
setHiddenFont(s);
}
for (int i = starty; i < endy; i++)
{
- seq = av.alignment.getSequenceAt(i);
+ seq = av.getAlignment().getSequenceAt(i);
if (seq == null)
{
continue;
}
gg.setFont(italic);
// boolean isrep=false;
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
// isrep =
setHiddenFont(seq);
(((i - starty) * av.charHeight) + av.charHeight)
- (av.charHeight / 5));
- if (av.hasHiddenRows && av.showHiddenMarkers)
+ if (av.hasHiddenRows() && av.showHiddenMarkers)
{
drawMarker(i, starty, 0);
}
void drawMarker(int i, int starty, int yoffset)
{
- SequenceI[] hseqs = av.alignment.getHiddenSequences().hiddenSequences;
+ SequenceI[] hseqs = av.getAlignment().getHiddenSequences().hiddenSequences;
// Use this method here instead of calling hiddenSeq adjust
// 3 times.
int hSize = hseqs.length;
Font bold = new Font(av.getFont().getName(), Font.BOLD, av.getFont()
.getSize());
- if (av.hiddenRepSequences != null
- && av.hiddenRepSequences.containsKey(seq))
+ if (av.getHiddenRepSequences() != null
+ && av.getHiddenRepSequences().containsKey(seq))
{
gg.setFont(bold);
return true;
}
if (mouseDragging && e.getY() >= getSize().height
- && av.alignment.getHeight() > av.getEndSeq())
+ && av.getAlignment().getHeight() > av.getEndSeq())
{
scrollThread = new ScrollThread(false);
}
{
av.setSelectionGroup(new SequenceGroup());
av.getSelectionGroup().setStartRes(0);
- av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+ av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
if (e.isShiftDown() && lastid != -1)
return;
}
- int index = av.alignment.findIndex((SequenceI) found.elementAt(0));
+ int index = av.getAlignment().findIndex((SequenceI) found.elementAt(0));
// do we need to scroll the panel?
if (av.getStartSeq() > index || av.getEndSeq() < index)
{
selectSeqs(lastid - 1, seq);
}
- else if (seq > lastid && seq < av.alignment.getHeight())
+ else if (seq > lastid && seq < av.getAlignment().getHeight())
{
selectSeqs(lastid + 1, seq);
}
*/
package jalview.appletgui;
+import jalview.datamodel.AlignmentI;
+
import java.awt.*;
import java.awt.event.*;
sr.forOverview = true;
fr = new FeatureRenderer(av);
fr.overview = true;
-
+
// scale the initial size of overviewpanel to shape of alignment
- float initialScale = (float) av.alignment.getWidth()
- / (float) av.alignment.getHeight();
+ float initialScale = (float) av.getAlignment().getWidth()
+ / (float) av.getAlignment().getHeight();
- if (av.hconsensus == null)
+ if (av.getSequenceConsensusHash() == null)
{
graphHeight = 0;
}
- if (av.alignment.getWidth() > av.alignment.getHeight())
+ if (av.getAlignment().getWidth() > av.getAlignment().getHeight())
{
// wider
width = 400;
if (boxX > (width - boxWidth))
{
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
// Try smallest possible box
boxWidth = (int) ((av.endRes - av.startRes + 1) * av.getCharWidth() * scalew);
int col = (int) (boxX / scalew / av.getCharWidth());
int row = (int) (boxY / scaleh / av.getCharHeight());
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
if (!av.getColumnSelection().isVisible(col))
{
col = av.getColumnSelection().findColumnPosition(col);
}
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(
+ row = av.getAlignment().getHiddenSequences().findIndexWithoutHiddenSeqs(
row);
}
public void run()
{
miniMe = null;
- int alwidth = av.alignment.getWidth();
- int alheight = av.alignment.getHeight();
+ int alwidth = av.getAlignment().getWidth();
+ int alheight = av.getAlignment().getHeight();
if (av.showSequenceFeatures)
{
int row, col, sameRow = 0, sameCol = 0;
jalview.datamodel.SequenceI seq;
boolean hiddenRow = false;
+ AlignmentI alignment=av.getAlignment();
for (row = 0; row <= sequencesHeight; row++)
{
if ((int) (row * sampleRow) == lastrow)
}
hiddenRow = false;
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow);
+ seq = alignment.getHiddenSequences().getHiddenSequence(lastrow);
if (seq == null)
{
- int index = av.alignment.getHiddenSequences()
+ int index = alignment.getHiddenSequences()
.findIndexWithoutHiddenSeqs(lastrow);
- seq = av.alignment.getSequenceAt(index);
+ seq = alignment.getSequenceAt(index);
}
else
{
}
else
{
- seq = av.alignment.getSequenceAt(lastrow);
+ seq = alignment.getSequenceAt(lastrow);
}
for (col = 0; col < width; col++)
}
if (hiddenRow
- || (av.hasHiddenColumns && !av.getColumnSelection()
+ || (av.hasHiddenColumns() && !av.getColumnSelection()
.isVisible(lastcol)))
{
color = color.darker().darker();
sameRow = 1;
}
- if (av.conservation != null)
+ if (av.getAlignmentConservationAnnotation()!= null)
{
for (col = 0; col < width; col++)
{
lastcol = (int) (col * sampleCol);
{
mg.translate(col, sequencesHeight);
- ap.annotationPanel.renderer.drawGraph(mg, av.conservation,
+ ap.annotationPanel.renderer.drawGraph(mg, av.getAlignmentConservationAnnotation(),
(int) (sampleCol) + 1, graphHeight,
(int) (col * sampleCol), (int) (col * sampleCol) + 1);
mg.translate(-col, -sequencesHeight);
public void setBoxPosition()
{
- int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth();
- int fullsizeHeight = (av.alignment.getHeight() + av.alignment
+ int fullsizeWidth = av.getAlignment().getWidth() * av.getCharWidth();
+ int fullsizeHeight = (av.getAlignment().getHeight() + av.getAlignment()
.getHiddenSequences().getSize()) * av.getCharHeight();
int startRes = av.getStartRes();
int endRes = av.getEndRes();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
int startSeq = av.startSeq;
int endSeq = av.endSeq;
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- startSeq = av.alignment.getHiddenSequences().adjustForHiddenSeqs(
+ startSeq = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(
startSeq);
- endSeq = av.alignment.getHiddenSequences()
+ endSeq = av.getAlignment().getHiddenSequences()
.adjustForHiddenSeqs(endSeq);
}
boxX = (int) (startRes * av.getCharWidth() * scalew);
boxY = (int) (startSeq * av.getCharHeight() * scaleh);
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
}
seqstrings = av.getAlignmentView(av.getSelectionGroup() != null);
if (av.getSelectionGroup() == null)
{
- seqs = av.alignment.getSequencesArray();
+ seqs = av.getAlignment().getSequencesArray();
}
else
{
- seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+ seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
SeqCigar sq[] = seqstrings.getSequences();
int length = sq[0].getWidth();
else if (validateSequences && comp instanceof AlignmentPanel
&& source instanceof AlignmentPanel)
{
- validateSequences(((AlignmentPanel) source).av.alignment,
- ((AlignmentPanel) comp).av.alignment);
+ validateSequences(((AlignmentPanel) source).av.getAlignment(),
+ ((AlignmentPanel) comp).av.getAlignment());
}
if (comp instanceof AlignmentPanel && alignmentChanged)
if (ap.av.getSelectionGroup() == null)
{
- seqs = ap.av.alignment.getSequencesArray();
+ seqs = ap.av.getAlignment().getSequencesArray();
}
else
{
- seqs = ap.av.getSelectionGroup().getSequencesInOrder(ap.av.alignment);
+ seqs = ap.av.getSelectionGroup().getSequencesInOrder(ap.av.getAlignment());
}
float scores[][] = new float[seqs.length][seqs.length];
double totscore = 0;
int count = ap.av.getSelectionGroup().getSize();
- String type = (ap.av.alignment.isNucleotide()) ? AlignSeq.DNA
+ String type = (ap.av.getAlignment().isNucleotide()) ? AlignSeq.DNA
: AlignSeq.PEP;
Sequence seq;
public class RedundancyPanel extends SliderPanel implements Runnable,
WindowListener
{
- AlignmentPanel ap;
-
Stack historyList = new Stack(); // simpler than synching with alignFrame.
float[] redundancy;
if ((sg != null) && (sg.getSize() >= 1))
{
- originalSequences = sg.getSequencesInOrder(ap.av.alignment);
+ originalSequences = sg.getSequencesInOrder(ap.av.getAlignment());
start = sg.getStartRes();
end = sg.getEndRes();
}
else
{
- originalSequences = ap.av.alignment.getSequencesArray();
+ originalSequences = ap.av.getAlignment().getSequencesArray();
start = 0;
- end = ap.av.alignment.getWidth();
+ end = ap.av.getAlignment().getWidth();
}
height = originalSequences.length;
}
EditCommand cut = new EditCommand("Remove Redundancy",
- EditCommand.CUT, deleted, 0, width, ap.av.alignment);
-
+ EditCommand.CUT, deleted, 0, width, ap.av.getAlignment());
+ AlignmentI alignment=ap.av.getAlignment();
for (int i = 0; i < del.size(); i++)
{
- ap.av.alignment.deleteSequence(deleted[i]);
+ alignment.deleteSequence(deleted[i]);
PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
if (sg != null)
{
if (av.getSelectionGroup() != null)
{
av.getSelectionGroup().addOrRemove(found, true);
- av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+ av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
else
{
av.setSelectionGroup(new SequenceGroup());
av.getSelectionGroup().addOrRemove(found, true);
- av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+ av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
PaintRefresher.Refresh(this, av.getSequenceSetId());
int x = (evt.getX() / av.getCharWidth()) + av.getStartRes();
final int res;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(x);
}
{
av.hideColumns(res, res);
if (av.getSelectionGroup() != null
- && av.getSelectionGroup().getSize() == av.alignment
+ && av.getSelectionGroup().getSize() == av.getAlignment()
.getHeight())
{
av.setSelectionGroup(null);
av.getColumnSelection().addElement(res);
SequenceGroup sg = new SequenceGroup();
- for (int i = 0; i < av.alignment.getSequences().size(); i++)
+ for (int i = 0; i < av.getAlignment().getSequences().size(); i++)
{
- sg.addSequence(av.alignment.getSequenceAt(i), false);
+ sg.addSequence(av.getAlignment().getSequenceAt(i), false);
}
sg.setStartRes(res);
int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
- if (res > av.alignment.getWidth())
+ if (res > av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
res = 0;
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
- if (res > av.alignment.getWidth())
+ if (res > av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
if (res < min)
public void mouseMoved(MouseEvent evt)
{
- if (!av.hasHiddenColumns)
+ if (!av.hasHiddenColumns())
{
return;
}
for (int i = 0; i < cs.size(); i++)
{
int sel = cs.columnAt(i);
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
sel = av.getColumnSelection().findColumnPosition(sel);
}
}
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
gg.setColor(Color.blue);
int res;
for (int i = scalestartx; i < endx; i += 10)
{
int value = i;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
value = av.getColumnSelection().adjustForHiddenColumns(value);
}
{
FontMetrics fm = getFontMetrics(av.getFont());
ypos += av.charHeight;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
startx = av.getColumnSelection().adjustForHiddenColumns(startx);
endx = av.getColumnSelection().adjustForHiddenColumns(endx);
}
- int maxwidth = av.alignment.getWidth();
- if (av.hasHiddenColumns)
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
// WEST SCALE
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
- SequenceI seq = av.alignment.getSequenceAt(i);
+ SequenceI seq = av.getAlignment().getSequenceAt(i);
int index = startx;
int value = -1;
continue;
}
- value = av.alignment.getSequenceAt(i).findPosition(index);
+ value = av.getAlignment().getSequenceAt(i).findPosition(index);
break;
}
{
ypos += av.charHeight;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
endx = av.getColumnSelection().adjustForHiddenColumns(endx);
}
SequenceI seq;
// EAST SCALE
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
- seq = av.alignment.getSequenceAt(i);
+ seq = av.getAlignment().getSequenceAt(i);
int index = endx;
int value = -1;
String mask = "0";
int maxWidth = 0;
int tmp;
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ AlignmentI alignment=av.getAlignment();
+ for (int i = 0; i < alignment.getHeight(); i++)
{
- tmp = av.alignment.getSequenceAt(i).getEnd();
+ tmp = alignment.getSequenceAt(i).getEnd();
if (tmp > maxWidth)
{
maxWidth = tmp;
int endx;
int ypos = hgap;
- int maxwidth = av.alignment.getWidth() - 1;
+ int maxwidth = av.getAlignment().getWidth() - 1;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
{
drawNorthScale(g, startRes, endx, ypos);
}
- if (av.hasHiddenColumns && av.showHiddenMarkers)
+ if (av.hasHiddenColumns() && av.showHiddenMarkers)
{
g.setColor(Color.blue);
int res;
void drawPanel(Graphics g1, int startRes, int endRes, int startSeq,
int endSeq, int offset)
{
- if (!av.hasHiddenColumns)
+ if (!av.hasHiddenColumns())
{
draw(g1, startRes, endRes, startSeq, endSeq, offset);
}
// ///////////////////////////
for (int i = startSeq; i < endSeq; i++)
{
- nextSeq = av.alignment.getSequenceAt(i);
+ nextSeq = av.getAlignment().getSequenceAt(i);
if (nextSeq == null)
{
continue;
}
- sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq),
+ sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
startRes, endRes, offset + ((i - startSeq) * av.charHeight));
if (av.showSequenceFeatures)
}
if (av.getSelectionGroup() != null
- || av.alignment.getGroups().size() > 0)
+ || av.getAlignment().getGroups().size() > 0)
{
drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset);
}
int ex = -1;
int groupIndex = -1;
- if ((group == null) && (av.alignment.getGroups().size() > 0))
+ if ((group == null) && (av.getAlignment().getGroups().size() > 0))
{
- group = (SequenceGroup) av.alignment.getGroups().elementAt(0);
+ group = (SequenceGroup) av.getAlignment().getGroups().elementAt(0);
groupIndex = 0;
}
boolean inGroup = false;
int top = -1;
int bottom = -1;
- int alHeight = av.alignment.getHeight() - 1;
+ int alHeight = av.getAlignment().getHeight() - 1;
for (i = startSeq; i < endSeq; i++)
{
if ((sx <= (endRes - startRes) * av.charWidth)
&& group.getSequences(null).contains(
- av.alignment.getSequenceAt(i)))
+ av.getAlignment().getSequenceAt(i)))
{
if ((bottom == -1)
&& (i >= alHeight || !group.getSequences(null)
- .contains(av.alignment.getSequenceAt(i + 1))))
+ .contains(av.getAlignment().getSequenceAt(i + 1))))
{
bottom = sy + av.charHeight;
}
{
if (((top == -1) && (i == 0))
|| !group.getSequences(null).contains(
- av.alignment.getSequenceAt(i - 1)))
+ av.getAlignment().getSequenceAt(i - 1)))
{
top = sy;
}
groupIndex++;
- if (groupIndex >= av.alignment.getGroups().size())
+ if (groupIndex >= av.getAlignment().getGroups().size())
{
break;
}
- group = (SequenceGroup) av.alignment.getGroups().elementAt(
+ group = (SequenceGroup) av.getAlignment().getGroups().elementAt(
groupIndex);
- } while (groupIndex < av.alignment.getGroups().size());
+ } while (groupIndex < av.getAlignment().getGroups().size());
}
}
{
seqCanvas.cursorX += dx;
seqCanvas.cursorY += dy;
- if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX))
+ if (av.hasHiddenColumns() && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
{
int original = seqCanvas.cursorX - dx;
- int maxWidth = av.alignment.getWidth();
+ int maxWidth = av.getAlignment().getWidth();
- while (!av.colSel.isVisible(seqCanvas.cursorX)
+ while (!av.getColumnSelection().isVisible(seqCanvas.cursorX)
&& seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0)
{
seqCanvas.cursorX += dx;
}
if (seqCanvas.cursorX >= maxWidth
- || !av.colSel.isVisible(seqCanvas.cursorX))
+ || !av.getColumnSelection().isVisible(seqCanvas.cursorX))
{
seqCanvas.cursorX = original;
}
{
seqCanvas.cursorX = 0;
}
- else if (seqCanvas.cursorX > av.alignment.getWidth() - 1)
+ else if (seqCanvas.cursorX > av.getAlignment().getWidth() - 1)
{
- seqCanvas.cursorX = av.alignment.getWidth() - 1;
+ seqCanvas.cursorX = av.getAlignment().getWidth() - 1;
}
if (seqCanvas.cursorY < 0)
{
seqCanvas.cursorY = 0;
}
- else if (seqCanvas.cursorY > av.alignment.getHeight() - 1)
+ else if (seqCanvas.cursorY > av.getAlignment().getHeight() - 1)
{
- seqCanvas.cursorY = av.alignment.getHeight() - 1;
+ seqCanvas.cursorY = av.getAlignment().getHeight() - 1;
}
endEditing();
{
ap.scrollUp(false);
}
- while (seqCanvas.cursorX < av.colSel
+ while (seqCanvas.cursorX < av.getColumnSelection()
.adjustForHiddenColumns(av.startRes))
{
break;
}
}
- while (seqCanvas.cursorX > av.colSel
+ while (seqCanvas.cursorX > av.getColumnSelection()
.adjustForHiddenColumns(av.endRes))
{
if (!ap.scrollRight(true))
}
}
}
- setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY),
+ setStatusMessage(av.getAlignment().getSequenceAt(seqCanvas.cursorY),
seqCanvas.cursorX, seqCanvas.cursorY);
seqCanvas.repaint();
if (av.getSelectionGroup() != null)
{
- SequenceGroup sg = av.selectionGroup;
+ SequenceGroup sg = av.getSelectionGroup();
// Find the top and bottom of this group
- int min = av.alignment.getHeight(), max = 0;
+ int min = av.getAlignment().getHeight(), max = 0;
for (int i = 0; i < sg.getSize(); i++)
{
- int index = av.alignment.findIndex(sg.getSequenceAt(i));
+ int index = av.getAlignment().findIndex(sg.getSequenceAt(i));
if (index > max)
{
max = index;
sg.getSequences(null).removeAllElements();
for (int i = min; i < max; i++)
{
- sg.addSequence(av.alignment.getSequenceAt(i), false);
+ sg.addSequence(av.getAlignment().getSequenceAt(i), false);
}
}
}
+ sequence.getName());
Object obj = null;
- if (av.alignment.isNucleotide())
+ if (av.getAlignment().isNucleotide())
{
obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res)
+ "");
public void mouseClicked(MouseEvent evt)
{
- SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
+ SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
if (evt.getClickCount() > 1)
{
if (av.getSelectionGroup()!=null && av.getSelectionGroup().getSize() == 1
res = (x / av.getCharWidth()) + av.getStartRes();
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
y -= hgap;
seq = Math.min((y % cHeight) / av.getCharHeight(),
- av.alignment.getHeight() - 1);
+ av.getAlignment().getHeight() - 1);
if (seq < 0)
{
seq = -1;
else
{
seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(),
- av.alignment.getHeight() - 1);
+ av.getAlignment().getHeight() - 1);
if (seq < 0)
{
seq = -1;
+ sequence.getName());
Object obj = null;
- if (av.alignment.isNucleotide())
+ if (av.getAlignment().isNucleotide())
{
obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res)
+ "");
ap.alignFrame.statusBar.setText(text.toString());
StringBuffer tooltipText = new StringBuffer();
- SequenceGroup[] groups = av.alignment.findAllGroups(sequence);
+ SequenceGroup[] groups = av.getAlignment().findAllGroups(sequence);
if (groups != null)
{
for (int g = 0; g < groups.length; g++)
boolean fixedColumns = false;
SequenceGroup sg = av.getSelectionGroup();
- SequenceI seq = av.alignment.getSequenceAt(startseq);
+ SequenceI seq = av.getAlignment().getSequenceAt(startseq);
- if (!groupEditing && av.hasHiddenRows)
+ if (!groupEditing && av.hasHiddenRows())
{
- if (av.hiddenRepSequences != null
- && av.hiddenRepSequences.containsKey(seq))
+ if (av.getHiddenRepSequences() != null
+ && av.getHiddenRepSequences().containsKey(seq))
{
- sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+ sg = (SequenceGroup) av.getHiddenRepSequences().get(seq);
groupEditing = true;
}
}
// Are we editing within a selection group?
if (groupEditing
- || (sg != null && sg.getSequences(av.hiddenRepSequences)
+ || (sg != null && sg.getSequences(av.getHiddenRepSequences())
.contains(seq)))
{
fixedColumns = true;
// but the sequence represents a group
if (sg == null)
{
- if (av.hiddenRepSequences == null
- || !av.hiddenRepSequences.containsKey(seq))
+ if (av.getHiddenRepSequences() == null
+ || !av.getHiddenRepSequences().containsKey(seq))
{
endEditing();
return;
}
- sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+ sg = (SequenceGroup) av.getHiddenRepSequences().get(seq);
}
fixedLeft = sg.getStartRes();
}
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
fixedColumns = true;
int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres);
if (groupEditing)
{
- Vector vseqs = sg.getSequences(av.hiddenRepSequences);
+ Vector vseqs = sg.getSequences(av.getHiddenRepSequences());
int g, groupSize = vseqs.size();
SequenceI[] groupSeqs = new SequenceI[groupSize];
for (g = 0; g < groupSeqs.length; g++)
// If the user has selected the whole sequence, and is dragging to
// the right, we can still extend the alignment and selectionGroup
if (sg.getStartRes() == 0 && sg.getEndRes() == fixedRight
- && sg.getEndRes() == av.alignment.getWidth() - 1)
+ && sg.getEndRes() == av.getAlignment().getWidth() - 1)
{
- sg.setEndRes(av.alignment.getWidth() + startres - lastres);
+ sg.setEndRes(av.getAlignment().getWidth() + startres - lastres);
fixedRight = sg.getEndRes();
}
if (!blank)
{
- if (sg.getSize() == av.alignment.getHeight())
+ if (sg.getSize() == av.getAlignment().getHeight())
{
- if ((av.hasHiddenColumns && startres < av.getColumnSelection()
+ if ((av.hasHiddenColumns() && startres < av.getColumnSelection()
.getHiddenBoundaryRight(startres)))
{
endEditing();
return;
}
- int alWidth = av.alignment.getWidth();
- if (av.hasHiddenRows)
+ int alWidth = av.getAlignment().getWidth();
+ if (av.hasHiddenRows())
{
- int hwidth = av.alignment.getHiddenSequences().getWidth();
+ int hwidth = av.getAlignment().getHiddenSequences().getWidth();
if (hwidth > alWidth)
{
alWidth = hwidth;
else
{
editCommand.appendEdit(EditCommand.INSERT_GAP, groupSeqs,
- startres, startres - lastres, av.alignment, true);
+ startres, startres - lastres, av.getAlignment(), true);
}
}
else
else
{
editCommand.appendEdit(EditCommand.DELETE_GAP, groupSeqs,
- startres, lastres - startres, av.alignment, true);
+ startres, lastres - startres, av.getAlignment(), true);
}
}
else
{
editCommand.appendEdit(EditCommand.INSERT_GAP, new SequenceI[]
- { seq }, lastres, startres - lastres, av.alignment, true);
+ { seq }, lastres, startres - lastres, av.getAlignment(), true);
}
}
else
if (max > 0)
{
editCommand.appendEdit(EditCommand.DELETE_GAP, new SequenceI[]
- { seq }, startres, max, av.alignment, true);
+ { seq }, startres, max, av.getAlignment(), true);
}
}
}
}
editCommand.appendEdit(EditCommand.DELETE_GAP, seq, blankColumn, 1,
- av.alignment, true);
+ av.getAlignment(), true);
- editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.alignment,
+ editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.getAlignment(),
true);
}
void deleteChar(int j, SequenceI[] seq, int fixedColumn)
{
- editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.alignment,
+ editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.getAlignment(),
true);
editCommand.appendEdit(EditCommand.INSERT_GAP, seq, fixedColumn, 1,
- av.alignment, true);
+ av.getAlignment(), true);
}
// ////////////////////////////////////////
if (stretchGroup == null)
{
- stretchGroup = av.alignment.findGroup(sequence);
+ stretchGroup = av.getAlignment().findGroup(sequence);
if (stretchGroup != null && res > stretchGroup.getStartRes()
&& res < stretchGroup.getEndRes())
{
{
stretchGroup = null;
- SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence);
+ SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence);
if (allGroups != null)
{
if (stretchGroup.cs instanceof ClustalxColourScheme)
{
((ClustalxColourScheme) stretchGroup.cs).resetClustalX(
- stretchGroup.getSequences(av.hiddenRepSequences),
+ stretchGroup.getSequences(av.getHiddenRepSequences()),
stretchGroup.getWidth());
}
mouseDragging = true;
- if (y > av.alignment.getHeight())
+ if (y > av.getAlignment().getHeight())
{
- y = av.alignment.getHeight() - 1;
+ y = av.getAlignment().getHeight() - 1;
}
- if (res >= av.alignment.getWidth())
+ if (res >= av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
if (stretchGroup.getEndRes() == res)
dragDirection = -1;
}
- while ((y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight()))
+ while ((y != oldSeq) && (oldSeq > -1) && (y < av.getAlignment().getHeight()))
{
// This routine ensures we don't skip any sequences, as the
// selection is quite slow.
}
if (mouseDragging && evt.getY() >= getSize().height
- && av.alignment.getHeight() > av.getEndSeq())
+ && av.getAlignment().getHeight() > av.getEndSeq())
{
running = ap.scrollUp(false);
}
// rules are: colsel is copied if there is a real intersection between
// sequence selection
boolean repaint = false, copycolsel = true;
- if (av.selectionGroup == null || !av.isSelectionGroupChanged())
+ if (av.getSelectionGroup() == null || !av.isSelectionGroupChanged(true))
{
SequenceGroup sgroup = null;
if (seqsel != null && seqsel.getSize()>0)
{
- if (av.alignment == null)
+ if (av.getAlignment() == null)
{
System.out
.println("Selection message: alignviewport av SeqSetId="
+ " 's alignment is NULL! returning immediatly.");
return;
}
- sgroup = seqsel.intersect(av.alignment,
- (av.hasHiddenRows) ? av.hiddenRepSequences : null);
+ sgroup = seqsel.intersect(av.getAlignment(),
+ (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
if ((sgroup == null || sgroup.getSize() == 0)
&& (colsel == null || colsel.size() == 0))
{
{
av.setSelectionGroup(null);
}
- repaint = av.isSelectionGroupChanged();
+ repaint = av.isSelectionGroupChanged(true);
}
- if (copycolsel && (av.colSel == null || !av.isColSelChanged()))
+ if (copycolsel && (av.getColumnSelection() == null || !av.isColSelChanged(true)))
{
// the current selection is unset or from a previous message
// so import the new colsel.
if (colsel == null || colsel.size() == 0)
{
- if (av.colSel != null)
+ if (av.getColumnSelection() != null)
{
- av.colSel.clear();
+ av.getColumnSelection().clear();
}
}
else
{
// TODO: shift colSel according to the intersecting sequences
- if (av.colSel == null)
+ if (av.getColumnSelection() == null)
{
- av.colSel = new ColumnSelection(colsel);
+ av.setColumnSelection(new ColumnSelection(colsel));
}
else
{
- av.colSel.setElementsFrom(colsel);
+ av.getColumnSelection().setElementsFrom(colsel);
}
}
- repaint |= av.isColSelChanged();
+ repaint |= av.isColSelChanged(true);
}
- if (copycolsel && av.hasHiddenColumns
- && (av.colSel == null || av.colSel.getHiddenColumns() == null))
+ if (copycolsel && av.hasHiddenColumns()
+ && (av.getColumnSelection() == null || av.getColumnSelection().getHiddenColumns() == null))
{
System.err.println("Bad things");
}
public Color getResidueBoxColour(SequenceI seq, int i)
{
- allGroups = av.alignment.findAllGroups(seq);
+ allGroups = av.getAlignment().findAllGroups(seq);
if (inCurrentSequenceGroup(i))
{
}
else if (av.getShowBoxes())
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
return resBoxColour;
public Color findSequenceColour(SequenceI seq, int i)
{
- allGroups = av.alignment.findAllGroups(seq);
+ allGroups = av.getAlignment().findAllGroups(seq);
drawBoxes(seq, i, i, 0);
return resBoxColour;
}
{
// cheat - use this if we have a consensus for each group: s =
// getDisplayChar(currentSequenceGroup.getConsensus(), i, s, '.');
- s = getDisplayChar(av.consensus, i, s, '.');
+ s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
}
}
else
graphics.setColor(resBoxColour);
}
}
- if (av.getShowunconserved())
+ if (av.getShowUnconserved())
{
- s = getDisplayChar(av.consensus, i, s, '.');
+ s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
}
}
conservationSlider.setTitle("Conservation Colour Increment (" + source
+ ")");
- if (ap.av.alignment.getGroups() != null)
+ if (ap.av.getAlignment().getGroups() != null)
{
sp.setAllGroupsCheckEnabled(true);
}
}
PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")");
- if (ap.av.alignment.getGroups() != null)
+ if (ap.av.getAlignment().getGroups() != null)
{
pid.setAllGroupsCheckEnabled(true);
}
if (allGroupsCheck.getState())
{
- allGroups = ap.av.alignment.getGroups();
+ allGroups = ap.av.getAlignment().getGroups();
groupIndex = allGroups.size() - 1;
}
else
av.setSelectionGroup(selected);
}
- selected.setEndRes(av.alignment.getWidth() - 1);
+ selected.setEndRes(av.getAlignment().getWidth() - 1);
selected.addOrRemove(sequence, true);
}
setColor(tree.getTopNode(), Color.black);
av.setSelectionGroup(null);
- av.alignment.deleteAllGroups();
+ av.getAlignment().deleteAllGroups();
av.sequenceColours = null;
colourGroups();
}
else
{
- cs = ColourSchemeProperty.getColour(sequences, av.alignment
+ cs = ColourSchemeProperty.getColour(sequences, av.getAlignment()
.getWidth(), ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
}
}
SequenceGroup sg = new SequenceGroup(sequences, "", cs, true, true,
- false, 0, av.alignment.getWidth() - 1);
+ false, 0, av.getAlignment().getWidth() - 1);
sg.setName("JTreeGroup:" + sg.hashCode());
sg.setIdColour(col);
}
- av.alignment.addGroup(sg);
+ av.getAlignment().addGroup(sg);
}
ap.updateAnnotation();
{
if (odata == null)
{
- tree = new NJTree(av.alignment.getSequencesArray(), newtree);
+ tree = new NJTree(av.getAlignment().getSequencesArray(), newtree);
}
else
{
- tree = new NJTree(av.alignment.getSequencesArray(), odata,
+ tree = new NJTree(av.getAlignment().getSequencesArray(), odata,
newtree);
}
if (av.getSelectionGroup() == null)
{
start = 0;
- end = av.alignment.getWidth();
- seqs = av.alignment.getSequencesArray();
+ end = av.getAlignment().getWidth();
+ seqs = av.getAlignment().getSequencesArray();
}
else
{
start = av.getSelectionGroup().getStartRes();
end = av.getSelectionGroup().getEndRes() + 1;
- seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+ seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
+++ /dev/null
-package jalview.datamodel;
-
-/**
- * base class holding visualization and analysis attributes for an active alignment view displayed in the GUI
- * @author jimp
- *
- */
-public class AlignmentViewport
-{
-
- /**
- * percentage gaps allowed in a column before all amino acid properties should be considered unconserved
- */
- int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
-
-
- public int getConsPercGaps()
- {
- return ConsPercGaps;
- }
-
-}
*/
void init()
{
- if (viewport.conservation == null)
+ if (viewport.getAlignmentConservationAnnotation()== null)
{
BLOSUM62Colour.setEnabled(false);
conservationMenuItem.setEnabled(false);
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
addServiceListeners();
- setGUINucleotide(viewport.alignment.isNucleotide());
+ setGUINucleotide(viewport.getAlignment().isNucleotide());
}
setMenusFromViewport(viewport);
if (newPanel)
{
- if (ap.av.padGaps)
+ if (ap.av.isPadGaps())
{
- ap.av.alignment.padGaps();
+ ap.av.getAlignment().padGaps();
}
ap.av.updateConservation(ap);
ap.av.updateConsensus(ap);
*/
void setMenusFromViewport(AlignViewport av)
{
- padGapsMenuitem.setSelected(av.padGaps);
+ padGapsMenuitem.setSelected(av.isPadGaps());
colourTextMenuItem.setSelected(av.showColourText);
abovePIDThreshold.setSelected(av.getAbovePIDThreshold());
conservationMenuItem.setSelected(av.getConservationSelected());
annotationPanelMenuItem.setState(av.showAnnotation);
viewBoxesMenuItem.setSelected(av.showBoxes);
viewTextMenuItem.setSelected(av.showText);
- showNonconservedMenuItem.setSelected(av.showUnconserved);
- showGroupConsensus.setSelected(av.showGroupConsensus);
- showGroupConservation.setSelected(av.showGroupConservation);
- showConsensusHistogram.setSelected(av.showConsensusHistogram);
- showSequenceLogo.setSelected(av.showSequenceLogo);
- normaliseSequenceLogo.setSelected(av.normaliseSequenceLogo);
+ showNonconservedMenuItem.setSelected(av.getShowUnconserved());
+ showGroupConsensus.setSelected(av.isShowGroupConsensus());
+ showGroupConservation.setSelected(av.isShowGroupConservation());
+ showConsensusHistogram.setSelected(av.isShowConsensusHistogram());
+ showSequenceLogo.setSelected(av.isShowSequenceLogo());
+ normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo());
setColourSelected(ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
autoCalculate.setSelected(av.autoCalculateConsensus);
sortByTree.setSelected(av.sortByTree);
listenToViewSelections.setSelected(av.followSelection);
- rnahelicesColour.setEnabled(av.alignment.hasRNAStructure());
+ rnahelicesColour.setEnabled(av.getAlignment().hasRNAStructure());
rnahelicesColour.setSelected(av.getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
setShowProductsEnabled();
String[] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
int reply = JOptionPane
.showInternalConfirmDialog(
}
FormatAdapter f = new FormatAdapter();
String output = f.formatSequences(format,
- (Alignment) viewport.alignment, // class cast exceptions will
+ (Alignment) viewport.getAlignment(), // class cast exceptions will
// occur in the distant future
- omitHidden, f.getCacheSuffixDefault(format), viewport.colSel);
+ omitHidden, f.getCacheSuffixDefault(format), viewport.getColumnSelection());
if (output == null)
{
{
String[] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
int reply = JOptionPane
.showInternalConfirmDialog(
try
{
cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
- viewport.alignment, omitHidden, viewport.colSel));
+ viewport.getAlignment(), omitHidden, viewport.getColumnSelection()));
Desktop.addInternalFrame(cap,
"Alignment output - " + e.getActionCommand(), 600, 500);
} catch (OutOfMemoryError oom)
{
new AnnotationExporter().exportAnnotations(
alignPanel,
- viewport.showAnnotation ? viewport.alignment
- .getAlignmentAnnotation() : null, viewport.alignment
+ viewport.showAnnotation ? viewport.getAlignment()
+ .getAlignmentAnnotation() : null, viewport.getAlignment()
.getGroups(),
- ((Alignment) viewport.alignment).alignmentProperties);
+ ((Alignment) viewport.getAlignment()).alignmentProperties);
}
public void associatedData_actionPerformed(ActionEvent e)
viewport.historyList.push(command);
viewport.redoList.clear();
updateEditMenuBar();
- viewport.hasHiddenColumns = (viewport.colSel != null
- && viewport.colSel.getHiddenColumns() != null && viewport.colSel
- .getHiddenColumns().size() > 0);
+ viewport.updateHiddenColumns();
+// viewport.hasHiddenColumns = (viewport.getColumnSelection() != null
+// && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+// .getHiddenColumns().size() > 0);
}
}
if (viewport != null)
{
return new AlignmentI[]
- { viewport.alignment };
+ { viewport.getAlignment() };
}
return null;
}
if (originalSource != null)
{
- originalSource.hasHiddenColumns = (viewport.colSel != null
- && viewport.colSel.getHiddenColumns() != null && viewport.colSel
- .getHiddenColumns().size() > 0);
+ if (originalSource!=viewport)
+ {
+ Cache.log.warn("Implementation worry: mismatch of viewport origin for undo");
+ }
+ originalSource.updateHiddenColumns();
+// originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
+// && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+// .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
- originalSource.alignment.getSequences());
+ originalSource.getAlignment().getSequences());
}
}
if (originalSource != null)
{
- originalSource.hasHiddenColumns = (viewport.colSel != null
- && viewport.colSel.getHiddenColumns() != null && viewport.colSel
- .getHiddenColumns().size() > 0);
+
+ if (originalSource!=viewport)
+ {
+ Cache.log.warn("Implementation worry: mismatch of viewport origin for redo");
+ }
+ originalSource.updateHiddenColumns();
+ //originalSource.hasHiddenColumns = (viewport.getColumnSelection() != null
+ // && viewport.getColumnSelection().getHiddenColumns() != null && viewport.getColumnSelection()
+ // .getHiddenColumns().size() > 0);
originalSource.firePropertyChange("alignment", null,
- originalSource.alignment.getSequences());
+ originalSource.getAlignment().getSequences());
}
}
{
if (comps.elementAt(i) instanceof AlignmentPanel)
{
- if (al == ((AlignmentPanel) comps.elementAt(i)).av.alignment)
+ if (al == ((AlignmentPanel) comps.elementAt(i)).av.getAlignment())
{
originalSource = ((AlignmentPanel) comps.elementAt(i)).av;
break;
// the current view against the closed view first
if (al != null)
{
- PaintRefresher.validateSequences(al, viewport.alignment);
+ PaintRefresher.validateSequences(al, viewport.getAlignment());
}
originalSource = viewport;
if (up)
{
- for (int i = 1; i < viewport.alignment.getHeight(); i++)
+ for (int i = 1; i < viewport.getAlignment().getHeight(); i++)
{
- SequenceI seq = viewport.alignment.getSequenceAt(i);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(i);
if (!sg.getSequences(null).contains(seq))
{
continue;
}
- SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
+ SequenceI temp = viewport.getAlignment().getSequenceAt(i - 1);
if (sg.getSequences(null).contains(temp))
{
continue;
}
- viewport.alignment.getSequences().setElementAt(temp, i);
- viewport.alignment.getSequences().setElementAt(seq, i - 1);
+ viewport.getAlignment().getSequences().setElementAt(temp, i);
+ viewport.getAlignment().getSequences().setElementAt(seq, i - 1);
}
}
else
{
- for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
+ for (int i = viewport.getAlignment().getHeight() - 2; i > -1; i--)
{
- SequenceI seq = viewport.alignment.getSequenceAt(i);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(i);
if (!sg.getSequences(null).contains(seq))
{
continue;
}
- SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
+ SequenceI temp = viewport.getAlignment().getSequenceAt(i + 1);
if (sg.getSequences(null).contains(temp))
{
continue;
}
- viewport.alignment.getSequences().setElementAt(temp, i);
- viewport.alignment.getSequences().setElementAt(seq, i + 1);
+ viewport.getAlignment().getSequences().setElementAt(temp, i);
+ viewport.getAlignment().getSequences().setElementAt(seq, i + 1);
}
}
Vector sg = new Vector();
if (viewport.cursorMode)
{
- sg.addElement(viewport.alignment
+ sg.addElement(viewport.getAlignment()
.getSequenceAt(alignPanel.seqPanel.seqCanvas.cursorY));
}
else if (viewport.getSelectionGroup() != null
- && viewport.getSelectionGroup().getSize() != viewport.alignment
+ && viewport.getSelectionGroup().getSize() != viewport.getAlignment()
.getHeight())
{
sg = viewport.getSelectionGroup().getSequences(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
}
if (sg.size() < 1)
Vector invertGroup = new Vector();
- for (int i = 0; i < viewport.alignment.getHeight(); i++)
+ for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
{
- if (!sg.contains(viewport.alignment.getSequenceAt(i)))
- invertGroup.add(viewport.alignment.getSequenceAt(i));
+ if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
+ invertGroup.add(viewport.getAlignment().getSequenceAt(i));
}
SequenceI[] seqs1 = new SequenceI[sg.size()];
SequenceI[] seqs = viewport.getSelectionAsNewSequence();
String[] omitHidden = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
omitHidden = viewport.getViewAsString(true);
}
}
Vector hiddenColumns = null;
- if (viewport.hasHiddenColumns)
+ if (viewport.hasHiddenColumns())
{
hiddenColumns = new Vector();
int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
}
Desktop.jalviewClipboard = new Object[]
- { seqs, viewport.alignment.getDataset(), hiddenColumns };
+ { seqs, viewport.getAlignment().getDataset(), hiddenColumns };
statusBar.setText("Copied " + seqs.length + " sequences to clipboard.");
}
}
// If the cut affects all sequences, remove highlighted columns
- if (sg.getSize() == viewport.alignment.getHeight())
+ if (sg.getSize() == viewport.getAlignment().getHeight())
{
viewport.getColumnSelection().removeElements(sg.getStartRes(),
sg.getEndRes() + 1);
*/
addHistoryItem(new EditCommand("Cut Sequences", EditCommand.CUT, cut,
sg.getStartRes(), sg.getEndRes() - sg.getStartRes() + 1,
- viewport.alignment));
+ viewport.getAlignment()));
viewport.setSelectionGroup(null);
viewport.sendSelection();
- viewport.alignment.deleteGroup(sg);
+ viewport.getAlignment().deleteGroup(sg);
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
*/
protected void deleteGroups_actionPerformed(ActionEvent e)
{
- viewport.alignment.deleteAllGroups();
+ viewport.getAlignment().deleteAllGroups();
viewport.sequenceColours = null;
viewport.setSelectionGroup(null);
PaintRefresher.Refresh(this, viewport.getSequenceSetId());
sg.addSequence(viewport.getAlignment().getSequenceAt(i), false);
}
- sg.setEndRes(viewport.alignment.getWidth() - 1);
+ sg.setEndRes(viewport.getAlignment().getWidth() - 1);
viewport.setSelectionGroup(sg);
viewport.sendSelection();
alignPanel.paintAlignment(true);
if (viewport.getSelectionGroup() != null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
}
else
{
- seqs = viewport.alignment.getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
TrimRegionCommand trimRegion;
{
trimRegion = new TrimRegionCommand("Remove Left",
TrimRegionCommand.TRIM_LEFT, seqs, column,
- viewport.alignment, viewport.colSel,
- viewport.selectionGroup);
+ viewport.getAlignment(), viewport.getColumnSelection(),
+ viewport.getSelectionGroup());
viewport.setStartRes(0);
}
else
{
trimRegion = new TrimRegionCommand("Remove Right",
TrimRegionCommand.TRIM_RIGHT, seqs, column,
- viewport.alignment, viewport.colSel,
- viewport.selectionGroup);
+ viewport.getAlignment(), viewport.getColumnSelection(),
+ viewport.getSelectionGroup());
}
statusBar.setText("Removed " + trimRegion.getSize() + " columns.");
addHistoryItem(trimRegion);
- Vector groups = viewport.alignment.getGroups();
+ Vector groups = viewport.getAlignment().getGroups();
for (int i = 0; i < groups.size(); i++)
{
if ((trimLeft && !sg.adjustForRemoveLeft(column))
|| (!trimLeft && !sg.adjustForRemoveRight(column)))
{
- viewport.alignment.deleteGroup(sg);
+ viewport.getAlignment().deleteGroup(sg);
}
}
*/
public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
{
- int start = 0, end = viewport.alignment.getWidth() - 1;
+ int start = 0, end = viewport.getAlignment().getWidth() - 1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
start = viewport.getSelectionGroup().getStartRes();
end = viewport.getSelectionGroup().getEndRes();
}
else
{
- seqs = viewport.alignment.getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
RemoveGapColCommand removeGapCols = new RemoveGapColCommand(
- "Remove Gapped Columns", seqs, start, end, viewport.alignment);
+ "Remove Gapped Columns", seqs, start, end, viewport.getAlignment());
addHistoryItem(removeGapCols);
// This is to maintain viewport position on first residue
// of first sequence
- SequenceI seq = viewport.alignment.getSequenceAt(0);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(0);
int startRes = seq.findPosition(viewport.startRes);
// ShiftList shifts;
// viewport.getAlignment().removeGaps(shifts=new ShiftList());
*/
public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
{
- int start = 0, end = viewport.alignment.getWidth() - 1;
+ int start = 0, end = viewport.getAlignment().getWidth() - 1;
SequenceI[] seqs;
if (viewport.getSelectionGroup() != null)
{
seqs = viewport.getSelectionGroup().getSequencesAsArray(
- viewport.hiddenRepSequences);
+ viewport.getHiddenRepSequences());
start = viewport.getSelectionGroup().getStartRes();
end = viewport.getSelectionGroup().getEndRes();
}
else
{
- seqs = viewport.alignment.getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
// This is to maintain viewport position on first residue
// of first sequence
- SequenceI seq = viewport.alignment.getSequenceAt(0);
+ SequenceI seq = viewport.getAlignment().getSequenceAt(0);
int startRes = seq.findPosition(viewport.startRes);
addHistoryItem(new RemoveGapsCommand("Remove Gaps", seqs, start, end,
- viewport.alignment));
+ viewport.getAlignment()));
viewport.setStartRes(seq.findIndex(startRes) - 1);
*/
public void padGapsMenuitem_actionPerformed(ActionEvent e)
{
- viewport.padGaps = padGapsMenuitem.isSelected();
+ viewport.setPadGaps(padGapsMenuitem.isSelected());
viewport.firePropertyChange("alignment", null, viewport.getAlignment()
.getSequences());
}
if (!copyAnnotation)
{
// just remove all the current annotation except for the automatic stuff
- newap.av.alignment.deleteAllGroups();
- for (AlignmentAnnotation alan : newap.av.alignment
+ newap.av.getAlignment().deleteAllGroups();
+ for (AlignmentAnnotation alan : newap.av.getAlignment()
.getAlignmentAnnotation())
{
if (!alan.autoCalculated)
{
- newap.av.alignment.deleteAnnotation(alan);
+ newap.av.getAlignment().deleteAnnotation(alan);
}
;
}
// Hide everything by the current selection - this is a hack - we do the
// invert and then hide
// first check that there will be visible columns after the invert.
- if ((viewport.colSel != null && viewport.colSel.getSelected() != null && viewport.colSel
+ if ((viewport.getColumnSelection() != null && viewport.getColumnSelection().getSelected() != null && viewport.getColumnSelection()
.getSelected().size() > 0)
|| (sg != null && sg.getSize() > 0 && sg.getStartRes() <= sg
.getEndRes()))
if (toggleSeqs)
{
- if (sg != null && sg.getSize() != viewport.alignment.getHeight())
+ if (sg != null && sg.getSize() != viewport.getAlignment().getHeight())
{
hideSelSequences_actionPerformed(null);
hide = true;
}
- else if (!(toggleCols && viewport.colSel.getSelected().size() > 0))
+ else if (!(toggleCols && viewport.getColumnSelection().getSelected().size() > 0))
{
showAllSeqs_actionPerformed(null);
}
if (toggleCols)
{
- if (viewport.colSel.getSelected().size() > 0)
+ if (viewport.getColumnSelection().getSelected().size() > 0)
{
hideSelColumns_actionPerformed(null);
if (!toggleSeqs)
{
- viewport.selectionGroup = sg;
+ viewport.setSelectionGroup(sg);
}
}
else if (!hide)
{
JEditorPane editPane = new JEditorPane("text/html", "");
editPane.setEditable(false);
- StringBuffer contents = new AlignmentProperties(viewport.alignment)
+ StringBuffer contents = new AlignmentProperties(viewport.getAlignment())
.formatAsHtml();
editPane.setText("<html>" + contents.toString() + "</html>");
JInternalFrame frame = new JInternalFrame();
public void clustalColour_actionPerformed(ActionEvent e)
{
changeColour(new ClustalxColourScheme(
- viewport.alignment.getSequences(),
- viewport.alignment.getWidth()));
+ viewport.getAlignment().getSequences(),
+ viewport.getAlignment().getWidth()));
}
/**
/*
public void covariationColour_actionPerformed(ActionEvent e)
{
- changeColour(new CovariationColourScheme(viewport.alignment.getAlignmentAnnotation()[0]));
+ changeColour(new CovariationColourScheme(viewport.getAlignment().getAlignmentAnnotation()[0]));
}
*/
public void annotationColour_actionPerformed(ActionEvent e)
if (viewport.getConservationSelected())
{
- Alignment al = (Alignment) viewport.alignment;
+ Alignment al = (Alignment) viewport.getAlignment();
Conservation c = new Conservation("All",
ResidueProperties.propHash, 3, al.getSequences(), 0,
al.getWidth() - 1);
cs.setConservation(null);
}
- cs.setConsensus(viewport.hconsensus);
+ cs.setConsensus(viewport.getSequenceConsensusHash());
}
viewport.setGlobalColourScheme(cs);
if (viewport.getColourAppliesToAllGroups())
{
- Vector groups = viewport.alignment.getGroups();
+ Vector groups = viewport.getAlignment().getGroups();
for (int i = 0; i < groups.size(); i++)
{
if (cs instanceof ClustalxColourScheme)
{
sg.cs = new ClustalxColourScheme(
- sg.getSequences(viewport.hiddenRepSequences),
+ sg.getSequences(viewport.getHiddenRepSequences()),
sg.getWidth());
}
else if (cs instanceof UserColourScheme)
sg.cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
sg.cs.setConsensus(AAFrequency.calculate(
- sg.getSequences(viewport.hiddenRepSequences),
+ sg.getSequences(viewport.getHiddenRepSequences()),
sg.getStartRes(), sg.getEndRes() + 1));
}
else
{
Conservation c = new Conservation("Group",
ResidueProperties.propHash, 3,
- sg.getSequences(viewport.hiddenRepSequences),
+ sg.getSequences(viewport.getHiddenRepSequences()),
sg.getStartRes(), sg.getEndRes() + 1);
c.calculate();
c.verdict(false, viewport.getConsPercGaps());
protected void modifyPID_actionPerformed(ActionEvent e)
{
if (viewport.getAbovePIDThreshold()
- && viewport.globalColourScheme != null)
+ && viewport.getGlobalColourScheme() != null)
{
SliderPanel.setPIDSliderSource(alignPanel,
viewport.getGlobalColourScheme(), "Background");
protected void modifyConservation_actionPerformed(ActionEvent e)
{
if (viewport.getConservationSelected()
- && viewport.globalColourScheme != null)
+ && viewport.getGlobalColourScheme()!= null)
{
SliderPanel.setConservationSlider(alignPanel,
- viewport.globalColourScheme, "Background");
+ viewport.getGlobalColourScheme(), "Background");
SliderPanel.showConservationSlider();
}
}
AlignmentSorter.sortByPID(viewport.getAlignment(), viewport
.getAlignment().getSequenceAt(0), null);
addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
{
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByID(viewport.getAlignment());
- addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment));
+ addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByLength(viewport.getAlignment());
addHistoryItem(new OrderCommand("Length Sort", oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByGroup(viewport.getAlignment());
addHistoryItem(new OrderCommand("Group Sort", oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
else
{
// are the visible sequences aligned?
- if (!viewport.alignment.isAligned(false))
+ if (!viewport.getAlignment().isAligned(false))
{
JOptionPane
.showMessageDialog(
return;
}
- if (viewport.alignment.getHeight() < 2)
+ if (viewport.getAlignment().getHeight() < 2)
{
return;
}
AlignmentSorter.sortBy(viewport.getAlignment(), order);
addHistoryItem(new OrderCommand(order.getName(), oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
AlignmentSorter.sortByAnnotationScore(scoreLabel,
viewport.getAlignment());// ,viewport.getSelectionGroup());
addHistoryItem(new OrderCommand("Sort by " + scoreLabel, oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
alignPanel.paintAlignment(true);
}
});
*/
public void buildSortByAnnotationScoresMenu()
{
- if (viewport.alignment.getAlignmentAnnotation() == null)
+ if (viewport.getAlignment().getAlignmentAnnotation() == null)
{
return;
}
- if (viewport.alignment.getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
+ if (viewport.getAlignment().getAlignmentAnnotation().hashCode() != _annotationScoreVectorHash)
{
sortByAnnotScore.removeAll();
// almost certainly a quicker way to do this - but we keep it simple
Hashtable scoreSorts = new Hashtable();
AlignmentAnnotation aann[];
- Enumeration sq = viewport.alignment.getSequences().elements();
+ Enumeration sq = viewport.getAlignment().getSequences().elements();
while (sq.hasMoreElements())
{
aann = ((SequenceI) sq.nextElement()).getAnnotation();
sortByAnnotScore.setVisible(scoreSorts.size() > 0);
scoreSorts.clear();
- _annotationScoreVectorHash = viewport.alignment
+ _annotationScoreVectorHash = viewport.getAlignment()
.getAlignmentAnnotation().hashCode();
}
}
if (undoname != null)
{
addHistoryItem(new OrderCommand(undoname, oldOrder,
- viewport.alignment));
+ viewport.getAlignment()));
}
alignPanel.paintAlignment(true);
return true;
}
// limit sequences - JBPNote in future - could spawn multiple prediction
// jobs
- // TODO: viewport.alignment.isAligned is a global state - the local
+ // TODO: viewport.getAlignment().isAligned is a global state - the local
// selection may well be aligned - we preserve 2.0.8 behaviour for moment.
- if (!viewport.alignment.isAligned(false))
+ if (!viewport.getAlignment().isAligned(false))
{
seqs.setSequences(new SeqCigar[]
{ seqs.getSequences()[0] });
* AlignFrame af = this; testAlView.addActionListener(new ActionListener() {
*
* @Override public void actionPerformed(ActionEvent e) {
- * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.alignment,
- * af.viewport.colSel, af.viewport.selectionGroup); }
+ * jalview.datamodel.AlignmentView.testSelectionViews(af.viewport.getAlignment(),
+ * af.viewport.getColumnSelection(), af.viewport.selectionGroup); }
*
* }); webService.add(testAlView);
*/
ths.setProgressBar("Searching for sequences from " + fsrc, sttime);
try
{
- Alignment ds = ths.getViewport().alignment.getDataset(); // update
+ Alignment ds = ths.getViewport().getAlignment().getDataset(); // update
// our local
// dataset
// reference
{
al = jalview.analysis.Dna.CdnaTranslate(selection, seqstring,
viewport.getViewAsVisibleContigs(true), viewport
- .getGapCharacter(), viewport.alignment
- .getAlignmentAnnotation(), viewport.alignment
+ .getGapCharacter(), viewport.getAlignment()
+ .getAlignmentAnnotation(), viewport.getAlignment()
.getWidth(), viewport.getAlignment().getDataset());
} catch (Exception ex)
{
try
{
featuresFile = new FeaturesFile(file, type)
- .parse(viewport.alignment.getDataset(),
+ .parse(viewport.getAlignment().getDataset(),
alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
false, jalview.bin.Cache.getDefault(
"RELAXEDSEQIDMATCHING", false));
// try to parse as annotation.
boolean isAnnotation = (format == null || format
.equalsIgnoreCase("PFAM")) ? new AnnotationFile()
- .readAnnotationFile(viewport.alignment, file, protocol)
+ .readAnnotationFile(viewport.getAlignment(), file, protocol)
: false;
if (!isAnnotation)
protected void extractScores_actionPerformed(ActionEvent e)
{
ParseProperties pp = new jalview.analysis.ParseProperties(
- viewport.alignment);
+ viewport.getAlignment());
// TODO: verify regex and introduce GUI dialog for version 2.5
// if (pp.getScoresFromDescription("col", "score column ",
// "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)",
viewport.getSequenceSelection(),
viewport.getAlignmentView(true).getSequenceStrings(
viewport.getGapCharacter()),
- viewport.alignment.getGroups());
- viewport.alignment.deleteAllGroups();
+ viewport.getAlignment().getGroups());
+ viewport.getAlignment().deleteAllGroups();
viewport.sequenceColours = null;
viewport.setSelectionGroup(null);
// set view properties for each group
{
gps[g].setShowNonconserved(viewport.getShowUnconserved());
gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo());
- viewport.alignment.addGroup(gps[g]);
+ viewport.getAlignment().addGroup(gps[g]);
Color col = new Color((int) (Math.random() * 255),
(int) (Math.random() * 255), (int) (Math.random() * 255));
col = col.brighter();
import jalview.structure.SelectionSource;
import jalview.structure.StructureSelectionManager;
import jalview.structure.VamsasSource;
+import jalview.viewmodel.AlignmentViewport;
import jalview.workers.AlignCalcManager;
+import jalview.workers.ConsensusThread;
import jalview.workers.ConservationThread;
+import jalview.workers.StrucConsensusThread;
/**
* DOCUMENT ME!
boolean colourAppliesToAllGroups = true;
- ColourSchemeI globalColourScheme = null;
-
boolean conservationColourSelected = false;
boolean abovePIDThreshold = false;
- SequenceGroup selectionGroup;
-
int charHeight;
int charWidth;
boolean seqNameItalics;
- AlignmentI alignment;
-
- ColumnSelection colSel = new ColumnSelection();
-
int threshold;
int increment;
boolean scaleRightWrapped = true;
- boolean hasHiddenColumns = false;
-
- boolean hasHiddenRows = false;
-
boolean showHiddenMarkers = true;
boolean cursorMode = false;
*/
Hashtable featuresDisplayed = null;
- /** DOCUMENT ME!! */
- public Hashtable[] hconsensus;
-
- public Hashtable[] hStrucConsensus;
-
- AlignmentAnnotation consensus;
-
- AlignmentAnnotation strucConsensus;
-
- AlignmentAnnotation conservation;
-
- AlignmentAnnotation quality;
-
- AlignmentAnnotation[] groupConsensus;
-
- AlignmentAnnotation[] groupConservation;
-
- boolean autoCalculateConsensus = true;
-
- boolean autoCalculateStrucConsensus = true;
-
- // JBPNote Prolly only need this in the applet version.
- private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
- this);
-
- boolean ignoreGapsInConsensusCalculation = false;
boolean isDataset = false;
boolean antiAlias = false;
- boolean padGaps = false;
-
Rectangle explodedPosition;
String viewName;
- String sequenceSetID;
-
boolean gatherViewsHere = false;
Stack historyList = new Stack();
boolean rightAlignIds = false;
- Hashtable hiddenRepSequences;
-
- boolean sortByTree;
-
/**
* Creates a new AlignViewport object.
*
centreColumnLabels = Cache.getDefault("CENTRE_COLUMN_LABELS", false);
autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
- padGaps = Cache.getDefault("PAD_GAPS", true);
+ setPadGaps(Cache.getDefault("PAD_GAPS", true));
shownpfeats = Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true);
showdbrefs = Cache.getDefault("SHOW_DBREFS_TOOLTIP", true);
{
return showSequenceFeatures;
}
-
- AlignCalcManagerI calculator=new AlignCalcManager();
-
- ConsensusThread consensusThread;
-
- StrucConsensusThread strucConsensusThread;
-
- boolean consUpdateNeeded = false;
-
- static boolean UPDATING_CONSENSUS = false;
-
- static boolean UPDATING_STRUC_CONSENSUS = false;
-
- static boolean UPDATING_CONSERVATION = false;
-
- boolean updatingConsensus = false;
-
- boolean updatingStrucConsensus = false;
-
- boolean updatingConservation = false;
/**
* centre columnar annotation labels in displayed alignment annotation TODO:
private boolean shownpfeats;
- /**
- * trigger update of conservation annotation
- */
- public void updateConservation(final AlignmentViewPanel ap)
- {
- // see note in mantis : issue number 8585
- if (alignment.isNucleotide() || conservation == null
- || !autoCalculateConsensus)
- {
- return;
- }
-
- calculator.startWorker(new jalview.workers.ConservationThread(this, ap));
- }
-
- /**
- * trigger update of consensus annotation
- */
- public void updateConsensus(final AlignmentPanel ap)
- {
- // see note in mantis : issue number 8585
- if (consensus == null || !autoCalculateConsensus)
- {
- return;
- }
- consensusThread = new ConsensusThread(ap);
- consensusThread.start();
- }
-
- class ConsensusThread extends Thread
- {
- AlignmentViewPanel ap;
- public ConsensusThread(AlignmentPanel ap)
- {
- this.ap = ap;
- }
-
- public void run()
- {
- updatingConsensus = true;
- while (UPDATING_CONSENSUS)
- {
- try
- {
- if (ap != null)
- {
- ap.paintAlignment(false);
- }
-
- Thread.sleep(200);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- UPDATING_CONSENSUS = true;
-
- try
- {
- int aWidth = (alignment != null) ? alignment.getWidth() : -1; // null
- // pointer
- // possibility
- // here.
- if (aWidth <= 0)
- {
- updatingConsensus = false;
- UPDATING_CONSENSUS = false;
- return;
- }
-
- consensus.annotations = null;
- consensus.annotations = new Annotation[aWidth];
-
- hconsensus = new Hashtable[aWidth];
- AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment
- .getWidth(), hconsensus, true);
- updateAnnotation(true);
- if (globalColourScheme != null)
- {
- globalColourScheme.setConsensus(hconsensus);
- }
-
- } catch (OutOfMemoryError error)
- {
- alignment.deleteAnnotation(consensus);
-
- consensus = null;
- hconsensus = null;
- ap.raiseOOMWarning("calculating consensus", error);
- }
- UPDATING_CONSENSUS = false;
- updatingConsensus = false;
-
- if (ap != null)
- {
- ap.paintAlignment(true);
- }
- }
-
- /**
- * update the consensus annotation from the sequence profile data using
- * current visualization settings.
- */
- public void updateAnnotation()
- {
- updateAnnotation(false);
- }
-
- protected void updateAnnotation(boolean immediate)
- {
- // TODO: make calls thread-safe, so if another thread calls this method,
- // it will either return or wait until one calculation is finished.
- if (immediate
- || (!updatingConsensus && consensus != null && hconsensus != null))
- {
- AAFrequency.completeConsensus(consensus, hconsensus, 0,
- hconsensus.length, ignoreGapsInConsensusCalculation,
- showSequenceLogo);
- }
- }
- }
-
- // --------START Structure Conservation
- public void updateStrucConsensus(final AlignmentPanel ap)
- {
- // see note in mantis : issue number 8585
- if (strucConsensus == null || !autoCalculateStrucConsensus)
- {
- return;
- }
- strucConsensusThread = new StrucConsensusThread(ap);
- strucConsensusThread.start();
- }
-
- class StrucConsensusThread extends Thread
- {
- AlignmentPanel ap;
-
- public StrucConsensusThread(AlignmentPanel ap)
- {
- this.ap = ap;
- }
-
- public void run()
- {
- updatingStrucConsensus = true;
- while (UPDATING_STRUC_CONSENSUS)
- {
- try
- {
- if (ap != null)
- {
- ap.paintAlignment(false);
- }
-
- Thread.sleep(200);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- UPDATING_STRUC_CONSENSUS = true;
-
- try
- {
- int aWidth = (alignment != null) ? alignment.getWidth() : -1; // null
- // pointer
- // possibility
- // here.
- if (aWidth <= 0)
- {
- updatingStrucConsensus = false;
- UPDATING_STRUC_CONSENSUS = false;
- return;
- }
-
- strucConsensus.annotations = null;
- strucConsensus.annotations = new Annotation[aWidth];
-
- hStrucConsensus = new Hashtable[aWidth];
-
- AlignmentAnnotation[] aa = ap.av.getAlignment()
- .getAlignmentAnnotation();
- AlignmentAnnotation rnaStruc = null;
- for (int i = 0; i < aa.length; i++)
- {
- if (aa[i].getRNAStruc() != null)
- {
- rnaStruc = aa[i];
- break;
- }
- }
-
- AlignmentAnnotation rna = ap.av.getAlignment()
- .getAlignmentAnnotation()[0];
- StructureFrequency.calculate(alignment.getSequencesArray(), 0,
- alignment.getWidth(), hStrucConsensus, true, rnaStruc);
- // TODO AlignmentAnnotation rnaStruc!!!
- updateAnnotation(true);
- if (globalColourScheme != null)
- {
- globalColourScheme.setConsensus(hStrucConsensus);
- }
-
- } catch (OutOfMemoryError error)
- {
- alignment.deleteAnnotation(strucConsensus);
-
- strucConsensus = null;
- hStrucConsensus = null;
- new OOMWarning("calculating structure consensus", error);
- }
- UPDATING_STRUC_CONSENSUS = false;
- updatingStrucConsensus = false;
-
- if (ap != null)
- {
- ap.paintAlignment(true);
- }
- }
-
- /**
- * update the consensus annotation from the sequence profile data using
- * current visualization settings.
- */
- public void updateAnnotation()
- {
- updateAnnotation(false);
- }
-
- protected void updateAnnotation(boolean immediate)
- {
- // TODO: make calls thread-safe, so if another thread calls this method,
- // it will either return or wait until one calculation is finished.
- if (immediate
- || (!updatingStrucConsensus && strucConsensus != null && hStrucConsensus != null))
- {
- StructureFrequency.completeConsensus(strucConsensus,
- hStrucConsensus, 0, hStrucConsensus.length, false,
- showSequenceLogo);
- }
- }
- }
-
// --------END Structure Conservation
/**
return sq;
}
- /**
- *
- *
- * @return null or the currently selected sequence region
- */
- public SequenceGroup getSelectionGroup()
- {
- return selectionGroup;
- }
-
- /**
- * Set the selection group for this window.
- *
- * @param sg
- * - group holding references to sequences in this alignment view
- *
- */
- public void setSelectionGroup(SequenceGroup sg)
- {
- selectionGroup = sg;
- }
/**
* GUI state
/**
* DOCUMENT ME!
*
- * @param cs
- * DOCUMENT ME!
- */
- public void setGlobalColourScheme(ColourSchemeI cs)
- {
- globalColourScheme = cs;
- }
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public ColourSchemeI getGlobalColourScheme()
- {
- return globalColourScheme;
- }
-
- /**
- * DOCUMENT ME!
- *
* @param res
* DOCUMENT ME!
*/
Desktop.instance).removeMappings(alignment.getCodonFrames());
}
this.alignment = align;
- if (alignment.getCodonFrames() != null)
+ if (alignment!=null && alignment.getCodonFrames() != null)
{
StructureSelectionManager.getStructureSelectionManager(
Desktop.instance).addMappings(alignment.getCodonFrames());
scaleRightWrapped = b;
}
- /**
- * Property change listener for changes in alignment
- *
- * @param listener
- * DOCUMENT ME!
- */
- public void addPropertyChangeListener(
- java.beans.PropertyChangeListener listener)
- {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param listener
- * DOCUMENT ME!
- */
- public void removePropertyChangeListener(
- java.beans.PropertyChangeListener listener)
- {
- changeSupport.removePropertyChangeListener(listener);
- }
-
- /**
- * Property change listener for changes in alignment
- *
- * @param prop
- * DOCUMENT ME!
- * @param oldvalue
- * DOCUMENT ME!
- * @param newvalue
- * DOCUMENT ME!
- */
- public void firePropertyChange(String prop, Object oldvalue,
- Object newvalue)
- {
- changeSupport.firePropertyChange(prop, oldvalue, newvalue);
- }
-
- public void setIgnoreGapsConsensus(boolean b, AlignmentPanel ap)
- {
- ignoreGapsInConsensusCalculation = b;
- updateConsensus(ap);
- if (globalColourScheme != null)
- {
- globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
- ignoreGapsInConsensusCalculation);
- }
- }
-
- public boolean getIgnoreGapsConsensus()
- {
- return ignoreGapsInConsensusCalculation;
- }
public void setDataset(boolean b)
{
return isDataset;
}
- public void hideSelectedColumns()
- {
- if (colSel.size() < 1)
- {
- return;
- }
- colSel.hideSelectedColumns();
- setSelectionGroup(null);
- hasHiddenColumns = true;
+ public boolean getShowHiddenMarkers()
+ {
+ return showHiddenMarkers;
+ }
+
+ public void setShowHiddenMarkers(boolean show)
+ {
+ showHiddenMarkers = show;
}
- public void hideColumns(int start, int end)
+ public Color getSequenceColour(SequenceI seq)
{
- if (start == end)
+ if (sequenceColours == null || !sequenceColours.containsKey(seq))
{
- colSel.hideColumns(start);
+ return Color.white;
}
else
{
- colSel.hideColumns(start, end);
+ return (Color) sequenceColours.get(seq);
}
-
- hasHiddenColumns = true;
}
- public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
+ public void setSequenceColour(SequenceI seq, Color col)
{
- int sSize = sg.getSize();
- if (sSize < 2)
+ if (sequenceColours == null)
{
- return;
+ sequenceColours = new Hashtable();
}
- if (hiddenRepSequences == null)
+ if (col == null)
{
- hiddenRepSequences = new Hashtable();
+ sequenceColours.remove(seq);
}
-
- hiddenRepSequences.put(repSequence, sg);
-
- // Hide all sequences except the repSequence
- SequenceI[] seqs = new SequenceI[sSize - 1];
- int index = 0;
- for (int i = 0; i < sSize; i++)
+ else
{
- if (sg.getSequenceAt(i) != repSequence)
- {
- if (index == sSize - 1)
- {
- return;
- }
-
- seqs[index++] = sg.getSequenceAt(i);
- }
+ sequenceColours.put(seq, col);
}
- sg.setSeqrep(repSequence);
- sg.setHidereps(true);
- hideSequence(seqs);
-
}
- public void hideAllSelectedSeqs()
+ /**
+ * returns the visible column regions of the alignment
+ *
+ * @param selectedRegionOnly
+ * true to just return the contigs intersecting with the selected
+ * area
+ * @return
+ */
+ public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
{
- if (selectionGroup == null || selectionGroup.getSize() < 1)
+ int[] viscontigs = null;
+ int start = 0, end = 0;
+ if (selectedRegionOnly && selectionGroup != null)
{
- return;
+ start = selectionGroup.getStartRes();
+ end = selectionGroup.getEndRes() + 1;
}
-
- SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
-
- hideSequence(seqs);
-
- setSelectionGroup(null);
- }
-
- public void hideSequence(SequenceI[] seq)
- {
- if (seq != null)
+ else
{
- for (int i = 0; i < seq.length; i++)
- {
- alignment.getHiddenSequences().hideSequence(seq[i]);
- }
- hasHiddenRows = true;
- firePropertyChange("alignment", null, alignment.getSequences());
+ end = alignment.getWidth();
}
- }
-
- public void showSequence(int index)
- {
- Vector tmp = alignment.getHiddenSequences().showSequence(index,
- hiddenRepSequences);
- if (tmp.size() > 0)
- {
- if (selectionGroup == null)
- {
- selectionGroup = new SequenceGroup();
- selectionGroup.setEndRes(alignment.getWidth() - 1);
- }
-
- for (int t = 0; t < tmp.size(); t++)
- {
- selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
- }
- firePropertyChange("alignment", null, alignment.getSequences());
- sendSelection();
- }
-
- if (alignment.getHiddenSequences().getSize() < 1)
- {
- hasHiddenRows = false;
- }
- }
-
- public void showColumn(int col)
- {
- colSel.revealHiddenColumns(col);
- if (colSel.getHiddenColumns() == null)
- {
- hasHiddenColumns = false;
- }
- }
-
- public void showAllHiddenColumns()
- {
- colSel.revealAllHiddenColumns();
- hasHiddenColumns = false;
- }
-
- public void showAllHiddenSeqs()
- {
- if (alignment.getHiddenSequences().getSize() > 0)
- {
- if (selectionGroup == null)
- {
- selectionGroup = new SequenceGroup();
- selectionGroup.setEndRes(alignment.getWidth() - 1);
- }
- Vector tmp = alignment.getHiddenSequences().showAll(
- hiddenRepSequences);
- for (int t = 0; t < tmp.size(); t++)
- {
- selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
- }
- firePropertyChange("alignment", null, alignment.getSequences());
- sendSelection();
- hasHiddenRows = false;
- hiddenRepSequences = null;
- }
- }
-
- public void invertColumnSelection()
- {
- colSel.invertColumnSelection(0, alignment.getWidth());
- }
-
- public int adjustForHiddenSeqs(int alignmentIndex)
- {
- return alignment.getHiddenSequences().adjustForHiddenSeqs(
- alignmentIndex);
- }
-
- /**
- * This method returns an array of new SequenceI objects derived from the
- * whole alignment or just the current selection with start and end points
- * adjusted
- *
- * @note if you need references to the actual SequenceI objects in the
- * alignment or currently selected then use getSequenceSelection()
- * @return selection as new sequenceI objects
- */
- public SequenceI[] getSelectionAsNewSequence()
- {
- SequenceI[] sequences;
-
- if (selectionGroup == null)
- {
- sequences = alignment.getSequencesArray();
- AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
- for (int i = 0; i < sequences.length; i++)
- {
- sequences[i] = new Sequence(sequences[i], annots); // construct new
- // sequence with
- // subset of visible
- // annotation
- }
- }
- else
- {
- sequences = selectionGroup.getSelectionAsNewSequences(alignment);
- }
-
- return sequences;
- }
-
- /**
- * get the currently selected sequence objects or all the sequences in the
- * alignment.
- *
- * @return array of references to sequence objects
- */
- public SequenceI[] getSequenceSelection()
- {
- SequenceI[] sequences = null;
- if (selectionGroup != null)
- {
- sequences = selectionGroup.getSequencesInOrder(alignment);
- }
- if (sequences == null)
- {
- sequences = alignment.getSequencesArray();
- }
- return sequences;
- }
-
- /**
- * This method returns the visible alignment as text, as seen on the GUI, ie
- * if columns are hidden they will not be returned in the result. Use this for
- * calculating trees, PCA, redundancy etc on views which contain hidden
- * columns.
- *
- * @return String[]
- */
- public jalview.datamodel.CigarArray getViewAsCigars(
- boolean selectedRegionOnly)
- {
- return new jalview.datamodel.CigarArray(alignment,
- (hasHiddenColumns ? colSel : null),
- (selectedRegionOnly ? selectionGroup : null));
- }
-
- /**
- * return a compact representation of the current alignment selection to pass
- * to an analysis function
- *
- * @param selectedOnly
- * boolean true to just return the selected view
- * @return AlignmentView
- */
- public jalview.datamodel.AlignmentView getAlignmentView(
- boolean selectedOnly)
- {
- return getAlignmentView(selectedOnly, false);
- }
-
- /**
- * return a compact representation of the current alignment selection to pass
- * to an analysis function
- *
- * @param selectedOnly
- * boolean true to just return the selected view
- * @param markGroups
- * boolean true to annotate the alignment view with groups on the
- * alignment (and intersecting with selected region if selectedOnly
- * is true)
- * @return AlignmentView
- */
- public jalview.datamodel.AlignmentView getAlignmentView(
- boolean selectedOnly, boolean markGroups)
- {
- return new AlignmentView(alignment, colSel, selectionGroup,
- hasHiddenColumns, selectedOnly, markGroups);
- }
-
- /**
- * This method returns the visible alignment as text, as seen on the GUI, ie
- * if columns are hidden they will not be returned in the result. Use this for
- * calculating trees, PCA, redundancy etc on views which contain hidden
- * columns.
- *
- * @return String[]
- */
- public String[] getViewAsString(boolean selectedRegionOnly)
- {
- String[] selection = null;
- SequenceI[] seqs = null;
- int i, iSize;
- int start = 0, end = 0;
- if (selectedRegionOnly && selectionGroup != null)
- {
- iSize = selectionGroup.getSize();
- seqs = selectionGroup.getSequencesInOrder(alignment);
- start = selectionGroup.getStartRes();
- end = selectionGroup.getEndRes() + 1;
- }
- else
- {
- iSize = alignment.getHeight();
- seqs = alignment.getSequencesArray();
- end = alignment.getWidth();
- }
-
- selection = new String[iSize];
- if (hasHiddenColumns)
- {
- selection = colSel.getVisibleSequenceStrings(start, end, seqs);
- }
- else
- {
- for (i = 0; i < iSize; i++)
- {
- selection[i] = seqs[i].getSequenceAsString(start, end);
- }
-
- }
- return selection;
- }
-
- public int[][] getVisibleRegionBoundaries(int min, int max)
- {
- Vector regions = new Vector();
- int start = min;
- int end = max;
-
- do
- {
- if (hasHiddenColumns)
- {
- if (start == 0)
- {
- start = colSel.adjustForHiddenColumns(start);
- }
-
- end = colSel.getHiddenBoundaryRight(start);
- if (start == end)
- {
- end = max;
- }
- if (end > max)
- {
- end = max;
- }
- }
-
- regions.addElement(new int[]
- { start, end });
-
- if (hasHiddenColumns)
- {
- start = colSel.adjustForHiddenColumns(end);
- start = colSel.getHiddenBoundaryLeft(start) + 1;
- }
- } while (end < max);
-
- int[][] startEnd = new int[regions.size()][2];
-
- regions.copyInto(startEnd);
-
- return startEnd;
-
- }
-
- public boolean getShowHiddenMarkers()
- {
- return showHiddenMarkers;
- }
-
- public void setShowHiddenMarkers(boolean show)
- {
- showHiddenMarkers = show;
- }
-
- public String getSequenceSetId()
- {
- if (sequenceSetID == null)
- {
- sequenceSetID = alignment.hashCode() + "";
- }
-
- return sequenceSetID;
- }
-
- /**
- * unique viewId for synchronizing state with stored Jalview Project
- *
- */
- private String viewId = null;
-
- public String getViewId()
- {
- if (viewId == null)
- {
- viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
- }
- return viewId;
- }
-
- public void alignmentChanged(AlignmentPanel ap)
- {
- if (padGaps)
- {
- alignment.padGaps();
- }
- if (hconsensus != null && autoCalculateConsensus)
- {
- updateConservation(ap);
- }
- if (autoCalculateConsensus)
- {
- updateConsensus(ap);
- }
- if (autoCalculateStrucConsensus)
- {
- updateStrucConsensus(ap);
- }
-
- // Reset endRes of groups if beyond alignment width
- int alWidth = alignment.getWidth();
- Vector groups = alignment.getGroups();
- if (groups != null)
- {
- for (int i = 0; i < groups.size(); i++)
- {
- SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
- if (sg.getEndRes() > alWidth)
- {
- sg.setEndRes(alWidth - 1);
- }
- }
- }
-
- if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
- {
- selectionGroup.setEndRes(alWidth - 1);
- }
-
- resetAllColourSchemes();
-
- // alignment.adjustSequenceAnnotations();
- }
-
- void resetAllColourSchemes()
- {
- ColourSchemeI cs = globalColourScheme;
- if (cs != null)
- {
- if (cs instanceof ClustalxColourScheme)
- {
- ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
- alignment.getWidth());
- }
-
- cs.setConsensus(hconsensus);
- if (cs.conservationApplied())
- {
- AlignmentI al = (Alignment) alignment;
- Conservation c = new Conservation("All",
- ResidueProperties.propHash, 3, al.getSequences(), 0, al
- .getWidth() - 1);
- c.calculate();
- c.verdict(false, getConsPercGaps());
-
- cs.setConservation(c);
- }
- }
-
- int s, sSize = alignment.getGroups().size();
- for (s = 0; s < sSize; s++)
- {
- SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
- if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
- {
- ((ClustalxColourScheme) sg.cs).resetClustalX(sg
- .getSequences(hiddenRepSequences), sg.getWidth());
- }
- sg.recalcConservation();
- }
- }
-
- public Color getSequenceColour(SequenceI seq)
- {
- if (sequenceColours == null || !sequenceColours.containsKey(seq))
- {
- return Color.white;
- }
- else
- {
- return (Color) sequenceColours.get(seq);
- }
- }
-
- public void setSequenceColour(SequenceI seq, Color col)
- {
- if (sequenceColours == null)
- {
- sequenceColours = new Hashtable();
- }
-
- if (col == null)
- {
- sequenceColours.remove(seq);
- }
- else
- {
- sequenceColours.put(seq, col);
- }
- }
-
- /**
- * returns the visible column regions of the alignment
- *
- * @param selectedRegionOnly
- * true to just return the contigs intersecting with the selected
- * area
- * @return
- */
- public int[] getViewAsVisibleContigs(boolean selectedRegionOnly)
- {
- int[] viscontigs = null;
- int start = 0, end = 0;
- if (selectedRegionOnly && selectionGroup != null)
- {
- start = selectionGroup.getStartRes();
- end = selectionGroup.getEndRes() + 1;
- }
- else
- {
- end = alignment.getWidth();
- }
- viscontigs = colSel.getVisibleContigs(start, end);
- return viscontigs;
+ viscontigs = colSel.getVisibleContigs(start, end);
+ return viscontigs;
}
/**
SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
if (sg.idColour != null)
{
- Vector sqs = sg.getSequences(hiddenRepSequences);
+ Vector sqs = sg.getSequences(getHiddenRepSequences());
for (int s = 0, sSize = sqs.size(); s < sSize; s++)
{
sequenceColours.put(sqs.elementAt(s), sg.idColour);
return followSelection;
}
- private long sgrouphash = -1, colselhash = -1;
-
boolean showSeqFeaturesHeight;
- /**
- * checks current SelectionGroup against record of last hash value, and
- * updates record.
- *
- * @param b
- * update the record of last hash value
- *
- * @return true if SelectionGroup changed since last call (when b is true)
- */
- boolean isSelectionGroupChanged(boolean b)
- {
- int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
- : selectionGroup.hashCode();
- if (hc != -1 && hc != sgrouphash)
- {
- if (b)
- {
- sgrouphash = hc;
- }
- return true;
- }
- return false;
- }
-
- /**
- * checks current colsel against record of last hash value, and optionally
- * updates record.
- *
- * @param b
- * update the record of last hash value
- * @return true if colsel changed since last call (when b is true)
- */
- boolean isColSelChanged(boolean b)
- {
- int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
- .hashCode();
- if (hc != -1 && hc != colselhash)
- {
- if (b)
- {
- colselhash = hc;
- }
- return true;
- }
- return false;
- }
-
public void sendSelection()
{
jalview.structure.StructureSelectionManager
return showSeqFeaturesHeight;
}
- boolean showUnconserved = false;
-
- public boolean getShowUnconserved()
- {
- return showUnconserved;
- }
-
- public void setShowUnconserved(boolean showunconserved)
- {
- showUnconserved = showunconserved;
- }
-
/**
* return the alignPanel containing the given viewport. Use this to get the
* components currently handling the given viewport.
}
/**
- * should conservation rows be shown for groups
- */
- boolean showGroupConservation = false;
-
- /**
- * should consensus rows be shown for groups
- */
- boolean showGroupConsensus = false;
-
- /**
- * should consensus profile be rendered by default
- */
- public boolean showSequenceLogo = false;
- /**
- * should consensus profile be rendered normalised to row height
- */
- public boolean normaliseSequenceLogo = false;
- /**
- * should consensus histograms be rendered by default
- */
- public boolean showConsensusHistogram = true;
-
- /**
- * @return the showConsensusProfile
- */
- public boolean isShowSequenceLogo()
- {
- return showSequenceLogo;
- }
-
- /**
- * @param showSequenceLogo
- * the new value
- */
- public void setShowSequenceLogo(boolean showSequenceLogo)
- {
- if (showSequenceLogo != this.showSequenceLogo)
- {
- // TODO: decouple settings setting from calculation when refactoring
- // annotation update method from alignframe to viewport
- this.showSequenceLogo = showSequenceLogo;
- if (consensusThread != null)
- {
- consensusThread.updateAnnotation();
- }
- if (strucConsensusThread != null)
- {
- strucConsensusThread.updateAnnotation();
- }
- }
- this.showSequenceLogo = showSequenceLogo;
- }
-
- /**
- * @param showConsensusHistogram
- * the showConsensusHistogram to set
- */
- public void setShowConsensusHistogram(boolean showConsensusHistogram)
- {
- this.showConsensusHistogram = showConsensusHistogram;
- }
-
- /**
- * @return the showGroupConservation
- */
- public boolean isShowGroupConservation()
- {
- return showGroupConservation;
- }
-
- /**
- * @param showGroupConservation
- * the showGroupConservation to set
- */
- public void setShowGroupConservation(boolean showGroupConservation)
- {
- this.showGroupConservation = showGroupConservation;
- }
-
- /**
- * @return the showGroupConsensus
- */
- public boolean isShowGroupConsensus()
- {
- return showGroupConsensus;
- }
-
- /**
- * @param showGroupConsensus
- * the showGroupConsensus to set
- */
- public void setShowGroupConsensus(boolean showGroupConsensus)
- {
- this.showGroupConsensus = showGroupConsensus;
- }
-
- /**
- *
- * @return flag to indicate if the consensus histogram should be rendered by
- * default
- */
- public boolean isShowConsensusHistogram()
- {
- return this.showConsensusHistogram;
- }
-
- /**
* synthesize a column selection if none exists so it covers the given
* selection group. if wholewidth is false, no column selection is made if the
* selection group covers the whole alignment width.
normaliseSequenceLogo = state;
}
- public boolean isCalcInProgress()
- {
- // TODO generalise to iterate over all calculators associated with av
- return updatingConsensus || updatingConservation || updatingStrucConsensus;
- }
-
- public boolean isCalculationInProgress(
- AlignmentAnnotation alignmentAnnotation)
- {
- if (!alignmentAnnotation.autoCalculated)
- return false;
- if ((updatingConsensus && consensus==alignmentAnnotation)
- || (updatingConservation && (conservation==alignmentAnnotation || quality==alignmentAnnotation))
- || (updatingStrucConsensus && strucConsensus==alignmentAnnotation)
- )
- {
- return true;
- }
- return false;
- }
/**
*
{
return validCharWidth;
}
-
- @Override
- public Hashtable[] getSequenceConsensusHash()
- {
- return hconsensus;
- }
-
- @Override
- public Hashtable[] getRnaStructureConsensusHash()
- {
- return hStrucConsensus;
- }
-
- @Override
- public AlignmentAnnotation getAlignmentQualityAnnot()
- {
- return quality;
- }
-
- @Override
- public AlignmentAnnotation getAlignmentConservationAnnotation()
- {
- return conservation;
- }
-
- @Override
- public boolean isClosed()
- {
- // TODO: check that this isClosed is only true after panel is closed, not before it is fully constructed.
- return alignment==null;
- }
-
- @Override
- public AlignCalcManagerI getCalcManager()
- {
- return calculator;
- }
}
// do we need to scroll the panel?
// TODO: tons of nullpointereexceptions raised here.
if (results != null && results.getSize() > 0 && av != null
- && av.alignment != null)
+ && av.getAlignment() != null)
{
- int seqIndex = av.alignment.findIndex(results);
+ int seqIndex = av.getAlignment().findIndex(results);
if (seqIndex == -1)
{
return false;
}
- SequenceI seq = av.alignment.getSequenceAt(seqIndex);
+ SequenceI seq = av.getAlignment().getSequenceAt(seqIndex);
- int[] r=results.getResults(seq, 0, av.alignment.getWidth());
+ int[] r=results.getResults(seq, 0, av.getAlignment().getWidth());
if (r == null)
{
return false;
{
return false;
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
start = av.getColumnSelection().findColumnPosition(start);
end = av.getColumnSelection().findColumnPosition(end);
if (start==end)
{
- if (!av.colSel.isVisible(r[0]))
+ if (!av.getColumnSelection().isVisible(r[0]))
{
// don't scroll - position isn't visible
return false;
public void setScrollValues(int x, int y)
{
// System.err.println("Scroll to "+x+","+y);
- if (av == null || av.alignment == null)
+ if (av == null || av.getAlignment() == null)
{
return;
}
- int width = av.alignment.getWidth();
- int height = av.alignment.getHeight();
+ int width = av.getAlignment().getWidth();
+ int height = av.getAlignment().getHeight();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
width = av.getColumnSelection().findColumnPosition(width);
}
if (av.getWrapAlignment())
{
- int maxwidth = av.alignment.getWidth();
+ int maxwidth = av.getAlignment().getWidth();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
endSeq = av.getAlignment().getHeight();
}
- int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;
+ int pagesHigh = ((av.getAlignment().getHeight() / totalSeq) + 1) * pheight;
if (av.showAnnotation)
{
pg.translate(idWidth, 0);
seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, 0);
- if (av.showAnnotation && (endSeq == av.alignment.getHeight()))
+ if (av.showAnnotation && (endSeq == av.getAlignment().getHeight()))
{
pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
alabels.drawComponent((Graphics2D) pg, idWidth);
int idWidth = getVisibleIdWidth();
- int maxwidth = av.alignment.getWidth();
- if (av.hasHiddenColumns)
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
do
{
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
pg.setFont(idPanel.idCanvas.idfont);
- SequenceI s = av.alignment.getSequenceAt(i);
+ SequenceI s = av.getAlignment().getSequenceAt(i);
String string = s.getDisplayId(av.getShowJVSuffix());
int xPos = 0;
if (av.rightAlignIds)
void makeAlignmentImage(int type, File file)
{
- int maxwidth = av.alignment.getWidth();
- if (av.hasHiddenColumns)
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
}
- int height = ((av.alignment.getHeight() + 1) * av.charHeight)
+ int height = ((av.getAlignment().getHeight() + 1) * av.charHeight)
+ scalePanel.getHeight();
int width = getVisibleIdWidth() + (maxwidth * av.charWidth);
{
try
{
- int s, sSize = av.alignment.getHeight(), res, alwidth = av.alignment
+ int s, sSize = av.getAlignment().getHeight(), res, alwidth = av.getAlignment()
.getWidth(), g, gSize, f, fSize, sy;
StringBuffer text = new StringBuffer();
PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));
{
sy = s * av.charHeight + scaleHeight;
- SequenceI seq = av.alignment.getSequenceAt(s);
+ SequenceI seq = av.getAlignment().getSequenceAt(s);
SequenceFeature[] features = seq.getDatasetSequence()
.getSequenceFeatures();
- SequenceGroup[] groups = av.alignment.findAllGroups(seq);
+ SequenceGroup[] groups = av.getAlignment().findAllGroups(seq);
for (res = 0; res < alwidth; res++)
{
text = new StringBuffer();
Object obj = null;
- if (av.alignment.isNucleotide())
+ if (av.getAlignment().isNucleotide())
{
obj = ResidueProperties.nucleotideName.get(seq.getCharAt(res)
+ "");
int cHeight = av.getAlignment().getHeight() * av.charHeight + hgap
+ annotationHeight;
- int maxwidth = av.alignment.getWidth();
- if (av.hasHiddenColumns)
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
jalview.structure.StructureSelectionManager ssm = av.getStructureSelectionManager();
ssm.removeStructureViewerListener(seqPanel, null);
ssm.removeSelectionListener(seqPanel);
- av.alignment = null;
+ av.setAlignment(null);
av = null;
}
else
// remove old automatic annotation
// add any new annotation
- Vector gr = av.alignment.getGroups(); // OrderedBy(av.alignment.getSequencesArray());
+ Vector gr = av.getAlignment().getGroups(); // OrderedBy(av.getAlignment().getSequencesArray());
// intersect alignment annotation with alignment groups
- AlignmentAnnotation[] aan = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aan = av.getAlignment().getAlignmentAnnotation();
Hashtable oldrfs = new Hashtable();
if (aan != null)
{
if (aan[an].autoCalculated && aan[an].groupRef != null)
{
oldrfs.put(aan[an].groupRef, aan[an].groupRef);
- av.alignment.deleteAnnotation(aan[an]);
+ av.getAlignment().deleteAnnotation(aan[an]);
aan[an] = null;
}
}
if (conv)
{
updateCalcs = true;
- av.alignment.addAnnotation(sg.getConservationRow(), 0);
+ av.getAlignment().addAnnotation(sg.getConservationRow(), 0);
}
if (cons)
{
updateCalcs = true;
- av.alignment.addAnnotation(sg.getConsensus(), 0);
+ av.getAlignment().addAnnotation(sg.getConsensus(), 0);
}
// refresh the annotation rows
if (updateCalcs)
@Override
public AlignmentI getAlignment()
{
- return av.alignment;
+ return av.getAlignment();
}
/**
public AnnotationColourChooser(AlignViewport av, final AlignmentPanel ap)
{
oldcs = av.getGlobalColourScheme();
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
oldgroupColours = new Hashtable();
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
}
});
- if (av.alignment.getAlignmentAnnotation() == null)
+ if (av.getAlignment().getAlignmentAnnotation() == null)
{
return;
}
adjusting = true;
Vector list = new Vector();
int index = 1;
- for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
+ for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
{
- String label = av.alignment.getAlignmentAnnotation()[i].label;
+ String label = av.getAlignment().getAlignmentAnnotation()[i].label;
if (!list.contains(label))
list.addElement(label);
else
return;
}
- currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations
+ currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations
.getSelectedIndex()];
int aboveThreshold = -1;
av.setGlobalColourScheme(acg);
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
void reset()
{
av.setGlobalColourScheme(oldcs);
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
{\r
if (GFFFormat.isSelected())\r
{\r
- text = new FeaturesFile().printGFFFormat(ap.av.alignment\r
+ text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()\r
.getDataset().getSequencesArray(),\r
getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());// ap.av.featuresDisplayed//);\r
}\r
else\r
{\r
- text = new FeaturesFile().printJalviewFormat(ap.av.alignment\r
+ text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()\r
.getDataset().getSequencesArray(),\r
getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); // ap.av.featuresDisplayed);\r
}\r
{\r
if (GFFFormat.isSelected())\r
{\r
- text = new FeaturesFile().printGFFFormat(ap.av.alignment\r
+ text = new FeaturesFile().printGFFFormat(ap.av.getAlignment()\r
.getDataset().getSequencesArray(),\r
getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());\r
}\r
else\r
{\r
- text = new FeaturesFile().printJalviewFormat(ap.av.alignment\r
+ text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment()\r
.getDataset().getSequencesArray(),\r
getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());\r
}\r
void getSelectedRow(int y)
{
int height = 0;
- AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
selectedRow = -2;
if (aa != null)
{
*/
public void actionPerformed(ActionEvent evt)
{
- AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
if (evt.getActionCommand().equals(ADDNEW))
{
AlignmentAnnotation newAnnotation = new AlignmentAnnotation(null,
- null, new Annotation[ap.av.alignment.getWidth()]);
+ null, new Annotation[ap.av.getAlignment().getWidth()]);
if (!editLabelDescription(newAnnotation))
{
return;
}
- ap.av.alignment.addAnnotation(newAnnotation);
- ap.av.alignment.setAnnotationIndex(newAnnotation, 0);
+ ap.av.getAlignment().addAnnotation(newAnnotation);
+ ap.av.getAlignment().setAnnotationIndex(newAnnotation, 0);
}
else if (evt.getActionCommand().equals(EDITNAME))
{
}
else if (evt.getActionCommand().equals(DELETE))
{
- ap.av.alignment.deleteAnnotation(aa[selectedRow]);
+ ap.av.getAlignment().deleteAnnotation(aa[selectedRow]);
}
else if (evt.getActionCommand().equals(SHOWALL))
{
if (start != end)
{
// Swap these annotations
- AlignmentAnnotation startAA = ap.av.alignment
+ AlignmentAnnotation startAA = ap.av.getAlignment()
.getAlignmentAnnotation()[start];
if (end == -1)
{
- end = ap.av.alignment.getAlignmentAnnotation().length - 1;
+ end = ap.av.getAlignment().getAlignmentAnnotation().length - 1;
}
- AlignmentAnnotation endAA = ap.av.alignment.getAlignmentAnnotation()[end];
+ AlignmentAnnotation endAA = ap.av.getAlignment().getAlignmentAnnotation()[end];
- ap.av.alignment.getAlignmentAnnotation()[end] = startAA;
- ap.av.alignment.getAlignmentAnnotation()[start] = endAA;
+ ap.av.getAlignment().getAlignmentAnnotation()[end] = startAA;
+ ap.av.getAlignment().getAlignmentAnnotation()[start] = endAA;
}
resizePanel = false;
getSelectedRow(evt.getY() - scrollOffset);
if (selectedRow > -1
- && ap.av.alignment.getAlignmentAnnotation().length > selectedRow)
+ && ap.av.getAlignment().getAlignmentAnnotation().length > selectedRow)
{
- AlignmentAnnotation aa = ap.av.alignment.getAlignmentAnnotation()[selectedRow];
+ AlignmentAnnotation aa = ap.av.getAlignment().getAlignmentAnnotation()[selectedRow];
StringBuffer desc = new StringBuffer();
if (aa.description != null
*/
public void mouseClicked(MouseEvent evt)
{
- AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = ap.av.getAlignment().getAlignmentAnnotation();
if (SwingUtilities.isLeftMouseButton(evt))
{
if (selectedRow > -1 && selectedRow < aa.length)
sq.setDatasetSequence(dseqs[0]);
}
Alignment ds = new Alignment(dseqs);
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
omitHidden = av.getColumnSelection().getVisibleSequenceStrings(0,
sq.getLength(), seqs);
.setContents(new StringSelection(output), Desktop.instance);
Vector hiddenColumns = null;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
hiddenColumns = new Vector();
for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++)
g.translate(0, scrollOffset);
g.setColor(Color.black);
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
int fontHeight = g.getFont().getSize();
int y = 0;
int x = 0;
public int calcPanelHeight()
{
// setHeight of panels
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
int height = 0;
if (aa != null)
*/
public void actionPerformed(ActionEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
return;
{
int index = av.getColumnSelection().columnAt(i);
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
if (anot[index] == null)
{
int index = av.getColumnSelection().columnAt(i);
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
if (anot[index] == null)
{
int index = av.getColumnSelection().columnAt(i);
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
if (anot[index] == null)
{
String collatedInput = "";
String last = "";
+ // TODO: refactor and save av.getColumnSelection for efficiency
for (int i = 0; i < columnSelection.size(); i++)
{
int index = columnSelection.columnAt(i);
// always check for current display state - just in case
- if (!av.colSel.isVisible(index))
+ if (!av.getColumnSelection().isVisible(index))
continue;
String tlabel = null;
if (anot[index] != null)
public void mousePressed(MouseEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
return;
/*
* Just display the needed structure options
*/
- if (av.alignment.isNucleotide() == true)
+ if (av.getAlignment().isNucleotide() == true)
{
item = new JMenuItem(STEM);
item.addActionListener(this);
{
if (graphStretch > -1)
{
- av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
+ av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight += graphStretchY
- evt.getY();
- if (av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight < 0)
+ if (av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight < 0)
{
- av.alignment.getAlignmentAnnotation()[graphStretch].graphHeight = 0;
+ av.getAlignment().getAlignmentAnnotation()[graphStretch].graphHeight = 0;
}
graphStretchY = evt.getY();
adjustPanelHeight();
*/
public void mouseMoved(MouseEvent evt)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
if (aa == null)
{
int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
{
if (activeRow != -1)
{
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();
+ AlignmentAnnotation[] aa = av.getAlignment().getAlignmentAnnotation();
AlignmentAnnotation anot = aa[activeRow];
if (anot.description.equals("secondary structure"))
{
if ((horizontal == 0) || gg == null
- || av.alignment.getAlignmentAnnotation() == null
- || av.alignment.getAlignmentAnnotation().length < 1
- || av.updatingConsensus || av.updatingConservation)
+ || av.getAlignment().getAlignmentAnnotation() == null
+ || av.getAlignment().getAlignmentAnnotation().length < 1
+ || av.isCalcInProgress())
{
repaint();
return;
*/
public void drawComponent(Graphics g, int startRes, int endRes)
{
- if (av.updatingConsensus || av.updatingConservation)
+ if (av.isCalcInProgress())
{
if (image == null)
{
fm = g.getFontMetrics();
}
- if ((av.alignment.getAlignmentAnnotation() == null)
- || (av.alignment.getAlignmentAnnotation().length < 1))
+ if ((av.getAlignment().getAlignmentAnnotation() == null)
+ || (av.getAlignment().getAlignmentAnnotation().length < 1))
{
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
source.viewport.gatherViewsHere = true;
source.viewport.explodedPosition = source.getBounds();
JInternalFrame[] frames = desktop.getAllFrames();
- String viewId = source.viewport.sequenceSetID;
+ String viewId = source.viewport.getSequenceSetId();
for (int t = 0; t < frames.length; t++)
{
{
minmax = new Hashtable();
}
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ AlignmentI alignment=av.getAlignment();
+ for (int i = 0; i < alignment.getHeight(); i++)
{
- SequenceFeature[] features = av.alignment.getSequenceAt(i)
+ SequenceFeature[] features = alignment.getSequenceAt(i)
.getDatasetSequence().getSequenceFeatures();
if (features == null)
Vector allGroups = new Vector();
SequenceFeature[] tmpfeatures;
String group;
- for (int i = 0; i < af.getViewport().alignment.getHeight(); i++)
+ for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
{
- if (af.getViewport().alignment.getSequenceAt(i).getDatasetSequence()
+ if (af.getViewport().getAlignment().getSequenceAt(i).getDatasetSequence()
.getSequenceFeatures() == null)
{
continue;
}
- tmpfeatures = af.getViewport().alignment.getSequenceAt(i)
+ tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
.getDatasetSequence().getSequenceFeatures();
int index = 0;
// Find out which features should be visible depending on which groups
// are selected / deselected
// and recompute average width ordering
- for (int i = 0; i < af.getViewport().alignment.getHeight(); i++)
+ for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
{
- tmpfeatures = af.getViewport().alignment.getSequenceAt(i)
+ tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
.getDatasetSequence().getSequenceFeatures();
if (tmpfeatures == null)
{
// TODO: add switches to control what is searched - sequences, IDS,
// descriptions, features
jalview.analysis.Finder finder = new jalview.analysis.Finder(
- av.alignment, av.getSelectionGroup(), seqIndex, resIndex);
+ av.getAlignment(), av.getSelectionGroup(), seqIndex, resIndex);
finder.setCaseSensitive(caseSensitive.isSelected());
finder.setFindAll(findAll);
gg.drawString(s.getDisplayId(av.getShowJVSuffix()), xPos,
(((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));
- if (av.hasHiddenRows && av.showHiddenMarkers)
+ if (av.hasHiddenRows() && av.showHiddenMarkers)
{
drawMarker(i, starty, ypos);
}
if (av.getWrapAlignment())
{
- int maxwidth = av.alignment.getWidth();
- int alheight = av.alignment.getHeight();
+ int maxwidth = av.getAlignment().getWidth();
+ int alheight = av.getAlignment().getHeight();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
{
for (int i = starty; i < alheight; i++)
{
- SequenceI s = av.alignment.getSequenceAt(i);
- if (av.hasHiddenRows)
+ SequenceI s = av.getAlignment().getSequenceAt(i);
+ if (av.hasHiddenRows())
{
setHiddenFont(s);
}
// Now draw the id strings
for (int i = starty; i < endy; i++)
{
- sequence = av.alignment.getSequenceAt(i);
+ sequence = av.getAlignment().getSequenceAt(i);
if (sequence == null)
{
continue;
}
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
setHiddenFont(sequence);
}
(((i - starty) * av.charHeight) + av.charHeight)
- (av.charHeight / 5));
- if (av.hasHiddenRows && av.showHiddenMarkers)
+ if (av.hasHiddenRows() && av.showHiddenMarkers)
{
drawMarker(i, starty, 0);
}
void drawMarker(int i, int starty, int yoffset)
{
- SequenceI[] hseqs = av.alignment.getHiddenSequences().hiddenSequences;
+ SequenceI[] hseqs = av.getAlignment().getHiddenSequences().hiddenSequences;
// Use this method here instead of calling hiddenSeq adjust
// 3 times.
int hSize = hseqs.length;
Font bold = new Font(av.getFont().getName(), Font.BOLD, av.getFont()
.getSize());
- if (av.hiddenRepSequences != null
- && av.hiddenRepSequences.containsKey(seq))
+ if (av.isHiddenRepSequence(seq))
{
gg.setFont(bold);
}
SeqPanel sp = alignPanel.seqPanel;
int seq = Math.max(0, sp.findSeq(e));
String tmp;
- if (seq > -1 && seq < av.alignment.getHeight())
+ if (seq > -1 && seq < av.getAlignment().getHeight())
{
- SequenceI sequence = av.alignment.getSequenceAt(seq);
+ SequenceI sequence = av.getAlignment().getSequenceAt(seq);
StringBuffer tip = new StringBuffer();
tip.append("<i>");
}
if (mouseDragging && (e.getY() >= getHeight())
- && (av.alignment.getHeight() > av.getEndSeq()))
+ && (av.getAlignment().getHeight() > av.getEndSeq()))
{
scrollThread = new ScrollThread(false);
}
{
av.setSelectionGroup(new SequenceGroup());
av.getSelectionGroup().setStartRes(0);
- av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1);
+ av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1);
}
if (e.isShiftDown() && (lastid != -1))
return;
}
- int index = av.alignment.findIndex((SequenceI) found.get(0));
+ int index = av.getAlignment().findIndex((SequenceI) found.get(0));
// do we need to scroll the panel?
if ((av.getStartSeq() > index) || (av.getEndSeq() < index))
object.setCreationDate(new java.util.Date(System.currentTimeMillis()));
object.setVersion(jalview.bin.Cache.getProperty("VERSION"));
- jalview.datamodel.AlignmentI jal = av.alignment;
+ jalview.datamodel.AlignmentI jal = av.getAlignment();
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
jal = jal.getHiddenSequences().getFullAlignment();
}
jseq.setId(id); // jseq id should be a string not a number
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- jseq.setHidden(av.alignment.getHiddenSequences().isHidden(jds));
+ jseq.setHidden(av.getAlignment().getHiddenSequences().isHidden(jds));
- if (av.hiddenRepSequences != null
- && av.hiddenRepSequences.containsKey(jal.getSequenceAt(i)))
+ if (av.isHiddenRepSequence(jal.getSequenceAt(i)))
{
- jalview.datamodel.SequenceI[] reps = ((jalview.datamodel.SequenceGroup) av.hiddenRepSequences
- .get(jal.getSequenceAt(i))).getSequencesInOrder(jal);
+ jalview.datamodel.SequenceI[] reps = av.getRepresentedSequences(jal.getSequenceAt(i)).getSequencesInOrder(jal);
for (int h = 0; h < reps.length; h++)
{
jms.addJSeq(jseq);
}
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- jal = av.alignment;
+ jal = av.getAlignment();
}
// SAVE MAPPINGS
if (jal.getCodonFrames() != null && jal.getCodonFrames().length > 0)
{
TreePanel tp = (TreePanel) frames[t];
- if (tp.treeCanvas.av.alignment == jal)
+ if (tp.treeCanvas.av.getAlignment() == jal)
{
Tree tree = new Tree();
tree.setTitle(tp.getTitle());
an.setLabel(aa[i].label);
- if (aa[i] == av.quality || aa[i] == av.conservation
- || aa[i] == av.consensus || aa[i].autoCalculated)
+ if (aa[i] == av.getAlignmentQualityAnnot() || aa[i] == av.getAlignmentConservationAnnotation()
+ || aa[i] == av.getAlignmentConsensusAnnotation() || aa[i].autoCalculated)
{
// new way of indicating autocalculated annotation -
an.setAutoCalculated(aa[i].autoCalculated);
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
if (av.getColumnSelection() == null
|| av.getColumnSelection().getHiddenColumns() == null)
for (int i = 0; i < JSEQ.length; i++)
{
- af.viewport.setSequenceColour(af.viewport.alignment.getSequenceAt(i),
+ af.viewport.setSequenceColour(af.viewport.getAlignment().getSequenceAt(i),
new java.awt.Color(JSEQ[i].getColour()));
}
jalview.gui.AlignViewport av = (jalview.gui.AlignViewport) viewportsAdded
.get(uniqueSeqSetId);
- af.viewport.sequenceSetID = uniqueSeqSetId;
+ af.viewport.setSequenceSetId(uniqueSeqSetId);
if (av != null)
{
// propagate shared settings to this new view
else if (view.getBgColour().startsWith("Annotation"))
{
// int find annotation
- if (af.viewport.alignment.getAlignmentAnnotation() != null)
+ if (af.viewport.getAlignment().getAlignmentAnnotation() != null)
{
- for (int i = 0; i < af.viewport.alignment
+ for (int i = 0; i < af.viewport.getAlignment()
.getAlignmentAnnotation().length; i++)
{
- if (af.viewport.alignment.getAlignmentAnnotation()[i].label
+ if (af.viewport.getAlignment().getAlignmentAnnotation()[i].label
.equals(view.getAnnotationColours().getAnnotation()))
{
- if (af.viewport.alignment.getAlignmentAnnotation()[i]
+ if (af.viewport.getAlignment().getAlignmentAnnotation()[i]
.getThreshold() == null)
{
- af.viewport.alignment.getAlignmentAnnotation()[i]
+ af.viewport.getAlignment().getAlignmentAnnotation()[i]
.setThreshold(new jalview.datamodel.GraphLine(view
.getAnnotationColours().getThreshold(),
"Threshold", java.awt.Color.black)
.equals("None"))
{
cs = new AnnotationColourGradient(
- af.viewport.alignment.getAlignmentAnnotation()[i],
+ af.viewport.getAlignment().getAlignmentAnnotation()[i],
new java.awt.Color(view.getAnnotationColours()
.getMinColour()), new java.awt.Color(view
.getAnnotationColours().getMaxColour()),
.startsWith("ucs"))
{
cs = new AnnotationColourGradient(
- af.viewport.alignment.getAlignmentAnnotation()[i],
+ af.viewport.getAlignment().getAlignmentAnnotation()[i],
GetUserColourScheme(jms, view
.getAnnotationColours().getColourScheme()),
view.getAnnotationColours().getAboveThreshold());
else
{
cs = new AnnotationColourGradient(
- af.viewport.alignment.getAlignmentAnnotation()[i],
+ af.viewport.getAlignment().getAlignmentAnnotation()[i],
ColourSchemeProperty.getColour(al, view
.getAnnotationColours().getColourScheme()),
view.getAnnotationColours().getAboveThreshold());
* if
* (view.getAnnotationColours().getColourScheme().equals("None"
* )) { sg.cs = new AnnotationColourGradient(
- * af.viewport.alignment.getAlignmentAnnotation()[i], new
+ * af.viewport.getAlignment().getAlignmentAnnotation()[i], new
* java.awt.Color(view.getAnnotationColours().
* getMinColour()), new
* java.awt.Color(view.getAnnotationColours().
*/
{
sg.cs = new AnnotationColourGradient(
- af.viewport.alignment.getAlignmentAnnotation()[i],
+ af.viewport.getAlignment().getAlignmentAnnotation()[i],
sg.cs, view.getAnnotationColours()
.getAboveThreshold());
}
if (cs != null)
{
cs.setThreshold(view.getPidThreshold(), true);
- cs.setConsensus(af.viewport.hconsensus);
+ cs.setConsensus(af.viewport.getSequenceConsensusHash());
}
}
}
if (view.hasIgnoreGapsinConsensus())
{
- af.viewport.ignoreGapsInConsensusCalculation = view
- .getIgnoreGapsinConsensus();
+ af.viewport.setIgnoreGapsConsensus(view
+ .getIgnoreGapsinConsensus(), null);
}
if (view.hasFollowHighlight())
{
}
if (view.hasShowSequenceLogo())
{
- af.viewport.showSequenceLogo = view.getShowSequenceLogo();
+ af.viewport.setShowSequenceLogo(view.getShowSequenceLogo());
}
else
{
- af.viewport.showSequenceLogo = false;
+ af.viewport.setShowSequenceLogo(false);
}
if (view.hasShowDbRefTooltip())
{
af.closeMenuItem_actionPerformed(true);
/*
- * if(ap.av.alignment.getAlignmentAnnotation()!=null) { for(int i=0;
- * i<ap.av.alignment.getAlignmentAnnotation().length; i++) {
- * if(!ap.av.alignment.getAlignmentAnnotation()[i].autoCalculated) {
- * af.alignPanel.av.alignment.getAlignmentAnnotation()[i] =
- * ap.av.alignment.getAlignmentAnnotation()[i]; } } }
+ * if(ap.av.getAlignment().getAlignmentAnnotation()!=null) { for(int i=0;
+ * i<ap.av.getAlignment().getAlignmentAnnotation().length; i++) {
+ * if(!ap.av.getAlignment().getAlignmentAnnotation()[i].autoCalculated) {
+ * af.alignPanel.av.getAlignment().getAlignmentAnnotation()[i] =
+ * ap.av.getAlignment().getAlignmentAnnotation()[i]; } } }
*/
return af.alignPanel;
\r
for (int i = 0; i < JSEQ.length; i++)\r
{\r
- af.viewport.setSequenceColour(af.viewport.alignment.getSequenceAt(i),\r
+ af.viewport.setSequenceColour(af.viewport.getAlignment().getSequenceAt(i),\r
new java.awt.Color(JSEQ[i].getColour()));\r
}\r
\r
if (cs != null)\r
{\r
cs.setThreshold(view.getPidThreshold(), true);\r
- cs.setConsensus(af.viewport.hconsensus);\r
+ cs.setConsensus(af.viewport.getSequenceConsensusHash());\r
}\r
}\r
\r
fr = new FeatureRenderer(ap);
// scale the initial size of overviewpanel to shape of alignment
- float initialScale = (float) av.alignment.getWidth()
- / (float) av.alignment.getHeight();
+ float initialScale = (float) av.getAlignment().getWidth()
+ / (float) av.getAlignment().getHeight();
- if (av.conservation == null)
+ if (av.getAlignmentConservationAnnotation()== null)
{
graphHeight = 0;
}
- if (av.alignment.getWidth() > av.alignment.getHeight())
+ if (av.getAlignment().getWidth() > av.getAlignment().getHeight())
{
// wider
width = 400;
if (boxX > (width - boxWidth))
{
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
// Try smallest possible box
boxWidth = (int) ((av.endRes - av.startRes + 1) * av.getCharWidth() * scalew);
int col = (int) (boxX / scalew / av.getCharWidth());
int row = (int) (boxY / scaleh / av.getCharHeight());
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
if (!av.getColumnSelection().isVisible(col))
{
col = av.getColumnSelection().findColumnPosition(col);
}
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(
+ row = av.getAlignment().getHiddenSequences().findIndexWithoutHiddenSeqs(
row);
}
fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());
}
- int alwidth = av.alignment.getWidth();
- int alheight = av.alignment.getHeight()
- + av.alignment.getHiddenSequences().getSize();
+ int alwidth = av.getAlignment().getWidth();
+ int alheight = av.getAlignment().getHeight()
+ + av.getAlignment().getHiddenSequences().getSize();
setPreferredSize(new Dimension(width, sequencesHeight + graphHeight));
lastrow = (int) (row * sampleRow);
hiddenRow = false;
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow);
+ seq = av.getAlignment().getHiddenSequences().getHiddenSequence(lastrow);
if (seq == null)
{
- int index = av.alignment.getHiddenSequences()
+ int index = av.getAlignment().getHiddenSequences()
.findIndexWithoutHiddenSeqs(lastrow);
- seq = av.alignment.getSequenceAt(index);
+ seq = av.getAlignment().getSequenceAt(index);
}
else
{
}
else
{
- seq = av.alignment.getSequenceAt(lastrow);
+ seq = av.getAlignment().getSequenceAt(lastrow);
}
if (seq == null)
}
if (hiddenRow
- || (av.hasHiddenColumns && !av.getColumnSelection()
+ || (av.hasHiddenColumns() && !av.getColumnSelection()
.isVisible(lastcol)))
{
color = new Color(color).darker().darker().getRGB();
}
}
- if (av.conservation != null)
+ if (av.getAlignmentConservationAnnotation()!= null)
{
renderer.updateFromAlignViewport(av);
for (col = 0; col < width; col++)
lastcol = (int) (col * sampleCol);
{
mg.translate(col, sequencesHeight);
- renderer.drawGraph(mg, av.conservation,
+ renderer.drawGraph(mg, av.getAlignmentConservationAnnotation(),
(int) (sampleCol) + 1, graphHeight,
(int) (col * sampleCol), (int) (col * sampleCol) + 1);
mg.translate(-col, -sequencesHeight);
*/
public void setBoxPosition()
{
- int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth();
- int fullsizeHeight = (av.alignment.getHeight() + av.alignment
+ int fullsizeWidth = av.getAlignment().getWidth() * av.getCharWidth();
+ int fullsizeHeight = (av.getAlignment().getHeight() + av.getAlignment()
.getHiddenSequences().getSize()) * av.getCharHeight();
int startRes = av.getStartRes();
int endRes = av.getEndRes();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
startRes = av.getColumnSelection().adjustForHiddenColumns(startRes);
endRes = av.getColumnSelection().adjustForHiddenColumns(endRes);
int startSeq = av.startSeq;
int endSeq = av.endSeq;
- if (av.hasHiddenRows)
+ if (av.hasHiddenRows())
{
- startSeq = av.alignment.getHiddenSequences().adjustForHiddenSeqs(
+ startSeq = av.getAlignment().getHiddenSequences().adjustForHiddenSeqs(
startSeq);
- endSeq = av.alignment.getHiddenSequences()
+ endSeq = av.getAlignment().getHiddenSequences()
.adjustForHiddenSeqs(endSeq);
}
boxX = (int) (startRes * av.getCharWidth() * scalew);
boxY = (int) (startSeq * av.getCharHeight() * scaleh);
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew);
}
seqstrings = av.getAlignmentView(av.getSelectionGroup() != null);
if (av.getSelectionGroup() == null)
{
- seqs = av.alignment.getSequencesArray();
+ seqs = av.getAlignment().getSequencesArray();
}
else
{
- seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+ seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
SeqCigar sq[] = seqstrings.getSequences();
int length = sq[0].getWidth();
if (validateSequences && comp instanceof AlignmentPanel
&& source instanceof AlignmentPanel)
{
- validateSequences(((AlignmentPanel) source).av.alignment,
- ((AlignmentPanel) comp).av.alignment);
+ validateSequences(((AlignmentPanel) source).av.getAlignment(),
+ ((AlignmentPanel) comp).av.getAlignment());
}
if (comp instanceof AlignmentPanel && alignmentChanged)
if (av.getSelectionGroup() == null)
{
- seqs = av.alignment.getSequencesArray();
+ seqs = av.getAlignment().getSequencesArray();
}
else
{
- seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+ seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
- String type = (av.alignment.isNucleotide()) ? AlignSeq.DNA
+ String type = (av.getAlignment().isNucleotide()) ? AlignSeq.DNA
: AlignSeq.PEP;
float[][] scores = new float[seqs.length][seqs.length];
}
else
{
- if (ap.av.alignment.isNucleotide() == false)
+ if (ap.av.getAlignment().isNucleotide() == false)
{
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)
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)
}
}
// for the case when no sequences are even visible
- if (ap.av.hasHiddenRows) {
+ if (ap.av.hasHiddenRows()) {
{
menuItem = new JMenuItem("Reveal All");
menuItem.addActionListener(new ActionListener()
editMenu.setVisible(false);
}
- if (!ap.av.alignment.getGroups().contains(sg))
+ if (!ap.av.getAlignment().getGroups().contains(sg))
{
unGroupMenuItem.setVisible(false);
}
{
SequenceGroup sg = getGroup();
sg.cs = new ClustalxColourScheme(
- sg.getSequences(ap.av.hiddenRepSequences),
- ap.av.alignment.getWidth());
+ sg.getSequences(ap.av.getHiddenRepSequences()),
+ ap.av.getAlignment().getWidth());
refresh();
}
if (abovePIDColour.isSelected())
{
sg.cs.setConsensus(AAFrequency.calculate(
- sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+ sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
sg.getEndRes() + 1));
int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
SequenceGroup sg = getGroup();
sg.cs = new PIDColourScheme();
sg.cs.setConsensus(AAFrequency.calculate(
- sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+ 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.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
sg.getEndRes() + 1));
refresh();
{
Conservation c = new Conservation("Group",
ResidueProperties.propHash, 3,
- sg.getSequences(ap.av.hiddenRepSequences), sg.getStartRes(),
+ sg.getSequences(ap.av.getHiddenRepSequences()), sg.getStartRes(),
sg.getEndRes() + 1);
c.calculate();
// 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);
refresh();
}
}
ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
- sg.getSequencesAsArray(ap.av.hiddenRepSequences), startEnd,
+ sg.getSequencesAsArray(ap.av.getHiddenRepSequences()), startEnd,
caseChange);
ap.alignFrame.addHistoryItem(caseCommand);
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++)
public void discoverPDB_actionPerformed()
{
+ // TODO: test: verify PDB sequence discovery behaves correctly for group selections
- final SequenceI[] sequences = ((ap.av.selectionGroup == null) ? new SequenceI[]
+ 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()
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();
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);
+ sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
+ sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
ap.alignFrame.addHistoryItem(editCommand);
public RNAHelicesColourChooser(AlignViewport av, final AlignmentPanel ap)
{
oldcs = av.getGlobalColourScheme();
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
oldgroupColours = new Hashtable();
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
adjusting = true;
Vector list = new Vector();
int index = 1;
- for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)
+ for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
{
- String label = av.alignment.getAlignmentAnnotation()[i].label;
+ String label = av.getAlignment().getAlignmentAnnotation()[i].label;
if (!list.contains(label))
list.addElement(label);
else
return;
}
- currentAnnotation = av.alignment.getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
+ currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
RNAHelicesColour rhc = null;
av.setGlobalColourScheme(rhc);
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
void reset()
{
av.setGlobalColourScheme(oldcs);
- if (av.alignment.getGroups() != null)
+ if (av.getAlignment().getGroups() != null)
{
- Vector allGroups = ap.av.alignment.getGroups();
+ Vector allGroups = ap.av.getAlignment().getGroups();
SequenceGroup sg;
for (int g = 0; g < allGroups.size(); g++)
{
if ((sg != null) && (sg.getSize() >= 1))
{
- originalSequences = sg.getSequencesInOrder(ap.av.alignment);
+ originalSequences = sg.getSequencesInOrder(ap.av.getAlignment());
start = sg.getStartRes();
end = sg.getEndRes();
}
else
{
- originalSequences = ap.av.alignment.getSequencesArray();
+ originalSequences = ap.av.getAlignment().getSequencesArray();
start = 0;
- end = ap.av.alignment.getWidth();
+ end = ap.av.getAlignment().getWidth();
}
height = originalSequences.length;
redundancy[i] = 0f;
}
- if (ap.av.hasHiddenColumns)
+ if (ap.av.hasHiddenColumns())
{
omitHidden = ap.av.getViewAsString(sg != null);
}
}
EditCommand cut = new EditCommand("Remove Redundancy",
- EditCommand.CUT, deleted, 0, width, ap.av.alignment);
+ EditCommand.CUT, deleted, 0, width, ap.av.getAlignment());
for (int i = 0; i < del.size(); i++)
{
- ap.av.alignment.deleteSequence(deleted[i]);
+ ap.av.getAlignment().deleteSequence(deleted[i]);
PaintRefresher.Refresh(this, ap.av.getSequenceSetId(), true, true);
if (sg != null)
{
aps[a].av.setSelectionGroup(new SequenceGroup());
aps[a].av.getSelectionGroup().addOrRemove(found, true);
aps[a].av.getSelectionGroup().setEndRes(
- aps[a].av.alignment.getWidth() - 1);
+ aps[a].av.getAlignment().getWidth() - 1);
}
}
PaintRefresher.Refresh(this, av.getSequenceSetId());
int x = (evt.getX() / av.getCharWidth()) + av.getStartRes();
final int res;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
x = av.getColumnSelection().adjustForHiddenColumns(x);
}
- if (x >= av.alignment.getWidth())
+ if (x >= av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
else
{
{
av.hideColumns(res, res);
if (av.getSelectionGroup() != null
- && av.getSelectionGroup().getSize() == av.alignment
+ && av.getSelectionGroup().getSize() == av.getAlignment()
.getHeight())
{
av.setSelectionGroup(null);
av.getColumnSelection().addElement(res);
SequenceGroup sg = new SequenceGroup();
// try to be as quick as possible
- SequenceI[] iVec = av.alignment.getSequencesArray();
+ SequenceI[] iVec = av.getAlignment().getSequencesArray();
for (int i = 0; i < iVec.length; i++)
{
sg.addSequence(iVec[i], false);
int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
- if (res >= av.alignment.getWidth())
+ if (res >= av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
if (!stretchingGroup)
res = 0;
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
- if (res >= av.alignment.getWidth())
+ if (res >= av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
if (res < min)
public void mouseMoved(MouseEvent evt)
{
- if (!av.hasHiddenColumns)
+ if (!av.hasHiddenColumns())
{
return;
}
for (int i = 0; i < cs.size(); i++)
{
int sel = cs.columnAt(i);
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
if (cs.isVisible(sel))
{
}
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
gg.setColor(Color.blue);
int res;
for (int i = scalestartx; i < endx; i += 10)
{
int value = i;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
value = av.getColumnSelection().adjustForHiddenColumns(value);
}
FontMetrics fm = getFontMetrics(av.getFont());
ypos += av.charHeight;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
startx = av.getColumnSelection().adjustForHiddenColumns(startx);
endx = av.getColumnSelection().adjustForHiddenColumns(endx);
}
- int maxwidth = av.alignment.getWidth();
- if (av.hasHiddenColumns)
+ int maxwidth = av.getAlignment().getWidth();
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
// WEST SCALE
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
- SequenceI seq = av.alignment.getSequenceAt(i);
+ SequenceI seq = av.getAlignment().getSequenceAt(i);
int index = startx;
int value = -1;
continue;
}
- value = av.alignment.getSequenceAt(i).findPosition(index);
+ value = av.getAlignment().getSequenceAt(i).findPosition(index);
break;
}
{
ypos += av.charHeight;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
endx = av.getColumnSelection().adjustForHiddenColumns(endx);
}
SequenceI seq;
// EAST SCALE
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
- seq = av.alignment.getSequenceAt(i);
+ seq = av.getAlignment().getSequenceAt(i);
int index = endx;
int value = -1;
String mask = "00";
int maxWidth = 0;
int tmp;
- for (int i = 0; i < av.alignment.getHeight(); i++)
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)
{
- tmp = av.alignment.getSequenceAt(i).getEnd();
+ tmp = av.getAlignment().getSequenceAt(i).getEnd();
if (tmp > maxWidth)
{
maxWidth = tmp;
int endx;
int ypos = hgap;
- int maxwidth = av.alignment.getWidth() - 1;
+ int maxwidth = av.getAlignment().getWidth() - 1;
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
}
drawNorthScale(g, startRes, endx, ypos);
}
- if (av.hasHiddenColumns && av.showHiddenMarkers)
+ if (av.hasHiddenColumns() && av.showHiddenMarkers)
{
g.setColor(Color.blue);
int res;
void drawPanel(Graphics g1, int startRes, int endRes, int startSeq,
int endSeq, int offset)
{
- if (!av.hasHiddenColumns)
+ if (!av.hasHiddenColumns())
{
draw(g1, startRes, endRes, startSeq, endSeq, offset);
}
// ///////////////////////////
for (int i = startSeq; i < endSeq; i++)
{
- nextSeq = av.alignment.getSequenceAt(i);
+ nextSeq = av.getAlignment().getSequenceAt(i);
if (nextSeq == null)
{
// occasionally, a race condition occurs such that the alignment row is
// empty
continue;
}
- sr.drawSequence(nextSeq, av.alignment.findAllGroups(nextSeq),
+ sr.drawSequence(nextSeq, av.getAlignment().findAllGroups(nextSeq),
startRes, endRes, offset + ((i - startSeq) * av.charHeight));
if (av.showSequenceFeatures)
}
if (av.getSelectionGroup() != null
- || av.alignment.getGroups().size() > 0)
+ || av.getAlignment().getGroups().size() > 0)
{
drawGroupsBoundaries(g, startRes, endRes, startSeq, endSeq, offset);
}
int groupIndex = -1;
int visWidth = (endRes - startRes + 1) * av.charWidth;
- if ((group == null) && (av.alignment.getGroups().size() > 0))
+ if ((group == null) && (av.getAlignment().getGroups().size() > 0))
{
- group = (SequenceGroup) av.alignment.getGroups().elementAt(0);
+ group = (SequenceGroup) av.getAlignment().getGroups().elementAt(0);
groupIndex = 0;
}
if ((sx <= (endRes - startRes) * av.charWidth)
&& group.getSequences(null).contains(
- av.alignment.getSequenceAt(i)))
+ av.getAlignment().getSequenceAt(i)))
{
if ((bottom == -1)
&& !group.getSequences(null).contains(
- av.alignment.getSequenceAt(i + 1)))
+ av.getAlignment().getSequenceAt(i + 1)))
{
bottom = sy + av.charHeight;
}
{
if (((top == -1) && (i == 0))
|| !group.getSequences(null).contains(
- av.alignment.getSequenceAt(i - 1)))
+ av.getAlignment().getSequenceAt(i - 1)))
{
top = sy;
}
g.setStroke(new BasicStroke());
- if (groupIndex >= av.alignment.getGroups().size())
+ if (groupIndex >= av.getAlignment().getGroups().size())
{
break;
}
- group = (SequenceGroup) av.alignment.getGroups().elementAt(
+ group = (SequenceGroup) av.getAlignment().getGroups().elementAt(
groupIndex);
- } while (groupIndex < av.alignment.getGroups().size());
+ } while (groupIndex < av.getAlignment().getGroups().size());
}
res = (x / av.getCharWidth()) + av.getStartRes();
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
res = av.getColumnSelection().adjustForHiddenColumns(res);
}
y -= hgap;
seq = Math.min((y % cHeight) / av.getCharHeight(),
- av.alignment.getHeight() - 1);
+ av.getAlignment().getHeight() - 1);
}
else
{
seq = Math.min((y / av.getCharHeight()) + av.getStartSeq(),
- av.alignment.getHeight() - 1);
+ av.getAlignment().getHeight() - 1);
}
return seq;
{
seqCanvas.cursorX += dx;
seqCanvas.cursorY += dy;
- if (av.hasHiddenColumns && !av.colSel.isVisible(seqCanvas.cursorX))
+ if (av.hasHiddenColumns() && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
{
int original = seqCanvas.cursorX - dx;
- int maxWidth = av.alignment.getWidth();
+ int maxWidth = av.getAlignment().getWidth();
- while (!av.colSel.isVisible(seqCanvas.cursorX)
+ while (!av.getColumnSelection().isVisible(seqCanvas.cursorX)
&& seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0)
{
seqCanvas.cursorX += dx;
}
if (seqCanvas.cursorX >= maxWidth
- || !av.colSel.isVisible(seqCanvas.cursorX))
+ || !av.getColumnSelection().isVisible(seqCanvas.cursorX))
{
seqCanvas.cursorX = original;
}
{
seqCanvas.cursorX = 0;
}
- else if (seqCanvas.cursorX > av.alignment.getWidth() - 1)
+ else if (seqCanvas.cursorX > av.getAlignment().getWidth() - 1)
{
- seqCanvas.cursorX = av.alignment.getWidth() - 1;
+ seqCanvas.cursorX = av.getAlignment().getWidth() - 1;
}
if (seqCanvas.cursorY < 0)
{
seqCanvas.cursorY = 0;
}
- else if (seqCanvas.cursorY > av.alignment.getHeight() - 1)
+ else if (seqCanvas.cursorY > av.getAlignment().getHeight() - 1)
{
- seqCanvas.cursorY = av.alignment.getHeight() - 1;
+ seqCanvas.cursorY = av.getAlignment().getHeight() - 1;
}
endEditing();
}
if (!av.wrapAlignment)
{
- while (seqCanvas.cursorX < av.colSel
+ while (seqCanvas.cursorX < av.getColumnSelection()
.adjustForHiddenColumns(av.startRes))
{
if (!ap.scrollRight(false))
break;
}
}
- while (seqCanvas.cursorX > av.colSel
+ while (seqCanvas.cursorX > av.getColumnSelection()
.adjustForHiddenColumns(av.endRes))
{
if (!ap.scrollRight(true))
}
}
}
- setStatusMessage(av.alignment.getSequenceAt(seqCanvas.cursorY),
+ setStatusMessage(av.getAlignment().getSequenceAt(seqCanvas.cursorY),
seqCanvas.cursorX, seqCanvas.cursorY);
seqCanvas.repaint();
if (av.getSelectionGroup() != null)
{
- SequenceGroup sg = av.selectionGroup;
+ SequenceGroup sg = av.getSelectionGroup();
// Find the top and bottom of this group
- int min = av.alignment.getHeight(), max = 0;
+ int min = av.getAlignment().getHeight(), max = 0;
for (int i = 0; i < sg.getSize(); i++)
{
- int index = av.alignment.findIndex(sg.getSequenceAt(i));
+ int index = av.getAlignment().findIndex(sg.getSequenceAt(i));
if (index > max)
{
max = index;
sg.getSequences(null).clear();
for (int i = min; i < max; i++)
{
- sg.addSequence(av.alignment.getSequenceAt(i), false);
+ sg.addSequence(av.getAlignment().getSequenceAt(i), false);
}
}
}
tooltipText.setLength(6); // Cuts the buffer back to <html>
- SequenceGroup[] groups = av.alignment.findAllGroups(sequence);
+ SequenceGroup[] groups = av.getAlignment().findAllGroups(sequence);
if (groups != null)
{
for (int g = 0; g < groups.length; g++)
+ sequence.getName());
Object obj = null;
- if (av.alignment.isNucleotide())
+ if (av.getAlignment().isNucleotide())
{
obj = ResidueProperties.nucleotideName.get(sequence.getCharAt(res)
+ "");
boolean fixedColumns = false;
SequenceGroup sg = av.getSelectionGroup();
- SequenceI seq = av.alignment.getSequenceAt(startseq);
+ SequenceI seq = av.getAlignment().getSequenceAt(startseq);
// No group, but the sequence may represent a group
- if (!groupEditing && av.hasHiddenRows)
+ if (!groupEditing && av.hasHiddenRows())
{
- if (av.hiddenRepSequences != null
- && av.hiddenRepSequences.containsKey(seq))
+ if (av.isHiddenRepSequence(seq))
{
- sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+ sg = av.getRepresentedSequences(seq);
groupEditing = true;
}
}
// Are we editing within a selection group?
if (groupEditing
- || (sg != null && sg.getSequences(av.hiddenRepSequences)
+ || (sg != null && sg.getSequences(av.getHiddenRepSequences())
.contains(seq)))
{
fixedColumns = true;
// but the sequence represents a group
if (sg == null)
{
- if (av.hiddenRepSequences == null
- || !av.hiddenRepSequences.containsKey(seq))
+ if (av.isHiddenRepSequence(seq))
{
endEditing();
return;
}
- sg = (SequenceGroup) av.hiddenRepSequences.get(seq);
+ sg = av.getRepresentedSequences(seq);
}
fixedLeft = sg.getStartRes();
}
}
- if (av.hasHiddenColumns)
+ if (av.hasHiddenColumns())
{
fixedColumns = true;
int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres);
if (groupEditing)
{
- Vector vseqs = sg.getSequences(av.hiddenRepSequences);
+ Vector vseqs = sg.getSequences(av.getHiddenRepSequences());
int g, groupSize = vseqs.size();
SequenceI[] groupSeqs = new SequenceI[groupSize];
for (g = 0; g < groupSeqs.length; g++)
// If the user has selected the whole sequence, and is dragging to
// the right, we can still extend the alignment and selectionGroup
if (sg.getStartRes() == 0 && sg.getEndRes() == fixedRight
- && sg.getEndRes() == av.alignment.getWidth() - 1)
+ && sg.getEndRes() == av.getAlignment().getWidth() - 1)
{
- sg.setEndRes(av.alignment.getWidth() + startres - lastres);
+ sg.setEndRes(av.getAlignment().getWidth() + startres - lastres);
fixedRight = sg.getEndRes();
}
if (!blank)
{
- if (sg.getSize() == av.alignment.getHeight())
+ if (sg.getSize() == av.getAlignment().getHeight())
{
- if ((av.hasHiddenColumns && startres < av.getColumnSelection()
+ if ((av.hasHiddenColumns() && startres < av.getColumnSelection()
.getHiddenBoundaryRight(startres)))
{
endEditing();
return;
}
- int alWidth = av.alignment.getWidth();
- if (av.hasHiddenRows)
+ int alWidth = av.getAlignment().getWidth();
+ if (av.hasHiddenRows())
{
- int hwidth = av.alignment.getHiddenSequences().getWidth();
+ int hwidth = av.getAlignment().getHiddenSequences().getWidth();
if (hwidth > alWidth)
{
alWidth = hwidth;
else
{
editCommand.appendEdit(EditCommand.INSERT_GAP, groupSeqs,
- startres, startres - lastres, av.alignment, true);
+ startres, startres - lastres, av.getAlignment(), true);
}
}
else
else
{
editCommand.appendEdit(EditCommand.DELETE_GAP, groupSeqs,
- startres, lastres - startres, av.alignment, true);
+ startres, lastres - startres, av.getAlignment(), true);
}
}
else
{
editCommand.appendEdit(EditCommand.INSERT_GAP, new SequenceI[]
- { seq }, lastres, startres - lastres, av.alignment, true);
+ { seq }, lastres, startres - lastres, av.getAlignment(), true);
}
}
else
if (max > 0)
{
editCommand.appendEdit(EditCommand.DELETE_GAP, new SequenceI[]
- { seq }, startres, max, av.alignment, true);
+ { seq }, startres, max, av.getAlignment(), true);
}
}
}else{//insertGap==false AND editSeq==TRUE;
else
{
editCommand.appendEdit(EditCommand.INSERT_NUC, new SequenceI[]
- { seq }, lastres, startres - lastres, av.alignment, true);
+ { seq }, lastres, startres - lastres, av.getAlignment(), true);
}
}
}
}
editCommand.appendEdit(EditCommand.DELETE_GAP, seq, blankColumn, 1,
- av.alignment, true);
+ av.getAlignment(), true);
- editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.alignment,
+ editCommand.appendEdit(EditCommand.INSERT_GAP, seq, j, 1, av.getAlignment(),
true);
}
void deleteChar(int j, SequenceI[] seq, int fixedColumn)
{
- editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.alignment,
+ editCommand.appendEdit(EditCommand.DELETE_GAP, seq, j, 1, av.getAlignment(),
true);
editCommand.appendEdit(EditCommand.INSERT_GAP, seq, fixedColumn, 1,
- av.alignment, true);
+ av.getAlignment(), true);
}
/**
public void mouseClicked(MouseEvent evt)
{
SequenceGroup sg = null;
- SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
+ SequenceI sequence = av.getAlignment().getSequenceAt(findSeq(evt));
if (evt.getClickCount() > 1)
{
sg = av.getSelectionGroup();
startWrapBlock = wrappedBlock;
- if (av.wrapAlignment && seq > av.alignment.getHeight())
+ if (av.wrapAlignment && seq > av.getAlignment().getHeight())
{
JOptionPane.showInternalMessageDialog(Desktop.desktop,
"Cannot edit annotations in wrapped view.",
if (stretchGroup == null)
{
- stretchGroup = av.alignment.findGroup(sequence);
+ stretchGroup = av.getAlignment().findGroup(sequence);
if ((stretchGroup != null) && (res > stretchGroup.getStartRes())
&& (res < stretchGroup.getEndRes()))
{
stretchGroup = null;
- SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence);
+ SequenceGroup[] allGroups = av.getAlignment().findAllGroups(sequence);
if (allGroups != null)
{
if (stretchGroup.cs instanceof ClustalxColourScheme)
{
((ClustalxColourScheme) stretchGroup.cs).resetClustalX(
- stretchGroup.getSequences(av.hiddenRepSequences),
+ stretchGroup.getSequences(av.getHiddenRepSequences()),
stretchGroup.getWidth());
}
return;
}
- if (res >= av.alignment.getWidth())
+ if (res >= av.getAlignment().getWidth())
{
- res = av.alignment.getWidth() - 1;
+ res = av.getAlignment().getWidth() - 1;
}
if (stretchGroup.getEndRes() == res)
dragDirection = -1;
}
- while ((y != oldSeq) && (oldSeq > -1) && (y < av.alignment.getHeight()))
+ while ((y != oldSeq) && (oldSeq > -1) && (y < av.getAlignment().getHeight()))
{
// This routine ensures we don't skip any sequences, as the
// selection is quite slow.
}
if (mouseDragging && (evt.getY() >= getHeight())
- && (av.alignment.getHeight() > av.getEndSeq()))
+ && (av.getAlignment().getHeight() > av.getEndSeq()))
{
running = ap.scrollUp(false);
}
SequenceGroup sgroup = null;
if (seqsel != null && seqsel.getSize()>0)
{
- if (av.alignment == null)
+ if (av.getAlignment() == null)
{
jalview.bin.Cache.log.warn("alignviewport av SeqSetId="
+ av.getSequenceSetId() + " ViewId=" + av.getViewId()
+ " 's alignment is NULL! returning immediatly.");
return;
}
- sgroup = seqsel.intersect(av.alignment,
- (av.hasHiddenRows) ? av.hiddenRepSequences : null);
+ sgroup = seqsel.intersect(av.getAlignment(),
+ (av.hasHiddenRows()) ? av.getHiddenRepSequences() : null);
if ((sgroup == null || sgroup.getSize() == 0)
|| (colsel == null || colsel.size() == 0))
{
// so import the new colsel.
if (colsel == null || colsel.size() == 0)
{
- if (av.colSel != null)
+ if (av.getColumnSelection() != null)
{
- av.colSel.clear();
+ av.getColumnSelection().clear();
repaint=true;
}
}
else
{
// TODO: shift colSel according to the intersecting sequences
- if (av.colSel == null)
+ if (av.getColumnSelection() == null)
{
- av.colSel = new ColumnSelection(colsel);
+ av.setColumnSelection(new ColumnSelection(colsel));
}
else
{
- av.colSel.setElementsFrom(colsel);
+ av.getColumnSelection().setElementsFrom(colsel);
}
}
av.isColSelChanged(true);
repaint = true;
}
- if (copycolsel && av.hasHiddenColumns
- && (av.colSel == null || av.colSel.getHiddenColumns() == null))
+ if (copycolsel && av.hasHiddenColumns()
+ && (av.getColumnSelection() == null || av.getColumnSelection().getHiddenColumns() == null))
{
System.err.println("Bad things");
}
{
for (int i = 0; i < al.getHeight(); i++)
{
- alignFrame.viewport.alignment.addSequence(al.getSequenceAt(i)); // this
+ alignFrame.viewport.getAlignment().addSequence(al.getSequenceAt(i)); // this
// also
// creates
// dataset
// sequence
// entries
}
- alignFrame.viewport.setEndSeq(alignFrame.viewport.alignment
+ alignFrame.viewport.setEndSeq(alignFrame.viewport.getAlignment()
.getHeight());
- alignFrame.viewport.alignment.getWidth();
+ alignFrame.viewport.getAlignment().getWidth();
alignFrame.viewport.firePropertyChange("alignment", null,
alignFrame.viewport.getAlignment().getSequences());
}
public Color getResidueBoxColour(SequenceI seq, int i)
{
- allGroups = av.alignment.findAllGroups(seq);
+ allGroups = av.getAlignment().findAllGroups(seq);
if (inCurrentSequenceGroup(i))
{
}
else if (av.getShowBoxes())
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
return resBoxColour;
}
else if (av.getShowBoxes())
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
}
if (currentSequenceGroup.getShowNonconserved()) // todo optimize
{
// todo - use sequence group consensus
- s = getDisplayChar(av.consensus, i, s, '.');
+ s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
}
if (av.getColourText())
{
getboxColour = true;
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
if (av.getShowBoxes())
{
{
if (!getboxColour)
{
- getBoxColour(av.globalColourScheme, seq, i);
+ getBoxColour(av.getGlobalColourScheme(), seq, i);
}
if (resBoxColour.getRed() + resBoxColour.getBlue()
graphics.setColor(av.textColour2);
}
}
- if (av.showUnconserved)
+ if (av.getShowUnconserved())
{
- s = getDisplayChar(av.consensus, i, s, '.');
+ s = getDisplayChar(av.getAlignmentConsensusAnnotation(), i, s, '.');
}
conservationSlider.setTitle("Conservation Colour Increment (" + source
+ ")");
- if (ap.av.alignment.getGroups() != null)
+ if (ap.av.getAlignment().getGroups() != null)
{
sp.setAllGroupsCheckEnabled(true);
}
PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")");
- if (ap.av.alignment.getGroups() != null)
+ if (ap.av.getAlignment().getGroups() != null)
{
pid.setAllGroupsCheckEnabled(true);
}
if (allGroupsCheck.isSelected())
{
- allGroups = ap.av.alignment.getGroups();
+ allGroups = ap.av.getAlignment().getGroups();
groupIndex = allGroups.size() - 1;
}
else
void setGroupTextColour()
{
- if (ap.av.alignment.getGroups() == null)
+ if (ap.av.getAlignment().getGroups() == null)
{
return;
}
- Vector groups = ap.av.alignment.getGroups();
+ Vector groups = ap.av.getAlignment().getGroups();
for (int i = 0; i < groups.size(); i++)
{
aps[a].av.setSelectionGroup(selected);
}
- selected.setEndRes(aps[a].av.alignment.getWidth() - 1);
+ selected.setEndRes(aps[a].av.getAlignment().getWidth() - 1);
selected.addOrRemove(sequence, true);
}
}
for (int a = 0; a < aps.length; a++)
{
aps[a].av.setSelectionGroup(null);
- aps[a].av.alignment.deleteAllGroups();
+ aps[a].av.getAlignment().deleteAllGroups();
aps[a].av.sequenceColours = null;
}
colourGroups();
}
else
{
- cs = ColourSchemeProperty.getColour(sequences, av.alignment
+ cs = ColourSchemeProperty.getColour(sequences, av.getAlignment()
.getWidth(), ColourSchemeProperty.getColourName(av
.getGlobalColourScheme()));
}
}
SequenceGroup sg = new SequenceGroup(sequences, null, cs, true, true,
- false, 0, av.alignment.getWidth() - 1);
+ false, 0, av.getAlignment().getWidth() - 1);
sg.setName("JTreeGroup:" + sg.hashCode());
sg.setIdColour(col);
sg.cs.setConservation(c);
}
- aps[a].av.alignment.addGroup(sg);
+ aps[a].av.getAlignment().addGroup(sg);
}
}
// notify the panel to redo any group specific stuff.
{
if (odata == null)
{
- tree = new NJTree(av.alignment.getSequencesArray(), newtree);
+ tree = new NJTree(av.getAlignment().getSequencesArray(), newtree);
}
else
{
- tree = new NJTree(av.alignment.getSequencesArray(), odata,
+ tree = new NJTree(av.getAlignment().getSequencesArray(), odata,
newtree);
}
if (!tree.hasOriginalSequenceData())
if (av.getSelectionGroup() == null)
{
start = 0;
- end = av.alignment.getWidth();
- seqs = av.alignment.getSequencesArray();
+ end = av.getAlignment().getWidth();
+ seqs = av.getAlignment().getSequencesArray();
}
else
{
start = av.getSelectionGroup().getStartRes();
end = av.getSelectionGroup().getEndRes() + 1;
- seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
+ seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
AlignmentSorter.sortByTree(av.getAlignment(), tree);
CommandI undo;
undo=new OrderCommand("Tree Sort", oldOrder,
- av.alignment);
+ av.getAlignment());
ap.paintAlignment(true);
return undo;
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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
+ * 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.viewmodel;
+
+import jalview.analysis.Conservation;
+import jalview.api.AlignCalcManagerI;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.ClustalxColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ResidueProperties;
+import jalview.workers.AlignCalcManager;
+import jalview.workers.ConsensusThread;
+import jalview.workers.ConservationThread;
+import jalview.workers.StrucConsensusThread;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * base class holding visualization and analysis attributes and common logic for an active alignment view displayed in the GUI
+ * @author jimp
+ *
+ */
+public abstract class AlignmentViewport implements AlignViewportI
+{
+ /**
+ * alignment displayed in the viewport. Please use get/setter
+ */
+ protected AlignmentI alignment;
+
+ protected String sequenceSetID;
+
+ private Hashtable hiddenRepSequences;
+
+ protected ColumnSelection colSel = new ColumnSelection();
+
+
+ public boolean autoCalculateConsensus = true;
+
+ protected boolean autoCalculateStrucConsensus = true;
+
+ protected boolean ignoreGapsInConsensusCalculation = false;
+
+
+ protected ColourSchemeI globalColourScheme = null;
+
+
+ public void setGlobalColourScheme(ColourSchemeI cs)
+ {
+ globalColourScheme = cs;
+ }
+
+ public ColourSchemeI getGlobalColourScheme()
+ {
+ return globalColourScheme;
+ }
+
+
+ protected AlignmentAnnotation consensus;
+
+ protected AlignmentAnnotation strucConsensus;
+
+ protected AlignmentAnnotation conservation;
+
+ protected AlignmentAnnotation quality;
+
+ protected AlignmentAnnotation[] groupConsensus;
+
+ protected AlignmentAnnotation[] groupConservation;
+
+ /**
+ * results of alignment consensus analysis for visible portion of view
+ */
+ protected Hashtable[] hconsensus=null;
+
+ /**
+ * results of secondary structure base pair consensus for visible portion of view
+ */
+ protected Hashtable[] hStrucConsensus=null;
+
+ /**
+ * percentage gaps allowed in a column before all amino acid properties should be considered unconserved
+ */
+ int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
+
+
+ public int getConsPercGaps()
+ {
+ return ConsPercGaps;
+ }
+ @Override
+ public void setSequenceConsensusHash(Hashtable[] hconsensus)
+ {
+ this.hconsensus=hconsensus;
+
+ }
+
+ @Override
+ public Hashtable[] getSequenceConsensusHash()
+ {
+ return hconsensus;
+ }
+
+ @Override
+ public Hashtable[] getRnaStructureConsensusHash()
+ {
+ return hStrucConsensus;
+ }
+ @Override
+ public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
+ {
+ this.hStrucConsensus=hStrucConsensus;
+
+ }
+ @Override
+ public AlignmentAnnotation getAlignmentQualityAnnot()
+ {
+ return quality;
+ }
+
+ @Override
+ public AlignmentAnnotation getAlignmentConservationAnnotation()
+ {
+ return conservation;
+ }
+ @Override
+ public AlignmentAnnotation getAlignmentConsensusAnnotation()
+ {
+ return consensus;
+ }
+ @Override
+ public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
+ {
+ return strucConsensus;
+ }
+
+ protected AlignCalcManagerI calculator=new AlignCalcManager();
+
+ jalview.workers.ConsensusThread consensusThread;
+
+ StrucConsensusThread strucConsensusThread;
+
+
+ private ConservationThread conservationThread;
+
+ /**
+ * trigger update of conservation annotation
+ */
+ public void updateConservation(final AlignmentViewPanel ap)
+ {
+ // see note in mantis : issue number 8585
+ if (alignment.isNucleotide() || conservation == null
+ || !autoCalculateConsensus)
+ {
+ return;
+ }
+
+ calculator.startWorker(conservationThread=new jalview.workers.ConservationThread(this, ap));
+ }
+
+ /**
+ * trigger update of consensus annotation
+ */
+ public void updateConsensus(final AlignmentViewPanel ap)
+ {
+ // see note in mantis : issue number 8585
+ if (consensus == null || !autoCalculateConsensus)
+ {
+ return;
+ }
+ calculator.startWorker(consensusThread = new ConsensusThread(this, ap));
+ }
+
+ // --------START Structure Conservation
+ public void updateStrucConsensus(final AlignmentViewPanel ap)
+ {
+ // see note in mantis : issue number 8585
+ if (strucConsensus == null || !autoCalculateStrucConsensus)
+ {
+ return;
+ }
+ calculator.startWorker(strucConsensusThread = new StrucConsensusThread(this,ap));
+ }
+
+ public boolean isCalcInProgress()
+ {
+ // TODO generalise to iterate over all calculators associated with av
+ return calculator.isWorking();
+ }
+
+ public boolean isCalculationInProgress(
+ AlignmentAnnotation alignmentAnnotation)
+ {
+ if (!alignmentAnnotation.autoCalculated)
+ return false;
+ if ((calculator.isWorking(consensusThread) && consensus==alignmentAnnotation)
+ || (calculator.isWorking(conservationThread) && (conservation==alignmentAnnotation || quality==alignmentAnnotation))
+ || (calculator.isWorking(strucConsensusThread) && strucConsensus==alignmentAnnotation)
+ )
+ {
+ return true;
+ }
+ return false;
+ }
+ @Override
+ public boolean isClosed()
+ {
+ // TODO: check that this isClosed is only true after panel is closed, not before it is fully constructed.
+ return alignment==null;
+ }
+
+ @Override
+ public AlignCalcManagerI getCalcManager()
+ {
+ return calculator;
+ }
+
+ /**
+ * should conservation rows be shown for groups
+ */
+ protected boolean showGroupConservation = false;
+
+ /**
+ * should consensus rows be shown for groups
+ */
+ protected boolean showGroupConsensus = false;
+
+ /**
+ * should consensus profile be rendered by default
+ */
+ protected boolean showSequenceLogo = false;
+ /**
+ * should consensus profile be rendered normalised to row height
+ */
+ protected boolean normaliseSequenceLogo = false;
+ /**
+ * should consensus histograms be rendered by default
+ */
+ protected boolean showConsensusHistogram = true;
+
+ /**
+ * @return the showConsensusProfile
+ */
+ public boolean isShowSequenceLogo()
+ {
+ return showSequenceLogo;
+ }
+
+ /**
+ * @param showSequenceLogo
+ * the new value
+ */
+ public void setShowSequenceLogo(boolean showSequenceLogo)
+ {
+ if (showSequenceLogo != this.showSequenceLogo)
+ {
+ // TODO: decouple settings setting from calculation when refactoring
+ // annotation update method from alignframe to viewport
+ this.showSequenceLogo = showSequenceLogo;
+ if (consensusThread != null)
+ {
+ consensusThread.updateAnnotation();
+ }
+ if (strucConsensusThread != null)
+ {
+ strucConsensusThread.updateAnnotation();
+ }
+ }
+ this.showSequenceLogo = showSequenceLogo;
+ }
+
+ /**
+ * @param showConsensusHistogram
+ * the showConsensusHistogram to set
+ */
+ public void setShowConsensusHistogram(boolean showConsensusHistogram)
+ {
+ this.showConsensusHistogram = showConsensusHistogram;
+ }
+
+ /**
+ * @return the showGroupConservation
+ */
+ public boolean isShowGroupConservation()
+ {
+ return showGroupConservation;
+ }
+
+ /**
+ * @param showGroupConservation
+ * the showGroupConservation to set
+ */
+ public void setShowGroupConservation(boolean showGroupConservation)
+ {
+ this.showGroupConservation = showGroupConservation;
+ }
+
+ /**
+ * @return the showGroupConsensus
+ */
+ public boolean isShowGroupConsensus()
+ {
+ return showGroupConsensus;
+ }
+
+ /**
+ * @param showGroupConsensus
+ * the showGroupConsensus to set
+ */
+ public void setShowGroupConsensus(boolean showGroupConsensus)
+ {
+ this.showGroupConsensus = showGroupConsensus;
+ }
+
+ /**
+ *
+ * @return flag to indicate if the consensus histogram should be rendered by
+ * default
+ */
+ public boolean isShowConsensusHistogram()
+ {
+ return this.showConsensusHistogram;
+ }
+
+ /**
+ * show non-conserved residues only
+ */
+ protected boolean showUnconserved = false;
+
+
+ /**
+ * when set, updateAlignment will always ensure sequences are of equal length
+ */
+ private boolean padGaps = false;
+
+ /**
+ * when set, alignment should be reordered according to a newly opened tree
+ */
+ public boolean sortByTree = false;
+
+ public boolean getShowUnconserved()
+ {
+ return showUnconserved;
+ }
+
+ public void setShowUnconserved(boolean showunconserved)
+ {
+ showUnconserved = showunconserved;
+ }
+
+ /**
+ * @param showNonconserved
+ * the showUnconserved to set
+ */
+ public void setShowunconserved(boolean displayNonconserved)
+ {
+ this.showUnconserved = displayNonconserved;
+ }
+
+ /**
+ *
+ *
+ * @return null or the currently selected sequence region
+ */
+ public SequenceGroup getSelectionGroup()
+ {
+ return selectionGroup;
+ }
+
+ /**
+ * Set the selection group for this window.
+ *
+ * @param sg
+ * - group holding references to sequences in this alignment view
+ *
+ */
+ public void setSelectionGroup(SequenceGroup sg)
+ {
+ selectionGroup = sg;
+ }
+
+ public void setHiddenColumns(ColumnSelection colsel)
+ {
+ this.colSel = colsel;
+ if (colSel.getHiddenColumns() != null)
+ {
+ hasHiddenColumns = true;
+ }
+ }
+
+ public ColumnSelection getColumnSelection()
+ {
+ return colSel;
+ }
+ public void setColumnSelection(ColumnSelection colSel)
+ {
+ this.colSel=colSel;
+ }
+ public Hashtable getHiddenRepSequences()
+ {
+ return hiddenRepSequences;
+ }
+ public void setHiddenRepSequences(Hashtable hiddenRepSequences)
+ {
+ this.hiddenRepSequences = hiddenRepSequences;
+ }
+ protected boolean hasHiddenColumns = false;
+
+ public void updateHiddenColumns()
+ {
+ hasHiddenColumns = colSel.getHiddenColumns() != null;
+ }
+
+ protected boolean hasHiddenRows = false;
+
+ public boolean hasHiddenRows() {
+ return hasHiddenRows;
+ }
+
+ protected SequenceGroup selectionGroup;
+
+ public void setSequenceSetId(String newid)
+ {
+ if (sequenceSetID!=null)
+ {
+ System.err.println("Warning - overwriting a sequenceSetId for a viewport!");
+ }
+ sequenceSetID=new String(newid);
+ }
+ public String getSequenceSetId()
+ {
+ if (sequenceSetID == null)
+ {
+ sequenceSetID = alignment.hashCode() + "";
+ }
+
+ return sequenceSetID;
+ }
+ /**
+ * unique viewId for synchronizing state (e.g. with stored Jalview Project)
+ *
+ */
+ protected String viewId = null;
+
+ public String getViewId()
+ {
+ if (viewId == null)
+ {
+ viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
+ }
+ return viewId;
+ }
+ public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
+ {
+ ignoreGapsInConsensusCalculation = b;
+ if (ap!=null) {updateConsensus(ap);
+ if (globalColourScheme != null)
+ {
+ globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
+ ignoreGapsInConsensusCalculation);
+ }}
+
+ }
+ private long sgrouphash = -1, colselhash = -1;
+
+ /**
+ * checks current SelectionGroup against record of last hash value, and
+ * updates record.
+ *
+ * @param b
+ * update the record of last hash value
+ *
+ * @return true if SelectionGroup changed since last call (when b is true)
+ */
+ public boolean isSelectionGroupChanged(boolean b)
+ {
+ int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
+ : selectionGroup.hashCode();
+ if (hc != -1 && hc != sgrouphash)
+ {
+ if (b)
+ {
+ sgrouphash = hc;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * checks current colsel against record of last hash value, and optionally
+ * updates record.
+ *
+ * @param b
+ * update the record of last hash value
+ * @return true if colsel changed since last call (when b is true)
+ */
+ public boolean isColSelChanged(boolean b)
+ {
+ int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
+ .hashCode();
+ if (hc != -1 && hc != colselhash)
+ {
+ if (b)
+ {
+ colselhash = hc;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean getIgnoreGapsConsensus()
+ {
+ return ignoreGapsInConsensusCalculation;
+ }
+
+ /// property change stuff
+
+ // JBPNote Prolly only need this in the applet version.
+ private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
+ this);
+
+
+ /**
+ * Property change listener for changes in alignment
+ *
+ * @param listener
+ * DOCUMENT ME!
+ */
+ public void addPropertyChangeListener(
+ java.beans.PropertyChangeListener listener)
+ {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param listener
+ * DOCUMENT ME!
+ */
+ public void removePropertyChangeListener(
+ java.beans.PropertyChangeListener listener)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Property change listener for changes in alignment
+ *
+ * @param prop
+ * DOCUMENT ME!
+ * @param oldvalue
+ * DOCUMENT ME!
+ * @param newvalue
+ * DOCUMENT ME!
+ */
+ public void firePropertyChange(String prop, Object oldvalue,
+ Object newvalue)
+ {
+ changeSupport.firePropertyChange(prop, oldvalue, newvalue);
+ }
+
+ // common hide/show column stuff
+
+
+ public void hideSelectedColumns()
+ {
+ if (colSel.size() < 1)
+ {
+ return;
+ }
+
+ colSel.hideSelectedColumns();
+ setSelectionGroup(null);
+
+ hasHiddenColumns = true;
+ }
+
+ public void hideColumns(int start, int end)
+ {
+ if (start == end)
+ {
+ colSel.hideColumns(start);
+ }
+ else
+ {
+ colSel.hideColumns(start, end);
+ }
+
+ hasHiddenColumns = true;
+ }
+
+ public void showColumn(int col)
+ {
+ colSel.revealHiddenColumns(col);
+ if (colSel.getHiddenColumns() == null)
+ {
+ hasHiddenColumns = false;
+ }
+ }
+
+ public void showAllHiddenColumns()
+ {
+ colSel.revealAllHiddenColumns();
+ hasHiddenColumns = false;
+ }
+
+
+ // common hide/show seq stuff
+ public void showAllHiddenSeqs()
+ {
+ if (alignment.getHiddenSequences().getSize() > 0)
+ {
+ if (selectionGroup == null)
+ {
+ selectionGroup = new SequenceGroup();
+ selectionGroup.setEndRes(alignment.getWidth() - 1);
+ }
+ Vector tmp = alignment.getHiddenSequences().showAll(
+ hiddenRepSequences);
+ for (int t = 0; t < tmp.size(); t++)
+ {
+ selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
+ }
+
+ hasHiddenRows = false;
+ hiddenRepSequences = null;
+
+ firePropertyChange("alignment", null, alignment.getSequences());
+ // used to set hasHiddenRows/hiddenRepSequences here, after the property changed event
+ sendSelection();
+ }
+ }
+
+ public void showSequence(int index)
+ {
+ Vector tmp = alignment.getHiddenSequences().showSequence(index,
+ hiddenRepSequences);
+ if (tmp.size() > 0)
+ {
+ if (selectionGroup == null)
+ {
+ selectionGroup = new SequenceGroup();
+ selectionGroup.setEndRes(alignment.getWidth() - 1);
+ }
+
+ for (int t = 0; t < tmp.size(); t++)
+ {
+ selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
+ }
+ // JBPNote: refactor: only update flag if we modified visiblity (used to do this regardless)
+ if (alignment.getHiddenSequences().getSize() < 1)
+ {
+ hasHiddenRows = false;
+ }
+ firePropertyChange("alignment", null, alignment.getSequences());
+ sendSelection();
+ }
+ }
+
+
+
+ public void hideAllSelectedSeqs()
+ {
+ if (selectionGroup == null || selectionGroup.getSize() < 1)
+ {
+ return;
+ }
+
+ SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
+
+ hideSequence(seqs);
+
+ setSelectionGroup(null);
+ }
+
+
+ public void hideSequence(SequenceI[] seq)
+ {
+ if (seq != null)
+ {
+ for (int i = 0; i < seq.length; i++)
+ {
+ alignment.getHiddenSequences().hideSequence(seq[i]);
+ }
+ hasHiddenRows = true;
+ firePropertyChange("alignment", null, alignment.getSequences());
+ }
+ }
+
+ public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
+ {
+ int sSize = sg.getSize();
+ if (sSize < 2)
+ {
+ return;
+ }
+
+ if (hiddenRepSequences == null)
+ {
+ hiddenRepSequences = new Hashtable();
+ }
+
+ hiddenRepSequences.put(repSequence, sg);
+
+ // Hide all sequences except the repSequence
+ SequenceI[] seqs = new SequenceI[sSize - 1];
+ int index = 0;
+ for (int i = 0; i < sSize; i++)
+ {
+ if (sg.getSequenceAt(i) != repSequence)
+ {
+ if (index == sSize - 1)
+ {
+ return;
+ }
+
+ seqs[index++] = sg.getSequenceAt(i);
+ }
+ }
+ sg.setSeqrep(repSequence); // note: not done in 2.7applet
+ sg.setHidereps(true); // note: not done in 2.7applet
+ hideSequence(seqs);
+
+ }
+
+ public boolean isHiddenRepSequence(SequenceI seq)
+ {
+ return hiddenRepSequences != null
+ && hiddenRepSequences.containsKey(seq);
+ }
+ public SequenceGroup getRepresentedSequences(SequenceI seq)
+ {
+ return (SequenceGroup) (hiddenRepSequences == null ? null : hiddenRepSequences.get(seq));
+ }
+
+ public int adjustForHiddenSeqs(int alignmentIndex)
+ {
+ return alignment.getHiddenSequences().adjustForHiddenSeqs(
+ alignmentIndex);
+ }
+
+ // Selection manipulation
+ /**
+ * broadcast selection to any interested parties
+ */
+ public abstract void sendSelection();
+
+
+ public void invertColumnSelection()
+ {
+ colSel.invertColumnSelection(0, alignment.getWidth());
+ }
+
+
+ /**
+ * This method returns an array of new SequenceI objects derived from the
+ * whole alignment or just the current selection with start and end points
+ * adjusted
+ *
+ * @note if you need references to the actual SequenceI objects in the
+ * alignment or currently selected then use getSequenceSelection()
+ * @return selection as new sequenceI objects
+ */
+ public SequenceI[] getSelectionAsNewSequence()
+ {
+ SequenceI[] sequences;
+ // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom - this was the only caller in the applet for this method
+ // JBPNote: in applet, this method returned references to the alignment sequences, and it did not honour the presence/absence of annotation attached to the alignment (probably!)
+ if (selectionGroup == null)
+ {
+ sequences = alignment.getSequencesArray();
+ AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
+ for (int i = 0; i < sequences.length; i++)
+ {
+ sequences[i] = new Sequence(sequences[i], annots); // construct new
+ // sequence with
+ // subset of visible
+ // annotation
+ }
+ }
+ else
+ {
+ sequences = selectionGroup.getSelectionAsNewSequences(alignment);
+ }
+
+ return sequences;
+ }
+
+
+ /**
+ * get the currently selected sequence objects or all the sequences in the
+ * alignment.
+ *
+ * @return array of references to sequence objects
+ */
+ public SequenceI[] getSequenceSelection()
+ {
+ SequenceI[] sequences = null;
+ if (selectionGroup != null)
+ {
+ sequences = selectionGroup.getSequencesInOrder(alignment);
+ }
+ if (sequences == null)
+ {
+ sequences = alignment.getSequencesArray();
+ }
+ return sequences;
+ }
+
+
+ /**
+ * This method returns the visible alignment as text, as seen on the GUI, ie
+ * if columns are hidden they will not be returned in the result. Use this for
+ * calculating trees, PCA, redundancy etc on views which contain hidden
+ * columns.
+ *
+ * @return String[]
+ */
+ public jalview.datamodel.CigarArray getViewAsCigars(
+ boolean selectedRegionOnly)
+ {
+ return new jalview.datamodel.CigarArray(alignment,
+ (hasHiddenColumns ? colSel : null),
+ (selectedRegionOnly ? selectionGroup : null));
+ }
+
+ /**
+ * return a compact representation of the current alignment selection to pass
+ * to an analysis function
+ *
+ * @param selectedOnly
+ * boolean true to just return the selected view
+ * @return AlignmentView
+ */
+ public jalview.datamodel.AlignmentView getAlignmentView(
+ boolean selectedOnly)
+ {
+ return getAlignmentView(selectedOnly, false);
+ }
+
+ /**
+ * return a compact representation of the current alignment selection to pass
+ * to an analysis function
+ *
+ * @param selectedOnly
+ * boolean true to just return the selected view
+ * @param markGroups
+ * boolean true to annotate the alignment view with groups on the
+ * alignment (and intersecting with selected region if selectedOnly
+ * is true)
+ * @return AlignmentView
+ */
+ public jalview.datamodel.AlignmentView getAlignmentView(
+ boolean selectedOnly, boolean markGroups)
+ {
+ return new AlignmentView(alignment, colSel, selectionGroup,
+ hasHiddenColumns, selectedOnly, markGroups);
+ }
+
+
+ /**
+ * This method returns the visible alignment as text, as seen on the GUI, ie
+ * if columns are hidden they will not be returned in the result. Use this for
+ * calculating trees, PCA, redundancy etc on views which contain hidden
+ * columns.
+ *
+ * @return String[]
+ */
+ public String[] getViewAsString(boolean selectedRegionOnly)
+ {
+ String[] selection = null;
+ SequenceI[] seqs = null;
+ int i, iSize;
+ int start = 0, end = 0;
+ if (selectedRegionOnly && selectionGroup != null)
+ {
+ iSize = selectionGroup.getSize();
+ seqs = selectionGroup.getSequencesInOrder(alignment);
+ start = selectionGroup.getStartRes();
+ end = selectionGroup.getEndRes() + 1;
+ }
+ else
+ {
+ iSize = alignment.getHeight();
+ seqs = alignment.getSequencesArray();
+ end = alignment.getWidth();
+ }
+
+ selection = new String[iSize];
+ if (hasHiddenColumns)
+ {
+ selection = colSel.getVisibleSequenceStrings(start, end, seqs);
+ }
+ else
+ {
+ for (i = 0; i < iSize; i++)
+ {
+ selection[i] = seqs[i].getSequenceAsString(start, end);
+ }
+
+ }
+ return selection;
+ }
+
+
+ /**
+ * return visible region boundaries within given column range
+ * @param min first column (inclusive, from 0)
+ * @param max last column (exclusive)
+ * @return int[][] range of {start,end} visible positions
+ */
+ public int[][] getVisibleRegionBoundaries(int min, int max)
+ {
+ Vector regions = new Vector();
+ int start = min;
+ int end = max;
+
+ do
+ {
+ if (hasHiddenColumns)
+ {
+ if (start == 0)
+ {
+ start = colSel.adjustForHiddenColumns(start);
+ }
+
+ end = colSel.getHiddenBoundaryRight(start);
+ if (start == end)
+ {
+ end = max;
+ }
+ if (end > max)
+ {
+ end = max;
+ }
+ }
+
+ regions.addElement(new int[]
+ { start, end });
+
+ if (hasHiddenColumns)
+ {
+ start = colSel.adjustForHiddenColumns(end);
+ start = colSel.getHiddenBoundaryLeft(start) + 1;
+ }
+ } while (end < max);
+
+ int[][] startEnd = new int[regions.size()][2];
+
+ regions.copyInto(startEnd);
+
+ return startEnd;
+
+ }
+ /**
+ * @return the padGaps
+ */
+ public boolean isPadGaps()
+ {
+ return padGaps;
+ }
+ /**
+ * @param padGaps the padGaps to set
+ */
+ public void setPadGaps(boolean padGaps)
+ {
+ this.padGaps = padGaps;
+ }
+ /**
+ * apply any post-edit constraints and trigger any calculations needed after an edit has been performed on the alignment
+ * @param ap
+ */
+ public void alignmentChanged(AlignmentViewPanel ap)
+ {
+ // TODO: test jvLite always pads, and that JVD has configurable padding.
+ if (isPadGaps())
+ {
+ alignment.padGaps();
+ }
+ if (autoCalculateConsensus)
+ {
+ updateConsensus(ap);
+ }
+ if (hconsensus != null && autoCalculateConsensus)
+ {
+ updateConservation(ap);
+ }
+ if (autoCalculateStrucConsensus)
+ {
+ updateStrucConsensus(ap);
+ }
+
+ // Reset endRes of groups if beyond alignment width
+ int alWidth = alignment.getWidth();
+ Vector groups = alignment.getGroups();
+ if (groups != null)
+ {
+ for (int i = 0; i < groups.size(); i++)
+ {
+ SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
+ if (sg.getEndRes() > alWidth)
+ {
+ sg.setEndRes(alWidth - 1);
+ }
+ }
+ }
+
+ if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
+ {
+ selectionGroup.setEndRes(alWidth - 1);
+ }
+
+ resetAllColourSchemes();
+
+ // alignment.adjustSequenceAnnotations();
+ }
+
+
+ /**
+ * reset scope and do calculations for all applied colourschemes on alignment
+ */
+ void resetAllColourSchemes()
+ {
+ ColourSchemeI cs = globalColourScheme;
+ if (cs != null)
+ {
+ if (cs instanceof ClustalxColourScheme)
+ {
+ ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
+ alignment.getWidth());
+ }
+
+ cs.setConsensus(hconsensus);
+ if (cs.conservationApplied())
+ {
+ cs.setConservation(Conservation.calculateConservation("All",
+ ResidueProperties.propHash, 3, alignment.getSequences(), 0,
+ alignment.getWidth(), false, getConsPercGaps(), false));
+ }
+ }
+
+ int s, sSize = alignment.getGroups().size();
+ for (s = 0; s < sSize; s++)
+ {
+ SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
+ if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
+ {
+ ((ClustalxColourScheme) sg.cs).resetClustalX(sg
+ .getSequences(hiddenRepSequences), sg.getWidth());
+ }
+ sg.recalcConservation();
+ }
+ }
+
+}