*/
package jalview.api;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
/**
*
* @return
*/
- public ColumnSelection getColumnSelection();
+ public HiddenColumns getHiddenColumns();
/**
* Retrieves hidden sequences from a complex file parser
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
}
public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
- ColumnSelection columnSelection, JalviewLite applet,
+ HiddenColumns hidden, JalviewLite applet,
String title, boolean embedded)
{
- this(al, hiddenSeqs, columnSelection, applet, title, embedded, true);
+ this(al, hiddenSeqs, hidden, applet, title, embedded, true);
}
public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
- ColumnSelection columnSelection, JalviewLite applet,
+ HiddenColumns hidden, JalviewLite applet,
String title, boolean embedded, boolean addToDisplay)
{
if (applet != null)
{
viewport.hideSequence(hiddenSeqs);
}
- if (columnSelection != null)
+ if (hidden != null)
{
- viewport.setColumnSelection(columnSelection);
+ viewport.getAlignment().setHiddenColumns(hidden);
}
viewport.setScaleAboveWrapped(scaleAbove.getState());
{
copiedHiddenColumns = new Vector();
int hiddenOffset = viewport.getSelectionGroup().getStartRes();
- for (int[] region : viewport.getColumnSelection().getHiddenColumns())
+ for (int[] region : viewport.getAlignment().getHiddenColumns()
+ .getListOfCols())
{
copiedHiddenColumns.addElement(new int[] {
region[0] - hiddenOffset, region[1] - hiddenOffset });
* @param csel
* - columns to be selected on the alignment
*/
- public void select(SequenceGroup sel, ColumnSelection csel)
+ public void select(SequenceGroup sel, ColumnSelection csel,
+ HiddenColumns hidden)
{
- alignPanel.seqPanel.selection(sel, csel, null);
+ alignPanel.seqPanel.selection(sel, csel, hidden, null);
}
public void scrollTo(int row, int column)
import jalview.commands.CommandI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
{
getStructureSelectionManager().sendSelection(
new SequenceGroup(getSelectionGroup()),
- new ColumnSelection(getColumnSelection()), this);
+ new ColumnSelection(getColumnSelection()),
+ new HiddenColumns(getAlignment().getHiddenColumns()), this);
}
/**
int start = -1;
if (av.hasHiddenColumns())
{
- start = av.getColumnSelection().findColumnPosition(ostart);
- end = av.getColumnSelection().findColumnPosition(end);
+ AlignmentI al = av.getAlignment();
+ start = al.getHiddenColumns().findColumnPosition(ostart);
+ end = al.getHiddenColumns().findColumnPosition(end);
if (start == end)
{
- if (!scrollToNearest && !av.getColumnSelection().isVisible(ostart))
+ if (!scrollToNearest && !al.getHiddenColumns().isVisible(ostart))
{
// don't scroll - position isn't visible
return false;
if (av.hasHiddenColumns())
{
- width = av.getColumnSelection().findColumnPosition(width);
+ width = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(width);
}
if (x < 0)
{
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
int canvasWidth = seqPanel.seqCanvas
package jalview.appletgui;
import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.schemes.AnnotationColourGradient;
import jalview.util.MessageManager;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
private int actionOption = ACTION_OPTION_SELECT;
- private ColumnSelection oldColumnSelection;
+ private HiddenColumns oldHiddenColumns;
public AnnotationColumnChooser()
{
{
return;
}
- setOldColumnSelection(av.getColumnSelection());
+ setOldHiddenColumns(av.getAlignment().getHiddenColumns());
adjusting = true;
Vector<String> list = new Vector<String>();
int index = 1;
@SuppressWarnings("unchecked")
public void reset()
{
- if (this.getOldColumnSelection() != null)
+ if (this.getOldHiddenColumns() != null)
{
av.getColumnSelection().clear();
if (av.getAnnotationColumnSelectionState() != null)
{
- ColumnSelection oldSelection = av
+ HiddenColumns oldHidden = av
.getAnnotationColumnSelectionState()
- .getOldColumnSelection();
- if (oldSelection != null && oldSelection.getHiddenColumns() != null
- && !oldSelection.getHiddenColumns().isEmpty())
+ .getOldHiddenColumns();
+ if (oldHidden != null && oldHidden.getListOfCols() != null
+ && !oldHidden.getListOfCols().isEmpty())
{
- for (Iterator<int[]> itr = oldSelection.getHiddenColumns()
+ for (Iterator<int[]> itr = oldHidden.getListOfCols()
.iterator(); itr.hasNext();)
{
int positions[] = itr.next();
av.hideColumns(positions[0], positions[1]);
}
}
- av.setColumnSelection(oldSelection);
+ av.getAlignment().setHiddenColumns(oldHidden);
}
ap.paintAlignment(true);
}
ap.paintAlignment(true);
}
- public ColumnSelection getOldColumnSelection()
+ public HiddenColumns getOldHiddenColumns()
{
- return oldColumnSelection;
+ return oldHiddenColumns;
}
- public void setOldColumnSelection(ColumnSelection currentColumnSelection)
+ public void setOldHiddenColumns(HiddenColumns currentHiddenColumns)
{
- if (currentColumnSelection != null)
+ if (currentHiddenColumns != null)
{
- this.oldColumnSelection = new ColumnSelection(currentColumnSelection);
+ this.oldHiddenColumns = new HiddenColumns(currentHiddenColumns);
}
}
if (av.hasHiddenColumns())
{
jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector();
- for (int[] region : av.getColumnSelection().getHiddenColumns())
+ for (int[] region : av.getAlignment().getHiddenColumns()
+ .getListOfCols())
{
jalview.appletgui.AlignFrame.copiedHiddenColumns
.addElement(new int[] { region[0], region[1] });
{
for (int index : av.getColumnSelection().getSelected())
{
- if (av.getColumnSelection().isVisible(index))
+ if (av.getAlignment().getHiddenColumns().isVisible(index))
{
anot[index] = null;
}
{
// TODO: JAL-2001 - provide a fast method to list visible selected
// columns
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
if (av.hasHiddenColumns())
{
- column = av.getColumnSelection().adjustForHiddenColumns(column);
+ column = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(column);
}
if (row > -1 && column < aa[row].annotations.length
import jalview.api.FeaturesSourceI;
import jalview.bin.JalviewLite;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.io.AlignmentFileReaderI;
if (source instanceof ComplexAlignFile)
{
- ColumnSelection colSel = ((ComplexAlignFile) source)
- .getColumnSelection();
+ HiddenColumns colSel = ((ComplexAlignFile) source)
+ .getHiddenColumns();
SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
.getHiddenSequences();
boolean showSeqFeatures = ((ComplexAlignFile) source)
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
int annotationHeight = 0;
private void mouseAction(MouseEvent evt)
{
od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment()
- .getHiddenSequences(), av.getColumnSelection(), av
+ .getHiddenSequences(), av.getAlignment().getHiddenColumns(), av
.getRanges());
ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
ap.paintAlignment(false);
}
if (hiddenRow
- || (hasHiddenCols && !av.getColumnSelection()
+ || (hasHiddenCols && !av.getAlignment().getHiddenColumns()
.isVisible(lastcol)))
{
color = color.darker().darker();
public void setBoxPosition()
{
od.setBoxPosition(av.getAlignment()
- .getHiddenSequences(), av.getColumnSelection(), av.getRanges());
+.getHiddenSequences(), av
+ .getAlignment().getHiddenColumns(), av.getRanges());
repaint();
}
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SeqCigar;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
/**
* DOCUMENT ME!
*/
+ @Override
public void run()
{
// TODO progress indicator
rc.paint(rc.getGraphics());
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == inputData)
}
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == xCombobox)
}
;
Object[] alAndColsel = pcaModel.getSeqtrings()
- .getAlignmentAndColumnSelection(gc);
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
AlignFrame af = new AlignFrame(al, av.applet,
"Original Data for PCA", false);
- af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]);
+ af.viewport.getAlignment().setHiddenColumns(
+ (HiddenColumns) alAndColsel[1]);
}
}
package jalview.appletgui;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.renderer.ScaleRenderer;
import jalview.renderer.ScaleRenderer.ScaleMark;
if (av.hasHiddenColumns())
{
- res = av.getColumnSelection().adjustForHiddenColumns(x);
+ res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x);
}
else
{
});
pop.add(item);
- if (av.getColumnSelection().hasManyHiddenColumns())
+ if (av.getAlignment().getHiddenColumns().hasManyHiddenColumns())
{
item = new MenuItem(MessageManager.getString("action.reveal_all"));
item.addActionListener(new ActionListener()
if (av.hasHiddenColumns())
{
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(res);
}
if (!stretchingGroup)
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
res = Math.max(0, res);
- res = cs.adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
reveal = null;
- for (int[] region : av.getColumnSelection().getHiddenColumns())
+ for (int[] region : av.getAlignment().getHiddenColumns()
+ .getListOfCols())
{
if (res + 1 == region[0] || res - 1 == region[1])
{
// Fill the selected columns
ColumnSelection cs = av.getColumnSelection();
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
int avCharWidth = av.getCharWidth();
int avcharHeight = av.getCharHeight();
if (cs != null)
{
gg.setColor(new Color(220, 0, 0));
- boolean hasHiddenColumns = cs.hasHiddenColumns();
+ boolean hasHiddenColumns = hidden.hasHiddenColumns();
for (int sel : cs.getSelected())
{
// TODO: JAL-2001 - provide a fast method to list visible selected in a
// given range
if (hasHiddenColumns)
{
- if (cs.isVisible(sel))
+ if (hidden.isVisible(sel))
{
- sel = cs.findColumnPosition(sel);
+ sel = hidden.findColumnPosition(sel);
}
else
{
if (av.getShowHiddenMarkers())
{
int widthx = 1 + endx - startx;
- for (int i = 0; i < cs.getHiddenColumns().size(); i++)
+ for (int i = 0; i < hidden.getListOfCols().size(); i++)
{
- res = cs.findHiddenRegionPosition(i) - startx;
+ res = hidden.findHiddenRegionPosition(i) - startx;
if (res < 0 || res > widthx)
{
package jalview.appletgui;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
ypos += avcharHeight;
if (av.hasHiddenColumns())
{
- startx = av.getColumnSelection().adjustForHiddenColumns(startx);
- endx = av.getColumnSelection().adjustForHiddenColumns(endx);
+ startx = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(startx);
+ endx = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(endx);
}
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
// WEST SCALE
if (av.hasHiddenColumns())
{
- endx = av.getColumnSelection().adjustForHiddenColumns(endx);
+ endx = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(endx);
}
SequenceI seq;
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
while ((ypos <= canvasHeight) && (startRes < maxwidth))
}
if (av.hasHiddenColumns() && av.getShowHiddenMarkers())
{
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
g.setColor(Color.blue);
int res;
- for (int i = 0; i < av.getColumnSelection().getHiddenColumns()
+ for (int i = 0; i < hidden.getListOfCols()
.size(); i++)
{
- res = av.getColumnSelection().findHiddenRegionPosition(i)
+ res = hidden.findHiddenRegionPosition(i)
- startRes;
if (res < 0 || res > endx - startRes)
if (av.hasHiddenColumns())
{
- for (int[] region : av.getColumnSelection().getHiddenColumns())
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ for (int[] region : hidden.getListOfCols())
{
int hideStart = region[0];
int hideEnd = region[1];
import jalview.commands.EditCommand.Action;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
seqCanvas.cursorX += dx;
seqCanvas.cursorY += dy;
if (av.hasHiddenColumns()
- && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
+ && !av.getAlignment().getHiddenColumns()
+ .isVisible(seqCanvas.cursorX))
{
int original = seqCanvas.cursorX - dx;
int maxWidth = av.getAlignment().getWidth();
- while (!av.getColumnSelection().isVisible(seqCanvas.cursorX)
+ while (!av.getAlignment().getHiddenColumns()
+ .isVisible(seqCanvas.cursorX)
&& seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0)
{
seqCanvas.cursorX += dx;
}
if (seqCanvas.cursorX >= maxWidth
- || !av.getColumnSelection().isVisible(seqCanvas.cursorX))
+ || !av.getAlignment().getHiddenColumns()
+ .isVisible(seqCanvas.cursorX))
{
seqCanvas.cursorX = original;
}
else
{
ViewportRanges ranges = av.getRanges();
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
while (seqCanvas.cursorY < ranges.getStartSeq())
{
ap.scrollUp(true);
{
ap.scrollUp(false);
}
- while (seqCanvas.cursorX < av.getColumnSelection()
- .adjustForHiddenColumns(ranges.getStartRes()))
+ while (seqCanvas.cursorX < hidden.adjustForHiddenColumns(ranges
+ .getStartRes()))
{
if (!ap.scrollRight(false))
break;
}
}
- while (seqCanvas.cursorX > av.getColumnSelection()
- .adjustForHiddenColumns(ranges.getEndRes()))
+ while (seqCanvas.cursorX > hidden.adjustForHiddenColumns(ranges
+ .getEndRes()))
{
if (!ap.scrollRight(true))
{
if (av.hasHiddenColumns())
{
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(res);
}
return res;
if (av.hasHiddenColumns())
{
fixedColumns = true;
- int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres);
- int y2 = av.getColumnSelection().getHiddenBoundaryRight(startres);
+ int y1 = av.getAlignment().getHiddenColumns()
+ .getHiddenBoundaryLeft(startres);
+ int y2 = av.getAlignment().getHiddenColumns()
+ .getHiddenBoundaryRight(startres);
if ((insertGap && startres > y1 && lastres < y1)
|| (!insertGap && startres < y2 && lastres > y2))
{
if (sg.getSize() == av.getAlignment().getHeight())
{
- if ((av.hasHiddenColumns() && startres < av
- .getColumnSelection().getHiddenBoundaryRight(startres)))
+ if ((av.hasHiddenColumns() && startres < av.getAlignment()
+ .getHiddenColumns().getHiddenBoundaryRight(startres)))
{
endEditing();
return;
*/
@Override
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
- SelectionSource source)
+ HiddenColumns hidden, SelectionSource source)
{
// TODO: fix this hack - source of messages is align viewport, but SeqPanel
// handles selection messages...
}
if (copycolsel
&& av.hasHiddenColumns()
- && (av.getColumnSelection() == null || av.getColumnSelection()
- .getHiddenColumns() == null))
+ && (av.getColumnSelection() == null || av.getAlignment()
+ .getHiddenColumns().getListOfCols() == null))
{
System.err.println("Bad things");
}
import jalview.api.analysis.ViewBasedAnalysisI;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.io.NewickFile;
import jalview.schemes.ResidueProperties;
return tree;
}
+ @Override
public void finalize() throws Throwable
{
ap = null;
}
;
Object[] alAndColsel = tree.seqData
- .getAlignmentAndColumnSelection(gc);
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
AlignFrame af = new AlignFrame(al, av.applet,
"Original Data for Tree", false);
- af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]);
+ af.viewport.getAlignment().setHiddenColumns(
+ (HiddenColumns) alAndColsel[1]);
}
}
else
this.newtree = newtree;
}
+ @Override
public void run()
{
if (newtree != null)
}
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == newickOutput)
}
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == fitToWindow)
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
@Override
public void run()
{
- alf.select(sel, csel);
+ alf.select(sel, csel, alf.getAlignViewport().getAlignment()
+ .getHiddenColumns());
}
});
}
SequenceI repseq = alignFrame.viewport.getAlignment()
.getSequenceAt(0);
alignFrame.viewport.getAlignment().setSeqrep(repseq);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
cs.hideInsertionsFor(repseq);
- alignFrame.viewport.setColumnSelection(cs);
+ alignFrame.viewport.getAlignment().setHiddenColumns(cs);
alignFrame.alignPanel.fontChanged();
alignFrame.alignPanel.setScrollValues(0, 0);
result = true;
HiddenSequences hiddenSequences;
+ HiddenColumns hiddenCols;
+
public Hashtable alignmentProperties;
private List<AlignedCodonFrame> codonFrameList;
{
groups = Collections.synchronizedList(new ArrayList<SequenceGroup>());
hiddenSequences = new HiddenSequences(this);
+ hiddenCols = new HiddenColumns();
codonFrameList = new ArrayList<AlignedCodonFrame>();
nucleotide = Comparison.isNucleotide(seqs);
public Alignment(SeqCigar[] alseqs)
{
SequenceI[] seqs = SeqCigar.createAlignmentSequences(alseqs,
- gapCharacter, new ColumnSelection(), null);
+ gapCharacter, new HiddenColumns(), null);
initAlignment(seqs);
}
}
@Override
+ public HiddenColumns getHiddenColumns()
+ {
+ return hiddenCols;
+ }
+
+ @Override
public CigarArray getCompactAlignment()
{
synchronized (sequences)
}
return new int[] { startPos, endPos };
}
+
+ @Override
+ public void setHiddenColumns(HiddenColumns cols)
+ {
+ hiddenCols = cols;
+ }
}
*/
package jalview.datamodel;
+import jalview.analysis.Rna;
+import jalview.analysis.SecStrConsensus.SimpleBP;
+import jalview.analysis.WUSSParseException;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import jalview.analysis.Rna;
-import jalview.analysis.SecStrConsensus.SimpleBP;
-import jalview.analysis.WUSSParseException;
-
/**
* DOCUMENT ME!
*
* @param colSel
*/
public AlignmentAnnotation(AlignmentAnnotation alignmentAnnotation,
- ColumnSelection colSel)
+ HiddenColumns hidden)
{
this(alignmentAnnotation);
if (annotations == null)
{
return;
}
- colSel.makeVisibleAnnotation(this);
+ hidden.makeVisibleAnnotation(this);
}
public void setPadGaps(boolean padgaps, char gapchar)
HiddenSequences getHiddenSequences();
+ HiddenColumns getHiddenColumns();
+
/**
* Compact representation of alignment
*
*/
public int[] getVisibleStartAndEndIndex(List<int[]> hiddenCols);
+ public void setHiddenColumns(HiddenColumns cols);
+
}
* the view
*/
public AlignmentView(AlignmentI alignment,
- ColumnSelection columnSelection, SequenceGroup selection,
+ HiddenColumns hidden,
+ SequenceGroup selection,
boolean hasHiddenColumns, boolean selectedRegionOnly,
boolean recordGroups)
{
// refactored from AlignViewport.getAlignmentView(selectedOnly);
this(new jalview.datamodel.CigarArray(alignment,
- (hasHiddenColumns ? columnSelection : null),
+ (hasHiddenColumns ? hidden : null),
(selectedRegionOnly ? selection : null)),
(selectedRegionOnly && selection != null) ? selection
.getStartRes() : 0);
* char
* @return Object[] { SequenceI[], ColumnSelection}
*/
- public Object[] getAlignmentAndColumnSelection(char gapCharacter)
+ public Object[] getAlignmentAndHiddenColumns(char gapCharacter)
{
- ColumnSelection colsel = new ColumnSelection();
+ HiddenColumns hidden = new HiddenColumns();
return new Object[] {
- SeqCigar.createAlignmentSequences(sequences, gapCharacter, colsel,
- contigs), colsel };
+ SeqCigar.createAlignmentSequences(sequences, gapCharacter, hidden,
+ contigs), hidden };
}
/**
if (contigs != null && contigs.length > 0)
{
SequenceI[] alignment = new SequenceI[sequences.length];
- ColumnSelection columnselection = new ColumnSelection();
+ // ColumnSelection columnselection = new ColumnSelection();
+ HiddenColumns hidden = new HiddenColumns();
if (contigs != null && contigs.length > 0)
{
int start = 0;
}
}
// mark hidden segment as hidden in the new alignment
- columnselection.hideColumns(nwidth, nwidth + contigs[contig + 2]
+ hidden.hideColumns(nwidth, nwidth + contigs[contig + 2]
- 1);
nwidth += contigs[contig + 2];
}
}
}
}
- return new Object[] { alignment, columnselection };
+ return new Object[] { alignment, hidden };
}
else
{
}
else
{
- return getAlignmentAndColumnSelection(gapCharacter);
+ return getAlignmentAndHiddenColumns(gapCharacter);
}
}
}
}
public static void testSelectionViews(AlignmentI alignment,
- ColumnSelection csel, SequenceGroup selection)
+ HiddenColumns hidden, SequenceGroup selection)
{
System.out.println("Testing standard view creation:\n");
AlignmentView view = null;
{
System.out
.println("View with no hidden columns, no limit to selection, no groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, false, false,
+ view = new AlignmentView(alignment, hidden, selection, false, false,
false);
summariseAlignmentView(view, System.out);
{
System.out
.println("View with no hidden columns, no limit to selection, and all groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, false, false,
+ view = new AlignmentView(alignment, hidden, selection, false, false,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
System.out
.println("View with no hidden columns, limited to selection and no groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, false, true,
+ view = new AlignmentView(alignment, hidden, selection, false, true,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
System.out
.println("View with no hidden columns, limited to selection, and all groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, false, true,
+ view = new AlignmentView(alignment, hidden, selection, false, true,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
System.out
.println("View *with* hidden columns, no limit to selection, no groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, true, false,
+ view = new AlignmentView(alignment, hidden, selection, true, false,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
System.out
.println("View *with* hidden columns, no limit to selection, and all groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, true, false,
+ view = new AlignmentView(alignment, hidden, selection, true, false,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
System.out
.println("View *with* hidden columns, limited to selection and no groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, true, true,
+ view = new AlignmentView(alignment, hidden, selection, true, true,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
System.out
.println("View *with* hidden columns, limited to selection, and all groups to be collected:");
- view = new AlignmentView(alignment, csel, selection, true, true, true);
+ view = new AlignmentView(alignment, hidden, selection, true, true,
+ true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
*/
package jalview.datamodel;
+import htsjdk.samtools.Cigar;
+
import java.util.List;
public class CigarArray extends CigarBase
* @param columnSelection
* @param selectionGroup
*/
- public CigarArray(AlignmentI alignment, ColumnSelection columnSelection,
+ public CigarArray(AlignmentI alignment, HiddenColumns hidden,
SequenceGroup selectionGroup)
{
this(constructSeqCigarArray(alignment, selectionGroup));
constructFromAlignment(alignment,
- columnSelection != null ? columnSelection.getHiddenColumns()
+ hidden != null ? hidden.getListOfCols()
: null, selectionGroup);
}
*/
package jalview.datamodel;
-import jalview.util.Comparison;
import jalview.util.ShiftList;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter.SearchableAnnotationField;
import java.util.BitSet;
import java.util.Collections;
import java.util.List;
-import java.util.Vector;
/**
* Data class holding the selected columns and hidden column ranges for a view.
IntList selection = new IntList();
- /*
- * list of hidden column [start, end] ranges; the list is maintained in
- * ascending start column order
- */
- Vector<int[]> hiddenColumns;
+ HiddenColumns hiddenColumns = new HiddenColumns();
/**
* Add a column to the selection
* @param left
* shift in edit (+ve for removal, or -ve for inserts)
*/
- public List<int[]> compensateForEdit(int start, int change)
- {
- List<int[]> deletedHiddenColumns = null;
- selection.compensateForEdits(start, change);
-
- if (hiddenColumns != null)
+ /* public List<int[]> compensateForEdit(int start, int change)
{
- deletedHiddenColumns = new ArrayList<int[]>();
- int hSize = hiddenColumns.size();
- for (int i = 0; i < hSize; i++)
- {
- int[] region = hiddenColumns.elementAt(i);
- if (region[0] > start && start + change > region[1])
- {
- deletedHiddenColumns.add(region);
-
- hiddenColumns.removeElementAt(i);
- i--;
- hSize--;
- continue;
- }
-
- if (region[0] > start)
- {
- region[0] -= change;
- region[1] -= change;
- }
-
- if (region[0] < 0)
- {
- region[0] = 0;
- }
-
- }
-
- this.revealHiddenColumns(0);
+ selection.compensateForEdits(start, change);
+ return hiddenColumns.compensateForEdit(start, change, this);
}
-
- return deletedHiddenColumns;
- }
-
+ */
/**
* propagate shift in alignment columns to column selection special version of
* compensateForEdit - allowing for edits within hidden regions
*/
private void compensateForDelEdits(int start, int change)
{
-
selection.compensateForEdits(start, change);
-
- if (hiddenColumns != null)
- {
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.elementAt(i);
- if (region[0] >= start)
- {
- region[0] -= change;
- }
- if (region[1] >= start)
- {
- region[1] -= change;
- }
- if (region[1] < region[0])
- {
- hiddenColumns.removeElementAt(i--);
- }
-
- if (region[0] < 0)
- {
- region[0] = 0;
- }
- if (region[1] < 0)
- {
- region[1] = 0;
- }
- }
- }
+ hiddenColumns.compensateForDelEdits(start, change);
}
/**
* @param shiftrecord
* @return
*/
- public ShiftList compensateForEdits(ShiftList shiftrecord)
+ private ShiftList compensateForEdits(ShiftList shiftrecord)
{
if (shiftrecord != null)
{
for (int i = 0, j = shifts.size(); i < j; i++)
{
int[] sh = shifts.get(i);
- // compensateForEdit(shifted+sh[0], sh[1]);
compensateForDelEdits(shifted + sh[0], sh[1]);
shifted -= sh[1];
}
return null;
}
- /**
- * removes intersection of position,length ranges in deletions from the
- * start,end regions marked in intervals.
- *
- * @param shifts
- * @param intervals
- * @return
- */
- private boolean pruneIntervalVector(final List<int[]> shifts,
- Vector<int[]> intervals)
- {
- boolean pruned = false;
- int i = 0, j = intervals.size() - 1, s = 0, t = shifts.size() - 1;
- int hr[] = intervals.elementAt(i);
- int sr[] = shifts.get(s);
- while (i <= j && s <= t)
- {
- boolean trailinghn = hr[1] >= sr[0];
- if (!trailinghn)
- {
- if (i < j)
- {
- hr = intervals.elementAt(++i);
- }
- else
- {
- i++;
- }
- continue;
- }
- int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
- if (endshift < hr[0] || endshift < sr[0])
- { // leadinghc disjoint or not a deletion
- if (s < t)
- {
- sr = shifts.get(++s);
- }
- else
- {
- s++;
- }
- continue;
- }
- boolean leadinghn = hr[0] >= sr[0];
- boolean leadinghc = hr[0] < endshift;
- boolean trailinghc = hr[1] < endshift;
- if (leadinghn)
- {
- if (trailinghc)
- { // deleted hidden region.
- intervals.removeElementAt(i);
- pruned = true;
- j--;
- if (i <= j)
- {
- hr = intervals.elementAt(i);
- }
- continue;
- }
- if (leadinghc)
- {
- hr[0] = endshift; // clip c terminal region
- leadinghn = !leadinghn;
- pruned = true;
- }
- }
- if (!leadinghn)
- {
- if (trailinghc)
- {
- if (trailinghn)
- {
- hr[1] = sr[0] - 1;
- pruned = true;
- }
- }
- else
- {
- // sr contained in hr
- if (s < t)
- {
- sr = shifts.get(++s);
- }
- else
- {
- s++;
- }
- continue;
- }
- }
- }
- return pruned; // true if any interval was removed or modified by
- // operations.
- }
/**
* remove any hiddenColumns or selected columns and shift remaining based on a
*
* @param deletions
*/
- public void pruneDeletions(ShiftList deletions)
+ private void pruneDeletions(ShiftList deletions)
{
if (deletions != null)
{
final List<int[]> shifts = deletions.getShifts();
if (shifts != null && shifts.size() > 0)
{
- // delete any intervals intersecting.
- if (hiddenColumns != null)
- {
- pruneIntervalVector(shifts, hiddenColumns);
- if (hiddenColumns != null && hiddenColumns.size() == 0)
- {
- hiddenColumns = null;
- }
- }
+ hiddenColumns.pruneDeletions(shifts);
+
if (selection != null && selection.size() > 0)
{
selection.pruneColumnList(shifts);
}
}
- /**
- * This Method is used to return all the HiddenColumn regions
- *
- * @return empty list or List of hidden column intervals
- */
- public List<int[]> getHiddenColumns()
- {
- return hiddenColumns == null ? Collections.<int[]> emptyList()
- : hiddenColumns;
- }
- /**
- * Return absolute column index for a visible column index
- *
- * @param column
- * int column index in alignment view (count from zero)
- * @return alignment column index for column
- */
- public int adjustForHiddenColumns(int column)
- {
- int result = column;
- if (hiddenColumns != null)
- {
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.elementAt(i);
- if (result >= region[0])
- {
- result += region[1] - region[0] + 1;
- }
- }
- }
- return result;
- }
-
- /**
- * Use this method to find out where a column will appear in the visible
- * alignment when hidden columns exist. If the column is not visible, then the
- * left-most visible column will always be returned.
- *
- * @param hiddenColumn
- * the column index in the full alignment including hidden columns
- * @return the position of the column in the visible alignment
- */
- public int findColumnPosition(int hiddenColumn)
- {
- int result = hiddenColumn;
- if (hiddenColumns != null)
- {
- int index = 0;
- int[] region;
- do
- {
- region = hiddenColumns.elementAt(index++);
- if (hiddenColumn > region[1])
- {
- result -= region[1] + 1 - region[0];
- }
- } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));
-
- if (hiddenColumn >= region[0] && hiddenColumn <= region[1])
- {
- // Here the hidden column is within a region, so
- // we want to return the position of region[0]-1, adjusted for any
- // earlier hidden columns.
- // Calculate the difference between the actual hidden col position
- // and region[0]-1, and then subtract from result to convert result from
- // the adjusted hiddenColumn value to the adjusted region[0]-1 value
-
- // However, if the region begins at 0 we cannot return region[0]-1
- // just return 0
- if (region[0] == 0)
- {
- return 0;
- }
- else
- {
- return result - (hiddenColumn - region[0] + 1);
- }
- }
- }
- return result; // return the shifted position after removing hidden columns.
- }
-
- /**
- * Find the visible column which is a given visible number of columns to the
- * left of another visible column. i.e. for a startColumn x, the column which
- * is distance 1 away will be column x-1.
- *
- * @param visibleDistance
- * the number of visible columns to offset by
- * @param startColumn
- * the column to start from
- * @return the position of the column in the visible alignment
- */
- public int subtractVisibleColumns(int visibleDistance, int startColumn)
- {
- int distance = visibleDistance;
-
- // in case startColumn is in a hidden region, move it to the left
- int start = adjustForHiddenColumns(findColumnPosition(startColumn));
-
- // get index of hidden region to left of start
- int index = getHiddenIndexLeft(start);
- if (index == -1)
- {
- // no hidden regions to left of startColumn
- return start - distance;
- }
-
- // walk backwards through the alignment subtracting the counts of visible
- // columns from distance
- int[] region;
- int gap = 0;
- int nextstart = start;
-
- while ((index > -1) && (distance - gap > 0))
- {
- // subtract the gap to right of region from distance
- distance -= gap;
- start = nextstart;
-
- // calculate the next gap
- region = hiddenColumns.get(index);
- gap = start - region[1];
-
- // set start to just to left of current region
- nextstart = region[0] - 1;
- index--;
- }
-
- if (distance - gap > 0)
- {
- // fell out of loop because there are no more hidden regions
- distance -= gap;
- return nextstart - distance;
- }
- return start - distance;
-
- }
-
- /**
- * Use this method to determine where the next hiddenRegion starts
- *
- * @param hiddenRegion
- * index of hidden region (counts from 0)
- * @return column number in visible view
- */
- public int findHiddenRegionPosition(int hiddenRegion)
- {
- int result = 0;
- if (hiddenColumns != null)
- {
- int index = 0;
- int gaps = 0;
- do
- {
- int[] region = hiddenColumns.elementAt(index);
- if (hiddenRegion == 0)
- {
- return region[0];
- }
-
- gaps += region[1] + 1 - region[0];
- result = region[1] + 1;
- index++;
- } while (index <= hiddenRegion);
-
- result -= gaps;
- }
-
- return result;
- }
-
- /**
- * THis method returns the rightmost limit of a region of an alignment with
- * hidden columns. In otherwords, the next hidden column.
- *
- * @param index
- * int
- */
- public int getHiddenBoundaryRight(int alPos)
- {
- if (hiddenColumns != null)
- {
- int index = 0;
- do
- {
- int[] region = hiddenColumns.elementAt(index);
- if (alPos < region[0])
- {
- return region[0];
- }
-
- index++;
- } while (index < hiddenColumns.size());
- }
-
- return alPos;
-
- }
-
- /**
- * This method returns the leftmost limit of a region of an alignment with
- * hidden columns. In otherwords, the previous hidden column.
- *
- * @param index
- * int
- */
- public int getHiddenBoundaryLeft(int alPos)
- {
- if (hiddenColumns != null)
- {
- int index = hiddenColumns.size() - 1;
- do
- {
- int[] region = hiddenColumns.elementAt(index);
- if (alPos > region[1])
- {
- return region[1];
- }
-
- index--;
- } while (index > -1);
- }
-
- return alPos;
-
- }
-
- /**
- * This method returns the index of the hidden region to the left of a column
- * position. If the column is in a hidden region it returns the index of the
- * region to the left. If there is no hidden region to the left it returns -1.
- *
- * @param pos
- * int
- */
- private int getHiddenIndexLeft(int pos)
- {
- if (hiddenColumns != null)
- {
- int index = hiddenColumns.size() - 1;
- do
- {
- int[] region = hiddenColumns.elementAt(index);
- if (pos > region[1])
- {
- return index;
- }
-
- index--;
- } while (index > -1);
- }
-
- return -1;
-
- }
-
- public void hideSelectedColumns()
+ public void hideSelectedColumns(AlignmentI al)
{
synchronized (selection)
{
for (int[] selregions : selection.getRanges())
{
- hideColumns(selregions[0], selregions[1]);
+ al.getHiddenColumns().hideColumns(selregions[0], selregions[1]);
}
selection.clear();
}
}
- /**
- * Adds the specified column range to the hidden columns
- *
- * @param start
- * @param end
- */
- public void hideColumns(int start, int end)
- {
- if (hiddenColumns == null)
- {
- hiddenColumns = new Vector<int[]>();
- }
-
- /*
- * traverse existing hidden ranges and insert / amend / append as
- * appropriate
- */
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.elementAt(i);
-
- if (end < region[0] - 1)
- {
- /*
- * insert discontiguous preceding range
- */
- hiddenColumns.insertElementAt(new int[] { start, end }, i);
- return;
- }
-
- if (end <= region[1])
- {
- /*
- * new range overlaps existing, or is contiguous preceding it - adjust
- * start column
- */
- region[0] = Math.min(region[0], start);
- return;
- }
-
- if (start <= region[1] + 1)
- {
- /*
- * new range overlaps existing, or is contiguous following it - adjust
- * start and end columns
- */
- region[0] = Math.min(region[0], start);
- region[1] = Math.max(region[1], end);
-
- /*
- * also update or remove any subsequent ranges
- * that are overlapped
- */
- while (i < hiddenColumns.size() - 1)
- {
- int[] nextRegion = hiddenColumns.get(i + 1);
- if (nextRegion[0] > end + 1)
- {
- /*
- * gap to next hidden range - no more to update
- */
- break;
- }
- region[1] = Math.max(nextRegion[1], end);
- hiddenColumns.remove(i + 1);
- }
- return;
- }
- }
-
- /*
- * remaining case is that the new range follows everything else
- */
- hiddenColumns.addElement(new int[] { start, end });
- }
/**
* Hides the specified column and any adjacent selected columns
* @param res
* int
*/
- public void hideColumns(int col)
+ public void hideSelectedColumns(int col, AlignmentI al)
{
/*
* deselect column (whether selected or not!)
min = max;
}
- hideColumns(min, max);
+ al.getHiddenColumns().hideColumns(min, max);
}
- /**
- * Unhides, and adds to the selection list, all hidden columns
- */
- public void revealAllHiddenColumns()
- {
- if (hiddenColumns != null)
- {
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.elementAt(i);
- for (int j = region[0]; j < region[1] + 1; j++)
- {
- addElement(j);
- }
- }
- }
-
- hiddenColumns = null;
- }
-
- /**
- * Reveals, and marks as selected, the hidden column range with the given
- * start column
- *
- * @param start
- */
- public void revealHiddenColumns(int start)
- {
- for (int i = 0; i < hiddenColumns.size(); i++)
- {
- int[] region = hiddenColumns.elementAt(i);
- if (start == region[0])
- {
- for (int j = region[0]; j < region[1] + 1; j++)
- {
- addElement(j);
- }
- hiddenColumns.removeElement(region);
- break;
- }
- }
- if (hiddenColumns.size() == 0)
- {
- hiddenColumns = null;
- }
- }
- public boolean isVisible(int column)
- {
- if (hiddenColumns != null)
- {
- for (int[] region : hiddenColumns)
- {
- if (column >= region[0] && column <= region[1])
- {
- return false;
- }
- }
- }
- return true;
- }
/**
* Copy constructor
if (copy != null)
{
selection = new IntList(copy.selection);
- if (copy.hiddenColumns != null)
- {
- hiddenColumns = new Vector<int[]>(copy.hiddenColumns.size());
- for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
- {
- int[] rh, cp;
- rh = copy.hiddenColumns.elementAt(i);
- if (rh != null)
- {
- cp = new int[rh.length];
- System.arraycopy(rh, 0, cp, 0, rh.length);
- hiddenColumns.addElement(cp);
- }
- }
- }
}
}
{
}
- public String[] getVisibleSequenceStrings(int start, int end,
- SequenceI[] seqs)
- {
- int i, iSize = seqs.length;
- String selections[] = new String[iSize];
- if (hiddenColumns != null && hiddenColumns.size() > 0)
- {
- for (i = 0; i < iSize; i++)
- {
- StringBuffer visibleSeq = new StringBuffer();
- List<int[]> regions = getHiddenColumns();
-
- int blockStart = start, blockEnd = end;
- int[] region;
- int hideStart, hideEnd;
-
- for (int j = 0; j < regions.size(); j++)
- {
- region = regions.get(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));
- }
-
- selections[i] = visibleSeq.toString();
- }
- }
- else
- {
- for (i = 0; i < iSize; i++)
- {
- selections[i] = seqs[i].getSequenceAsString(start, end);
- }
- }
-
- return selections;
- }
-
- /**
- * return all visible segments between the given start and end boundaries
- *
- * @param start
- * (first column inclusive from 0)
- * @param end
- * (last column - not inclusive)
- * @return int[] {i_start, i_end, ..} where intervals lie in
- * start<=i_start<=i_end<end
- */
- public int[] getVisibleContigs(int start, int end)
- {
- if (hiddenColumns != null && hiddenColumns.size() > 0)
- {
- List<int[]> visiblecontigs = new ArrayList<int[]>();
- List<int[]> regions = getHiddenColumns();
-
- int vstart = start;
- int[] region;
- int hideStart, hideEnd;
-
- for (int j = 0; vstart < end && j < regions.size(); j++)
- {
- region = regions.get(j);
- hideStart = region[0];
- hideEnd = region[1];
-
- if (hideEnd < vstart)
- {
- continue;
- }
- if (hideStart > vstart)
- {
- visiblecontigs.add(new int[] { vstart, hideStart - 1 });
- }
- vstart = hideEnd + 1;
- }
-
- if (vstart < end)
- {
- visiblecontigs.add(new int[] { vstart, end - 1 });
- }
- int[] vcontigs = new int[visiblecontigs.size() * 2];
- for (int i = 0, j = visiblecontigs.size(); i < j; i++)
- {
- int[] vc = visiblecontigs.get(i);
- visiblecontigs.set(i, null);
- vcontigs[i * 2] = vc[0];
- vcontigs[i * 2 + 1] = vc[1];
- }
- visiblecontigs.clear();
- return vcontigs;
- }
- else
- {
- return new int[] { start, end - 1 };
- }
- }
-
- /**
- * Locate the first and last position visible for this sequence. if seq isn't
- * visible then return the position of the left and right of the hidden
- * boundary region, and the corresponding alignment column indices for the
- * extent of the sequence
- *
- * @param seq
- * @return int[] { visible start, visible end, first seqpos, last seqpos,
- * alignment index for seq start, alignment index for seq end }
- */
- public int[] locateVisibleBoundsOfSequence(SequenceI seq)
- {
- int fpos = seq.getStart(), lpos = seq.getEnd();
- int start = 0;
-
- if (hiddenColumns == null || hiddenColumns.size() == 0)
- {
- int ifpos = seq.findIndex(fpos) - 1, ilpos = seq.findIndex(lpos) - 1;
- return new int[] { ifpos, ilpos, fpos, lpos, ifpos, ilpos };
- }
-
- // Simply walk along the sequence whilst watching for hidden column
- // boundaries
- List<int[]> regions = getHiddenColumns();
- int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq
- .getLength(), hideEnd = -1;
- int visPrev = 0, visNext = 0, firstP = -1, lastP = -1;
- boolean foundStart = false;
- for (int p = 0, pLen = seq.getLength(); spos <= seq.getEnd()
- && p < pLen; p++)
- {
- if (!Comparison.isGap(seq.getCharAt(p)))
- {
- // keep track of first/last column
- // containing sequence data regardless of visibility
- if (firstP == -1)
- {
- firstP = p;
- }
- lastP = p;
- // update hidden region start/end
- while (hideEnd < p && rcount < regions.size())
- {
- int[] region = regions.get(rcount++);
- visPrev = visNext;
- visNext += region[0] - visPrev;
- hideStart = region[0];
- hideEnd = region[1];
- }
- if (hideEnd < p)
- {
- hideStart = seq.getLength();
- }
- // update visible boundary for sequence
- if (p < hideStart)
- {
- if (!foundStart)
- {
- fpos = spos;
- start = p;
- foundStart = true;
- }
- lastvispos = p;
- lpos = spos;
- }
- // look for next sequence position
- spos++;
- }
- }
- if (foundStart)
- {
- return new int[] { findColumnPosition(start),
- findColumnPosition(lastvispos), fpos, lpos, firstP, lastP };
- }
- // otherwise, sequence was completely hidden
- return new int[] { visPrev, visNext, 0, 0, firstP, lastP };
- }
-
- /**
- * delete any columns in alignmentAnnotation that are hidden (including
- * sequence associated annotation).
- *
- * @param alignmentAnnotation
- */
- public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
- {
- makeVisibleAnnotation(-1, -1, alignmentAnnotation);
- }
-
- /**
- * delete any columns in alignmentAnnotation that are hidden (including
- * sequence associated annotation).
- *
- * @param start
- * remove any annotation to the right of this column
- * @param end
- * remove any annotation to the left of this column
- * @param alignmentAnnotation
- * the annotation to operate on
- */
- public void makeVisibleAnnotation(int start, int end,
- AlignmentAnnotation alignmentAnnotation)
- {
- if (alignmentAnnotation.annotations == null)
- {
- return;
- }
- if (start == end && end == -1)
- {
- start = 0;
- end = alignmentAnnotation.annotations.length;
- }
- if (hiddenColumns != null && hiddenColumns.size() > 0)
- {
- // then mangle the alignmentAnnotation annotation array
- Vector<Annotation[]> annels = new Vector<Annotation[]>();
- Annotation[] els = null;
- List<int[]> regions = getHiddenColumns();
- int blockStart = start, blockEnd = end;
- int[] region;
- int hideStart, hideEnd, w = 0;
-
- for (int j = 0; j < regions.size(); j++)
- {
- region = regions.get(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;
- }
- annels.addElement(els = new Annotation[blockEnd - blockStart]);
- System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
- 0, els.length);
- w += els.length;
- blockStart = hideEnd + 1;
- blockEnd = end;
- }
- if (end > blockStart)
- {
- annels.addElement(els = new Annotation[end - blockStart + 1]);
- if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)
- {
- // copy just the visible segment of the annotation row
- System.arraycopy(alignmentAnnotation.annotations, blockStart,
- els, 0, els.length);
- }
- else
- {
- // copy to the end of the annotation row
- System.arraycopy(alignmentAnnotation.annotations, blockStart,
- els, 0,
- (alignmentAnnotation.annotations.length - blockStart));
- }
- w += els.length;
- }
- if (w == 0)
- {
- return;
- }
- alignmentAnnotation.annotations = new Annotation[w];
- w = 0;
- for (Annotation[] chnk : annels)
- {
- System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
- chnk.length);
- w += chnk.length;
- }
- }
- else
- {
- alignmentAnnotation.restrict(start, end);
- }
- }
/**
* Invert the column selection from first to end-1. leaves hiddenColumns
* @param first
* @param end
*/
- public void invertColumnSelection(int first, int width)
+ public void invertColumnSelection(int first, int width, AlignmentI al)
{
- boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;
+ boolean hasHidden = al.getHiddenColumns().hasHidden();
for (int i = first; i < width; i++)
{
if (contains(i))
}
else
{
- if (!hasHidden || isVisible(i))
+ if (!hasHidden || al.getHiddenColumns().isVisible(i))
{
addElement(i);
}
{
for (Integer col : colsel.getSelected())
{
- if (hiddenColumns != null && isVisible(col.intValue()))
+ if (hiddenColumns != null
+ && hiddenColumns.isVisible(col.intValue()))
{
selection.add(col);
}
selection = new IntList();
if (colsel.selection != null && colsel.selection.size() > 0)
{
- if (hiddenColumns != null && hiddenColumns.size() > 0)
+ if (hiddenColumns.hasHidden())
{
// only select visible columns in this columns selection
addElementsFrom(colsel);
// return propagateInsertions(profileseq, al, )
char gc = al.getGapCharacter();
- Object[] alandcolsel = input.getAlignmentAndColumnSelection(gc);
+ Object[] alandcolsel = input.getAlignmentAndHiddenColumns(gc);
ColumnSelection nview = (ColumnSelection) alandcolsel[1];
SequenceI origseq = ((SequenceI[]) alandcolsel[0])[profsqpos];
nview.propagateInsertions(profileseq, al, origseq);
* - sequence corresponding to profileseq which defines gap map for
* modifying al
*/
- public void propagateInsertions(SequenceI profileseq, AlignmentI al,
+ private void propagateInsertions(SequenceI profileseq, AlignmentI al,
SequenceI origseq)
{
char gc = al.getGapCharacter();
// recover mapping between sequence's non-gap positions and positions
// mapping to view.
pruneDeletions(ShiftList.parseMap(origseq.gapMap()));
- int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
+ int[] viscontigs = hiddenColumns.getVisibleContigs(0,
+ profileseq.getLength());
int spos = 0;
int offset = 0;
- // input.pruneDeletions(ShiftList.parseMap(((SequenceI[])
- // alandcolsel[0])[0].gapMap()))
+
// add profile to visible contigs
for (int v = 0; v < viscontigs.length; v += 2)
{
return (selection != null && selection.size() > 0);
}
- /**
- *
- * @return true if there are columns hidden
- */
- public boolean hasHiddenColumns()
- {
- return hiddenColumns != null && hiddenColumns.size() > 0;
- }
-
- /**
- *
- * @return true if there are more than one set of columns hidden
- */
- public boolean hasManyHiddenColumns()
- {
- return hiddenColumns != null && hiddenColumns.size() > 1;
- }
- /**
- * mark the columns corresponding to gap characters as hidden in the column
- * selection
- *
- * @param sr
- */
- public void hideInsertionsFor(SequenceI sr)
- {
- List<int[]> inserts = sr.getInsertions();
- for (int[] r : inserts)
- {
- hideColumns(r[0], r[1]);
- }
- }
public boolean filterAnnotations(Annotation[] annotations,
AnnotationFilterParameter filterParams)
{
// JBPNote - this method needs to be refactored to become independent of
// viewmodel package
- this.revealAllHiddenColumns();
+ hiddenColumns.revealAllHiddenColumns(this);
this.clear();
int count = 0;
do
public int hashCode()
{
int hashCode = selection.hashCode();
- if (hiddenColumns != null)
- {
- for (int[] hidden : hiddenColumns)
- {
- hashCode = 31 * hashCode + hidden[0];
- hashCode = 31 * hashCode + hidden[1];
- }
- }
- return hashCode;
+ return hiddenColumns.hashCode(hashCode);
}
/**
return false;
}
- /*
- * check hidden columns are either both null, or match
- */
- if (this.hiddenColumns == null)
- {
- return (that.hiddenColumns == null);
- }
- if (that.hiddenColumns == null
- || that.hiddenColumns.size() != this.hiddenColumns.size())
- {
- return false;
- }
- int i = 0;
- for (int[] thisRange : hiddenColumns)
- {
- int[] thatRange = that.hiddenColumns.get(i++);
- if (thisRange[0] != thatRange[0] || thisRange[1] != thatRange[1])
- {
- return false;
- }
- }
- return true;
+ return this.hiddenColumns.equals(that.hiddenColumns);
}
/**
--- /dev/null
+package jalview.datamodel;
+
+import jalview.util.Comparison;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+public class HiddenColumns
+{
+ /*
+ * list of hidden column [start, end] ranges; the list is maintained in
+ * ascending start column order
+ */
+ private Vector<int[]> hiddenColumns;
+
+ /**
+ * This Method is used to return all the HiddenColumn regions
+ *
+ * @return empty list or List of hidden column intervals
+ */
+ public List<int[]> getListOfCols()
+ {
+ return hiddenColumns == null ? Collections.<int[]> emptyList()
+ : hiddenColumns;
+ }
+
+ public boolean hasHidden()
+ {
+ return (hiddenColumns != null) && (!hiddenColumns.isEmpty());
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof HiddenColumns))
+ {
+ return false;
+ }
+ HiddenColumns that = (HiddenColumns) obj;
+
+ /*
+ * check hidden columns are either both null, or match
+ */
+ if (this.hiddenColumns == null)
+ {
+ return (that.hiddenColumns == null);
+ }
+ if (that.hiddenColumns == null
+ || that.hiddenColumns.size() != this.hiddenColumns.size())
+ {
+ return false;
+ }
+ int i = 0;
+ for (int[] thisRange : hiddenColumns)
+ {
+ int[] thatRange = that.hiddenColumns.get(i++);
+ if (thisRange[0] != thatRange[0] || thisRange[1] != thatRange[1])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return absolute column index for a visible column index
+ *
+ * @param column
+ * int column index in alignment view (count from zero)
+ * @return alignment column index for column
+ */
+ public int adjustForHiddenColumns(int column)
+ {
+ int result = column;
+ if (hiddenColumns != null)
+ {
+ for (int i = 0; i < hiddenColumns.size(); i++)
+ {
+ int[] region = hiddenColumns.elementAt(i);
+ if (result >= region[0])
+ {
+ result += region[1] - region[0] + 1;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Use this method to find out where a column will appear in the visible
+ * alignment when hidden columns exist. If the column is not visible, then the
+ * left-most visible column will always be returned.
+ *
+ * @param hiddenColumn
+ * the column index in the full alignment including hidden columns
+ * @return the position of the column in the visible alignment
+ */
+ public int findColumnPosition(int hiddenColumn)
+ {
+ int result = hiddenColumn;
+ if (hiddenColumns != null)
+ {
+ int index = 0;
+ int[] region;
+ do
+ {
+ region = hiddenColumns.elementAt(index++);
+ if (hiddenColumn > region[1])
+ {
+ result -= region[1] + 1 - region[0];
+ }
+ } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));
+
+ if (hiddenColumn >= region[0] && hiddenColumn <= region[1])
+ {
+ // Here the hidden column is within a region, so
+ // we want to return the position of region[0]-1, adjusted for any
+ // earlier hidden columns.
+ // Calculate the difference between the actual hidden col position
+ // and region[0]-1, and then subtract from result to convert result from
+ // the adjusted hiddenColumn value to the adjusted region[0]-1 value
+
+ // However, if the region begins at 0 we cannot return region[0]-1
+ // just return 0
+ if (region[0] == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return result - (hiddenColumn - region[0] + 1);
+ }
+ }
+ }
+ return result; // return the shifted position after removing hidden columns.
+ }
+
+ /**
+ * Find the visible column which is a given visible number of columns to the
+ * left of another visible column. i.e. for a startColumn x, the column which
+ * is distance 1 away will be column x-1.
+ *
+ * @param visibleDistance
+ * the number of visible columns to offset by
+ * @param startColumn
+ * the column to start from
+ * @return the position of the column in the visible alignment
+ */
+ public int subtractVisibleColumns(int visibleDistance, int startColumn)
+ {
+ int distance = visibleDistance;
+
+ // in case startColumn is in a hidden region, move it to the left
+ int start = adjustForHiddenColumns(findColumnPosition(startColumn));
+
+ // get index of hidden region to left of start
+ int index = getHiddenIndexLeft(start);
+ if (index == -1)
+ {
+ // no hidden regions to left of startColumn
+ return start - distance;
+ }
+
+ // walk backwards through the alignment subtracting the counts of visible
+ // columns from distance
+ int[] region;
+ int gap = 0;
+ int nextstart = start;
+
+ while ((index > -1) && (distance - gap > 0))
+ {
+ // subtract the gap to right of region from distance
+ distance -= gap;
+ start = nextstart;
+
+ // calculate the next gap
+ region = hiddenColumns.get(index);
+ gap = start - region[1];
+
+ // set start to just to left of current region
+ nextstart = region[0] - 1;
+ index--;
+ }
+
+ if (distance - gap > 0)
+ {
+ // fell out of loop because there are no more hidden regions
+ distance -= gap;
+ return nextstart - distance;
+ }
+ return start - distance;
+
+ }
+
+ /**
+ * Use this method to determine where the next hiddenRegion starts
+ *
+ * @param hiddenRegion
+ * index of hidden region (counts from 0)
+ * @return column number in visible view
+ */
+ public int findHiddenRegionPosition(int hiddenRegion)
+ {
+ int result = 0;
+ if (hiddenColumns != null)
+ {
+ int index = 0;
+ int gaps = 0;
+ do
+ {
+ int[] region = hiddenColumns.elementAt(index);
+ if (hiddenRegion == 0)
+ {
+ return region[0];
+ }
+
+ gaps += region[1] + 1 - region[0];
+ result = region[1] + 1;
+ index++;
+ } while (index <= hiddenRegion);
+
+ result -= gaps;
+ }
+
+ return result;
+ }
+
+ /**
+ * This method returns the rightmost limit of a region of an alignment with
+ * hidden columns. In otherwords, the next hidden column.
+ *
+ * @param index
+ * int
+ */
+ public int getHiddenBoundaryRight(int alPos)
+ {
+ if (hiddenColumns != null)
+ {
+ int index = 0;
+ do
+ {
+ int[] region = hiddenColumns.elementAt(index);
+ if (alPos < region[0])
+ {
+ return region[0];
+ }
+
+ index++;
+ } while (index < hiddenColumns.size());
+ }
+
+ return alPos;
+
+ }
+
+ /**
+ * This method returns the leftmost limit of a region of an alignment with
+ * hidden columns. In otherwords, the previous hidden column.
+ *
+ * @param index
+ * int
+ */
+ public int getHiddenBoundaryLeft(int alPos)
+ {
+ if (hiddenColumns != null)
+ {
+ int index = hiddenColumns.size() - 1;
+ do
+ {
+ int[] region = hiddenColumns.elementAt(index);
+ if (alPos > region[1])
+ {
+ return region[1];
+ }
+
+ index--;
+ } while (index > -1);
+ }
+
+ return alPos;
+
+ }
+
+ /**
+ * This method returns the index of the hidden region to the left of a column
+ * position. If the column is in a hidden region it returns the index of the
+ * region to the left. If there is no hidden region to the left it returns -1.
+ *
+ * @param pos
+ * int
+ */
+ private int getHiddenIndexLeft(int pos)
+ {
+ if (hiddenColumns != null)
+ {
+ int index = hiddenColumns.size() - 1;
+ do
+ {
+ int[] region = hiddenColumns.elementAt(index);
+ if (pos > region[1])
+ {
+ return index;
+ }
+
+ index--;
+ } while (index > -1);
+ }
+
+ return -1;
+
+ }
+
+ /**
+ * Adds the specified column range to the hidden columns
+ *
+ * @param start
+ * @param end
+ */
+ public void hideColumns(int start, int end)
+ {
+ if (hiddenColumns == null)
+ {
+ hiddenColumns = new Vector<int[]>();
+ }
+
+ /*
+ * traverse existing hidden ranges and insert / amend / append as
+ * appropriate
+ */
+ for (int i = 0; i < hiddenColumns.size(); i++)
+ {
+ int[] region = hiddenColumns.elementAt(i);
+
+ if (end < region[0] - 1)
+ {
+ /*
+ * insert discontiguous preceding range
+ */
+ hiddenColumns.insertElementAt(new int[] { start, end }, i);
+ return;
+ }
+
+ if (end <= region[1])
+ {
+ /*
+ * new range overlaps existing, or is contiguous preceding it - adjust
+ * start column
+ */
+ region[0] = Math.min(region[0], start);
+ return;
+ }
+
+ if (start <= region[1] + 1)
+ {
+ /*
+ * new range overlaps existing, or is contiguous following it - adjust
+ * start and end columns
+ */
+ region[0] = Math.min(region[0], start);
+ region[1] = Math.max(region[1], end);
+
+ /*
+ * also update or remove any subsequent ranges
+ * that are overlapped
+ */
+ while (i < hiddenColumns.size() - 1)
+ {
+ int[] nextRegion = hiddenColumns.get(i + 1);
+ if (nextRegion[0] > end + 1)
+ {
+ /*
+ * gap to next hidden range - no more to update
+ */
+ break;
+ }
+ region[1] = Math.max(nextRegion[1], end);
+ hiddenColumns.remove(i + 1);
+ }
+ return;
+ }
+ }
+
+ /*
+ * remaining case is that the new range follows everything else
+ */
+ hiddenColumns.addElement(new int[] { start, end });
+ }
+
+ public boolean isVisible(int column)
+ {
+ if (hiddenColumns != null)
+ {
+ for (int[] region : hiddenColumns)
+ {
+ if (column >= region[0] && column <= region[1])
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * ColumnSelection
+ */
+ public HiddenColumns()
+ {
+ }
+
+ /**
+ * Copy constructor
+ *
+ * @param copy
+ */
+ public HiddenColumns(HiddenColumns copy)
+ {
+ if (copy != null)
+ {
+ if (copy.hiddenColumns != null)
+ {
+ hiddenColumns = new Vector<int[]>(copy.hiddenColumns.size());
+ for (int i = 0, j = copy.hiddenColumns.size(); i < j; i++)
+ {
+ int[] rh, cp;
+ rh = copy.hiddenColumns.elementAt(i);
+ if (rh != null)
+ {
+ cp = new int[rh.length];
+ System.arraycopy(rh, 0, cp, 0, rh.length);
+ hiddenColumns.addElement(cp);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * propagate shift in alignment columns to column selection
+ *
+ * @param start
+ * beginning of edit
+ * @param left
+ * shift in edit (+ve for removal, or -ve for inserts)
+ */
+ public List<int[]> compensateForEdit(int start, int change,
+ ColumnSelection sel)
+ {
+ List<int[]> deletedHiddenColumns = null;
+
+ if (hiddenColumns != null)
+ {
+ deletedHiddenColumns = new ArrayList<int[]>();
+ int hSize = hiddenColumns.size();
+ for (int i = 0; i < hSize; i++)
+ {
+ int[] region = hiddenColumns.elementAt(i);
+ if (region[0] > start && start + change > region[1])
+ {
+ deletedHiddenColumns.add(region);
+
+ hiddenColumns.removeElementAt(i);
+ i--;
+ hSize--;
+ continue;
+ }
+
+ if (region[0] > start)
+ {
+ region[0] -= change;
+ region[1] -= change;
+ }
+
+ if (region[0] < 0)
+ {
+ region[0] = 0;
+ }
+
+ }
+
+ this.revealHiddenColumns(0, sel);
+ }
+
+ return deletedHiddenColumns;
+ }
+
+ /**
+ * propagate shift in alignment columns to column selection special version of
+ * compensateForEdit - allowing for edits within hidden regions
+ *
+ * @param start
+ * beginning of edit
+ * @param left
+ * shift in edit (+ve for removal, or -ve for inserts)
+ */
+ public void compensateForDelEdits(int start, int change)
+ {
+ if (hiddenColumns != null)
+ {
+ for (int i = 0; i < hiddenColumns.size(); i++)
+ {
+ int[] region = hiddenColumns.elementAt(i);
+ if (region[0] >= start)
+ {
+ region[0] -= change;
+ }
+ if (region[1] >= start)
+ {
+ region[1] -= change;
+ }
+ if (region[1] < region[0])
+ {
+ hiddenColumns.removeElementAt(i--);
+ }
+
+ if (region[0] < 0)
+ {
+ region[0] = 0;
+ }
+ if (region[1] < 0)
+ {
+ region[1] = 0;
+ }
+ }
+ }
+ }
+
+ /**
+ * return all visible segments between the given start and end boundaries
+ *
+ * @param start
+ * (first column inclusive from 0)
+ * @param end
+ * (last column - not inclusive)
+ * @return int[] {i_start, i_end, ..} where intervals lie in
+ * start<=i_start<=i_end<end
+ */
+ public int[] getVisibleContigs(int start, int end)
+ {
+ if (hiddenColumns != null && hiddenColumns.size() > 0)
+ {
+ List<int[]> visiblecontigs = new ArrayList<int[]>();
+ List<int[]> regions = getListOfCols();
+
+ int vstart = start;
+ int[] region;
+ int hideStart, hideEnd;
+
+ for (int j = 0; vstart < end && j < regions.size(); j++)
+ {
+ region = regions.get(j);
+ hideStart = region[0];
+ hideEnd = region[1];
+
+ if (hideEnd < vstart)
+ {
+ continue;
+ }
+ if (hideStart > vstart)
+ {
+ visiblecontigs.add(new int[] { vstart, hideStart - 1 });
+ }
+ vstart = hideEnd + 1;
+ }
+
+ if (vstart < end)
+ {
+ visiblecontigs.add(new int[] { vstart, end - 1 });
+ }
+ int[] vcontigs = new int[visiblecontigs.size() * 2];
+ for (int i = 0, j = visiblecontigs.size(); i < j; i++)
+ {
+ int[] vc = visiblecontigs.get(i);
+ visiblecontigs.set(i, null);
+ vcontigs[i * 2] = vc[0];
+ vcontigs[i * 2 + 1] = vc[1];
+ }
+ visiblecontigs.clear();
+ return vcontigs;
+ }
+ else
+ {
+ return new int[] { start, end - 1 };
+ }
+ }
+
+ public String[] getVisibleSequenceStrings(int start, int end,
+ SequenceI[] seqs)
+ {
+ int i, iSize = seqs.length;
+ String selections[] = new String[iSize];
+ if (hiddenColumns != null && hiddenColumns.size() > 0)
+ {
+ for (i = 0; i < iSize; i++)
+ {
+ StringBuffer visibleSeq = new StringBuffer();
+ List<int[]> regions = getListOfCols();
+
+ int blockStart = start, blockEnd = end;
+ int[] region;
+ int hideStart, hideEnd;
+
+ for (int j = 0; j < regions.size(); j++)
+ {
+ region = regions.get(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));
+ }
+
+ selections[i] = visibleSeq.toString();
+ }
+ }
+ else
+ {
+ for (i = 0; i < iSize; i++)
+ {
+ selections[i] = seqs[i].getSequenceAsString(start, end);
+ }
+ }
+
+ return selections;
+ }
+
+ /**
+ * Locate the first and last position visible for this sequence. if seq isn't
+ * visible then return the position of the left and right of the hidden
+ * boundary region, and the corresponding alignment column indices for the
+ * extent of the sequence
+ *
+ * @param seq
+ * @return int[] { visible start, visible end, first seqpos, last seqpos,
+ * alignment index for seq start, alignment index for seq end }
+ */
+ public int[] locateVisibleBoundsOfSequence(SequenceI seq)
+ {
+ int fpos = seq.getStart(), lpos = seq.getEnd();
+ int start = 0;
+
+ if (hiddenColumns == null || hiddenColumns.size() == 0)
+ {
+ int ifpos = seq.findIndex(fpos) - 1, ilpos = seq.findIndex(lpos) - 1;
+ return new int[] { ifpos, ilpos, fpos, lpos, ifpos, ilpos };
+ }
+
+ // Simply walk along the sequence whilst watching for hidden column
+ // boundaries
+ List<int[]> regions = getListOfCols();
+ int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq
+ .getLength(), hideEnd = -1;
+ int visPrev = 0, visNext = 0, firstP = -1, lastP = -1;
+ boolean foundStart = false;
+ for (int p = 0, pLen = seq.getLength(); spos <= seq.getEnd()
+ && p < pLen; p++)
+ {
+ if (!Comparison.isGap(seq.getCharAt(p)))
+ {
+ // keep track of first/last column
+ // containing sequence data regardless of visibility
+ if (firstP == -1)
+ {
+ firstP = p;
+ }
+ lastP = p;
+ // update hidden region start/end
+ while (hideEnd < p && rcount < regions.size())
+ {
+ int[] region = regions.get(rcount++);
+ visPrev = visNext;
+ visNext += region[0] - visPrev;
+ hideStart = region[0];
+ hideEnd = region[1];
+ }
+ if (hideEnd < p)
+ {
+ hideStart = seq.getLength();
+ }
+ // update visible boundary for sequence
+ if (p < hideStart)
+ {
+ if (!foundStart)
+ {
+ fpos = spos;
+ start = p;
+ foundStart = true;
+ }
+ lastvispos = p;
+ lpos = spos;
+ }
+ // look for next sequence position
+ spos++;
+ }
+ }
+ if (foundStart)
+ {
+ return new int[] { findColumnPosition(start),
+ findColumnPosition(lastvispos), fpos, lpos, firstP, lastP };
+ }
+ // otherwise, sequence was completely hidden
+ return new int[] { visPrev, visNext, 0, 0, firstP, lastP };
+ }
+
+ /**
+ * delete any columns in alignmentAnnotation that are hidden (including
+ * sequence associated annotation).
+ *
+ * @param alignmentAnnotation
+ */
+ public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
+ {
+ makeVisibleAnnotation(-1, -1, alignmentAnnotation);
+ }
+
+ /**
+ * delete any columns in alignmentAnnotation that are hidden (including
+ * sequence associated annotation).
+ *
+ * @param start
+ * remove any annotation to the right of this column
+ * @param end
+ * remove any annotation to the left of this column
+ * @param alignmentAnnotation
+ * the annotation to operate on
+ */
+ public void makeVisibleAnnotation(int start, int end,
+ AlignmentAnnotation alignmentAnnotation)
+ {
+ if (alignmentAnnotation.annotations == null)
+ {
+ return;
+ }
+ if (start == end && end == -1)
+ {
+ start = 0;
+ end = alignmentAnnotation.annotations.length;
+ }
+ if (hiddenColumns != null && hiddenColumns.size() > 0)
+ {
+ // then mangle the alignmentAnnotation annotation array
+ Vector<Annotation[]> annels = new Vector<Annotation[]>();
+ Annotation[] els = null;
+ List<int[]> regions = getListOfCols();
+ int blockStart = start, blockEnd = end;
+ int[] region;
+ int hideStart, hideEnd, w = 0;
+
+ for (int j = 0; j < regions.size(); j++)
+ {
+ region = regions.get(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;
+ }
+
+ annels.addElement(els = new Annotation[blockEnd - blockStart]);
+ System.arraycopy(alignmentAnnotation.annotations, blockStart, els,
+ 0, els.length);
+ w += els.length;
+ blockStart = hideEnd + 1;
+ blockEnd = end;
+ }
+
+ if (end > blockStart)
+ {
+ annels.addElement(els = new Annotation[end - blockStart + 1]);
+ if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)
+ {
+ // copy just the visible segment of the annotation row
+ System.arraycopy(alignmentAnnotation.annotations, blockStart,
+ els, 0, els.length);
+ }
+ else
+ {
+ // copy to the end of the annotation row
+ System.arraycopy(alignmentAnnotation.annotations, blockStart,
+ els, 0,
+ (alignmentAnnotation.annotations.length - blockStart));
+ }
+ w += els.length;
+ }
+ if (w == 0)
+ {
+ return;
+ }
+
+ alignmentAnnotation.annotations = new Annotation[w];
+ w = 0;
+
+ for (Annotation[] chnk : annels)
+ {
+ System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,
+ chnk.length);
+ w += chnk.length;
+ }
+ }
+ else
+ {
+ alignmentAnnotation.restrict(start, end);
+ }
+ }
+
+ /**
+ *
+ * @return true if there are columns hidden
+ */
+ public boolean hasHiddenColumns()
+ {
+ return hiddenColumns != null && hiddenColumns.size() > 0;
+ }
+
+ /**
+ *
+ * @return true if there are more than one set of columns hidden
+ */
+ public boolean hasManyHiddenColumns()
+ {
+ return hiddenColumns != null && hiddenColumns.size() > 1;
+ }
+
+ /**
+ * mark the columns corresponding to gap characters as hidden in the column
+ * selection
+ *
+ * @param sr
+ */
+ public void hideInsertionsFor(SequenceI sr)
+ {
+ List<int[]> inserts = sr.getInsertions();
+ for (int[] r : inserts)
+ {
+ hideColumns(r[0], r[1]);
+ }
+ }
+
+ /**
+ * Unhides, and adds to the selection list, all hidden columns
+ */
+ public void revealAllHiddenColumns(ColumnSelection sel)
+ {
+ if (hiddenColumns != null)
+ {
+ for (int i = 0; i < hiddenColumns.size(); i++)
+ {
+ int[] region = hiddenColumns.elementAt(i);
+ for (int j = region[0]; j < region[1] + 1; j++)
+ {
+ sel.addElement(j);
+ }
+ }
+ }
+
+ hiddenColumns = null;
+ }
+
+ /**
+ * Reveals, and marks as selected, the hidden column range with the given
+ * start column
+ *
+ * @param start
+ */
+ public void revealHiddenColumns(int start, ColumnSelection sel)
+ {
+ for (int i = 0; i < hiddenColumns.size(); i++)
+ {
+ int[] region = hiddenColumns.elementAt(i);
+ if (start == region[0])
+ {
+ for (int j = region[0]; j < region[1] + 1; j++)
+ {
+ sel.addElement(j);
+ }
+
+ hiddenColumns.removeElement(region);
+ break;
+ }
+ }
+ if (hiddenColumns.size() == 0)
+ {
+ hiddenColumns = null;
+ }
+ }
+
+ /**
+ * removes intersection of position,length ranges in deletions from the
+ * start,end regions marked in intervals.
+ *
+ * @param shifts
+ * @param intervals
+ * @return
+ */
+ private boolean pruneIntervalVector(final List<int[]> shifts,
+ Vector<int[]> intervals)
+ {
+ boolean pruned = false;
+ int i = 0, j = intervals.size() - 1, s = 0, t = shifts.size() - 1;
+ int hr[] = intervals.elementAt(i);
+ int sr[] = shifts.get(s);
+ while (i <= j && s <= t)
+ {
+ boolean trailinghn = hr[1] >= sr[0];
+ if (!trailinghn)
+ {
+ if (i < j)
+ {
+ hr = intervals.elementAt(++i);
+ }
+ else
+ {
+ i++;
+ }
+ continue;
+ }
+ int endshift = sr[0] + sr[1]; // deletion ranges - -ve means an insert
+ if (endshift < hr[0] || endshift < sr[0])
+ { // leadinghc disjoint or not a deletion
+ if (s < t)
+ {
+ sr = shifts.get(++s);
+ }
+ else
+ {
+ s++;
+ }
+ continue;
+ }
+ boolean leadinghn = hr[0] >= sr[0];
+ boolean leadinghc = hr[0] < endshift;
+ boolean trailinghc = hr[1] < endshift;
+ if (leadinghn)
+ {
+ if (trailinghc)
+ { // deleted hidden region.
+ intervals.removeElementAt(i);
+ pruned = true;
+ j--;
+ if (i <= j)
+ {
+ hr = intervals.elementAt(i);
+ }
+ continue;
+ }
+ if (leadinghc)
+ {
+ hr[0] = endshift; // clip c terminal region
+ leadinghn = !leadinghn;
+ pruned = true;
+ }
+ }
+ if (!leadinghn)
+ {
+ if (trailinghc)
+ {
+ if (trailinghn)
+ {
+ hr[1] = sr[0] - 1;
+ pruned = true;
+ }
+ }
+ else
+ {
+ // sr contained in hr
+ if (s < t)
+ {
+ sr = shifts.get(++s);
+ }
+ else
+ {
+ s++;
+ }
+ continue;
+ }
+ }
+ }
+ return pruned; // true if any interval was removed or modified by
+ // operations.
+ }
+
+ /**
+ * remove any hiddenColumns or selected columns and shift remaining based on a
+ * series of position, range deletions.
+ *
+ * @param deletions
+ */
+ public void pruneDeletions(List<int[]> shifts)
+ {
+ // delete any intervals intersecting.
+ if (hiddenColumns != null)
+ {
+ pruneIntervalVector(shifts, hiddenColumns);
+ if (hiddenColumns != null && hiddenColumns.size() == 0)
+ {
+ hiddenColumns = null;
+ }
+ }
+ }
+
+ /**
+ * Returns a hashCode built from selected columns and hidden column ranges
+ */
+ public int hashCode(int hc)
+ {
+ int hashCode = hc;
+ if (hiddenColumns != null)
+ {
+ for (int[] hidden : hiddenColumns)
+ {
+ hashCode = 31 * hashCode + hidden[0];
+ hashCode = 31 * hashCode + hidden[1];
+ }
+ }
+ return hashCode;
+ }
+
+}
/**
* create an alignment from the given array of cigar sequences and gap
* character, and marking the given segments as visible in the given
- * columselection.
+ * hiddenColumns.
*
* @param alseqs
* @param gapCharacter
- * @param colsel
- * - columnSelection where hidden regions are marked
+ * @param hidden
+ * - hiddenColumns where hidden regions are marked
* @param segments
* - visible regions of alignment
* @return SequenceI[]
*/
public static SequenceI[] createAlignmentSequences(SeqCigar[] alseqs,
- char gapCharacter, ColumnSelection colsel, int[] segments)
+ char gapCharacter, HiddenColumns hidden, int[] segments)
{
SequenceI[] seqs = new SequenceI[alseqs.length];
StringBuffer[] g_seqs = new StringBuffer[alseqs.length];
if (segments == null)
{
// add a hidden column for this deletion
- colsel.hideColumns(inspos, inspos + insert.length - 1);
+ hidden.hideColumns(inspos, inspos + insert.length - 1);
}
}
}
{
// int start=shifts.shift(segments[i]-1)+1;
// int end=shifts.shift(segments[i]+segments[i+1]-1)-1;
- colsel.hideColumns(segments[i + 1], segments[i + 1]
+ hidden.hideColumns(segments[i + 1], segments[i + 1]
+ segments[i + 2] - 1);
}
}
import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
* TODO
*/
public void superposeStructures(AlignmentI alignment, int refStructure,
- ColumnSelection hiddenCols)
+ HiddenColumns hiddenCols)
{
superposeStructures(new AlignmentI[] { alignment },
new int[] { refStructure },
- new ColumnSelection[] { hiddenCols });
+ new HiddenColumns[] { hiddenCols });
}
/**
*/
@Override
public String superposeStructures(AlignmentI[] _alignment,
- int[] _refStructure, ColumnSelection[] _hiddenCols)
+ int[] _refStructure, HiddenColumns[] _hiddenCols)
{
while (viewer.isScriptExecuting())
{
{
int refStructure = _refStructure[a];
AlignmentI alignment = _alignment[a];
- ColumnSelection hiddenCols = _hiddenCols[a];
+ HiddenColumns hiddenCols = _hiddenCols[a];
if (a > 0
&& selectioncom.length() > 0
&& !selectioncom.substring(selectioncom.length() - 1).equals(
import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
import jalview.structure.StructureMapping;
FeatureRenderer fr = viewPanel.getFeatureRenderer();
FeatureColourFinder finder = new FeatureColourFinder(fr);
AlignViewportI viewport = viewPanel.getAlignViewport();
- ColumnSelection cs = viewport.getColumnSelection();
+ HiddenColumns cs = viewport.getAlignment().getHiddenColumns();
AlignmentI al = viewport.getAlignment();
List<StructureMappingcommandSet> cset = new ArrayList<StructureMappingcommandSet>();
import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.renderer.seqfeatures.FeatureColourFinder;
FeatureRenderer fr = viewPanel.getFeatureRenderer();
FeatureColourFinder finder = new FeatureColourFinder(fr);
AlignViewportI viewport = viewPanel.getAlignViewport();
- ColumnSelection cs = viewport.getColumnSelection();
+ HiddenColumns cs = viewport.getAlignment().getHiddenColumns();
AlignmentI al = viewport.getAlignment();
Map<Object, AtomSpecModel> colourMap = new LinkedHashMap<Object, AtomSpecModel>();
Color lastColour = null;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResultsI;
*/
@Override
public String superposeStructures(AlignmentI[] _alignment,
- int[] _refStructure, ColumnSelection[] _hiddenCols)
+ int[] _refStructure, HiddenColumns[] _hiddenCols)
{
StringBuilder allComs = new StringBuilder(128);
String[] files = getPdbFile();
{
int refStructure = _refStructure[a];
AlignmentI alignment = _alignment[a];
- ColumnSelection hiddenCols = _hiddenCols[a];
+ HiddenColumns hiddenCols = _hiddenCols[a];
if (refStructure >= files.length)
{
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SeqCigar;
* @param height
* height of frame.
*/
- public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
+ public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns,
int width, int height)
{
this(al, hiddenColumns, width, height, null);
* @param sequenceSetId
* (may be null)
*/
- public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
+ public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns,
int width, int height, String sequenceSetId)
{
this(al, hiddenColumns, width, height, sequenceSetId, null);
* @param viewId
* (may be null)
*/
- public AlignFrame(AlignmentI al, ColumnSelection hiddenColumns,
+ public AlignFrame(AlignmentI al, HiddenColumns hiddenColumns,
int width, int height, String sequenceSetId, String viewId)
{
setSize(width, height);
}
public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
- ColumnSelection hiddenColumns, int width, int height)
+ HiddenColumns hiddenColumns, int width, int height)
{
setSize(width, height);
exportData.getAlignment(), // class cast exceptions will
// occur in the distant future
exportData.getOmitHidden(), exportData.getStartEndPostions(),
- f.getCacheSuffixDefault(format),
- viewport.getColumnSelection());
+ f.getCacheSuffixDefault(format), viewport.getAlignment()
+ .getHiddenColumns());
if (output == null)
{
cap.setText(new FormatAdapter(alignPanel, exportData.getSettings())
.formatSequences(format, exportData.getAlignment(),
exportData.getOmitHidden(),
- exportData.getStartEndPostions(),
- viewport.getColumnSelection()));
+ exportData
+ .getStartEndPostions(), viewport
+ .getAlignment().getHiddenColumns()));
Desktop.addInternalFrame(cap, MessageManager.formatMessage(
"label.alignment_output_command",
new Object[] { e.getActionCommand() }), 600, 500);
alignmentToExport = viewport.getAlignment();
}
alignmentStartEnd = alignmentToExport
- .getVisibleStartAndEndIndex(viewport.getColumnSelection()
- .getHiddenColumns());
+ .getVisibleStartAndEndIndex(viewport.getAlignment()
+ .getHiddenColumns()
+ .getListOfCols());
AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
omitHidden, alignmentStartEnd, settings);
return ed;
hiddenColumns = new ArrayList<int[]>();
int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
.getSelectionGroup().getEndRes();
- for (int[] region : viewport.getColumnSelection().getHiddenColumns())
+ for (int[] region : viewport.getAlignment().getHiddenColumns()
+ .getListOfCols())
{
if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
{
viewport.getAlignment(), 0, false);
SequenceI repseq = viewport.getAlignment().getSequenceAt(0);
viewport.getAlignment().setSeqrep(repseq);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
cs.hideInsertionsFor(repseq);
- viewport.setColumnSelection(cs);
+ viewport.getAlignment().setHiddenColumns(cs);
isAnnotation = true;
}
// else if (IdentifyFile.FeaturesFile.equals(format))
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
* @param hiddenColumns
* ColumnSelection
*/
- public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns)
+ public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
{
setAlignment(al);
if (hiddenColumns != null)
{
- colSel = hiddenColumns;
+ al.setHiddenColumns(hiddenColumns);
}
init();
}
* @param seqsetid
* (may be null)
*/
- public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
+ public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
String seqsetid)
{
this(al, hiddenColumns, seqsetid, null);
* @param viewid
* (may be null)
*/
- public AlignViewport(AlignmentI al, ColumnSelection hiddenColumns,
+ public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
String seqsetid, String viewid)
{
sequenceSetID = seqsetid;
setAlignment(al);
if (hiddenColumns != null)
{
- colSel = hiddenColumns;
+ al.setHiddenColumns(hiddenColumns);
}
init();
}
{
end = alignment.getWidth();
}
- viscontigs = colSel.getVisibleContigs(start, end);
+ viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end);
return viscontigs;
}
jalview.structure.StructureSelectionManager
.getStructureSelectionManager(Desktop.instance).sendSelection(
new SequenceGroup(getSelectionGroup()),
- new ColumnSelection(getColumnSelection()), this);
+ new ColumnSelection(getColumnSelection()),
+ new HiddenColumns(getAlignment().getHiddenColumns()),
+ this);
}
/**
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
}
if (av.hasHiddenColumns())
{
- start = av.getColumnSelection().findColumnPosition(start);
- end = av.getColumnSelection().findColumnPosition(end);
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ start = hidden.findColumnPosition(start);
+ end = hidden.findColumnPosition(end);
if (start == end)
{
- if (!av.getColumnSelection().isVisible(r[0]))
+ if (!hidden.isVisible(r[0]))
{
// don't scroll - position isn't visible
return false;
if (av.hasHiddenColumns())
{
// reset the width to exclude hidden columns
- width = av.getColumnSelection().findColumnPosition(width);
+ width = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(width);
}
hextent = getSeqPanel().seqCanvas.getWidth() / av.getCharWidth();
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
int canvasWidth = getSeqPanel().seqCanvas
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
int resWidth = getSeqPanel().seqCanvas.getWrappedCanvasWidth(pwidth
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth);
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth);
}
int height = ((av.getAlignment().getHeight() + 1) * av.getCharHeight())
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
int height = ((maxwidth / chunkWidth) + 1) * cHeight;
package jalview.gui;
import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.schemes.AnnotationColourGradient;
import jalview.util.MessageManager;
import jalview.viewmodel.annotationfilter.AnnotationFilterParameter;
private int actionOption = ACTION_OPTION_SELECT;
- private ColumnSelection oldColumnSelection;
+ private HiddenColumns oldHiddenColumns;
public AnnotationColumnChooser(AlignViewport av, final AlignmentPanel ap)
{
{
return;
}
- setOldColumnSelection(av.getColumnSelection());
+ setOldHiddenColumns(av.getAlignment().getHiddenColumns());
adjusting = true;
setAnnotations(new JComboBox<String>(getAnnotationItems(false)));
@Override
protected void reset()
{
- if (this.getOldColumnSelection() != null)
+ if (this.getOldHiddenColumns() != null)
{
av.getColumnSelection().clear();
if (av.getAnnotationColumnSelectionState() != null)
{
- ColumnSelection oldSelection = av
+ HiddenColumns oldHidden = av
.getAnnotationColumnSelectionState()
- .getOldColumnSelection();
- if (oldSelection != null && oldSelection.getHiddenColumns() != null
- && !oldSelection.getHiddenColumns().isEmpty())
+ .getOldHiddenColumns();
+ if (oldHidden != null && oldHidden.getListOfCols() != null
+ && !oldHidden.getListOfCols().isEmpty())
{
- for (Iterator<int[]> itr = oldSelection.getHiddenColumns()
+ for (Iterator<int[]> itr = oldHidden.getListOfCols()
.iterator(); itr.hasNext();)
{
int positions[] = itr.next();
av.hideColumns(positions[0], positions[1]);
}
}
- av.setColumnSelection(oldSelection);
+ av.getAlignment().setHiddenColumns(oldHidden);
}
ap.paintAlignment(true);
}
ap.paintAlignment(true);
}
- public ColumnSelection getOldColumnSelection()
+ public HiddenColumns getOldHiddenColumns()
{
- return oldColumnSelection;
+ return oldHiddenColumns;
}
- public void setOldColumnSelection(ColumnSelection currentColumnSelection)
+ public void setOldHiddenColumns(HiddenColumns currentHiddenColumns)
{
- if (currentColumnSelection != null)
+ if (currentHiddenColumns != null)
{
- this.oldColumnSelection = new ColumnSelection(currentColumnSelection);
+ this.oldHiddenColumns = new HiddenColumns(currentHiddenColumns);
}
}
Alignment ds = new Alignment(dseqs);
if (av.hasHiddenColumns())
{
- omitHidden = av.getColumnSelection().getVisibleSequenceStrings(0,
+ omitHidden = av.getAlignment().getHiddenColumns()
+ .getVisibleSequenceStrings(0,
sq.getLength(), seqs);
}
int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 };
- List<int[]> hiddenCols = av.getColumnSelection().getHiddenColumns();
+ List<int[]> hiddenCols = av.getAlignment().getHiddenColumns()
+ .getListOfCols();
if (hiddenCols != null)
{
alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
if (av.hasHiddenColumns())
{
hiddenColumns = new ArrayList<int[]>();
- for (int[] region : av.getColumnSelection().getHiddenColumns())
+ for (int[] region : av.getAlignment().getHiddenColumns()
+ .getListOfCols())
{
hiddenColumns.add(new int[] { region[0], region[1] });
}
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.renderer.AnnotationRenderer;
import jalview.renderer.AwtRenderPanelI;
{
for (int index : av.getColumnSelection().getSelected())
{
- if (av.getColumnSelection().isVisible(index))
+ if (av.getAlignment().getHiddenColumns().isVisible(index))
{
anot[index] = null;
}
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
}
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
StringBuilder collatedInput = new StringBuilder(64);
String last = "";
ColumnSelection viscols = av.getColumnSelection();
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
/*
* the selection list (read-only view) is in selection order, not
for (int index : selected)
{
// always check for current display state - just in case
- if (!viscols.isVisible(index))
+ if (!hidden.isVisible(index))
{
continue;
}
if (av.hasHiddenColumns())
{
- column = av.getColumnSelection().adjustForHiddenColumns(column);
+ column = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(column);
}
AlignmentAnnotation ann = aa[row];
import jalview.analysis.AlignSeq;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.RnaViewerModel;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
@Override
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
- SelectionSource source)
+ HiddenColumns hidden, SelectionSource source)
{
if (source != ap.av)
{
import jalview.api.FeaturesSourceI;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.io.AlignmentFileReaderI;
import jalview.io.AppletFormatAdapter;
AlignFrame af;
if (source instanceof ComplexAlignFile)
{
- ColumnSelection colSel = ((ComplexAlignFile) source)
- .getColumnSelection();
+ HiddenColumns hidden = ((ComplexAlignFile) source)
+ .getHiddenColumns();
SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
.getHiddenSequences();
boolean showSeqFeatures = ((ComplexAlignFile) source)
.getGlobalColourScheme();
FeaturesDisplayedI fd = ((ComplexAlignFile) source)
.getDisplayedFeatures();
- af = new AlignFrame(al, hiddenSeqs, colSel,
+ af = new AlignFrame(al, hiddenSeqs, hidden,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
af.getViewport().setShowSequenceFeatures(showSeqFeatures);
af.getViewport().setFeaturesDisplayed(fd);
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
int annotationHeight = 0;
if (av.hasHiddenColumns())
{
- if (av.getColumnSelection() == null
- || av.getColumnSelection().getHiddenColumns() == null)
+ jalview.datamodel.HiddenColumns hidden = av.getAlignment()
+ .getHiddenColumns();
+ if (hidden == null || hidden.getListOfCols() == null)
{
warn("REPORT BUG: avoided null columnselection bug (DMAM reported). Please contact Jim about this.");
}
else
{
- for (int c = 0; c < av.getColumnSelection().getHiddenColumns()
+ for (int c = 0; c < hidden.getListOfCols()
.size(); c++)
{
- int[] region = av.getColumnSelection().getHiddenColumns()
+ int[] region = hidden.getListOfCols()
.get(c);
HiddenColumns hc = new HiddenColumns();
hc.setStart(region[0]);
if (!av.getWrapAlignment())
{
od.updateViewportFromMouse(evt.getX(), evt.getY(), av
- .getAlignment().getHiddenSequences(), av
- .getColumnSelection(), av.getRanges());
+ .getAlignment().getHiddenSequences(), av.getAlignment()
+ .getHiddenColumns(), av.getRanges());
ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
}
}
if (!av.getWrapAlignment())
{
od.updateViewportFromMouse(evt.getX(), evt.getY(), av
- .getAlignment().getHiddenSequences(), av
- .getColumnSelection(), av.getRanges());
+ .getAlignment().getHiddenSequences(), av.getAlignment()
+ .getHiddenColumns(), av.getRanges());
ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
}
}
}
if (hiddenRow
- || (hasHiddenCols && !av.getColumnSelection()
+ || (hasHiddenCols && !av.getAlignment().getHiddenColumns()
.isVisible(lastcol)))
{
color = color.darker().darker();
public void setBoxPosition()
{
od.setBoxPosition(av.getAlignment()
- .getHiddenSequences(), av.getColumnSelection(), av.getRanges());
+.getHiddenSequences(), av
+ .getAlignment().getHiddenColumns(), av.getRanges());
repaint();
}
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SeqCigar;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GPCAPanel;
}
;
Object[] alAndColsel = pcaModel.getSeqtrings()
- .getAlignmentAndColumnSelection(gc);
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
if (true)
{
// make a new frame!
- AlignFrame af = new AlignFrame(al,
- (ColumnSelection) alAndColsel[1], AlignFrame.DEFAULT_WIDTH,
+ AlignFrame af = new AlignFrame(al, (HiddenColumns) alAndColsel[1],
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
// >>>This is a fix for the moment, until a better solution is
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
{
if (sequence != null)
{
- ColumnSelection cs = ap.av.getColumnSelection();
- if (cs == null)
+ /* ColumnSelection cs = ap.av.getColumnSelection();
+ if (cs == null)
+ {
+ cs = new ColumnSelection();
+ }
+ cs.hideInsertionsFor(sequence);
+ ap.av.setColumnSelection(cs);*/
+
+ HiddenColumns hidden = ap.av.getAlignment().getHiddenColumns();
+ if (hidden == null)
{
- cs = new ColumnSelection();
+ hidden = new HiddenColumns();
}
- cs.hideInsertionsFor(sequence);
- ap.av.setColumnSelection(cs);
+ hidden.hideInsertionsFor(sequence);
+ ap.av.getAlignment().setHiddenColumns(hidden);
}
refresh();
}
package jalview.gui;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.renderer.ScaleRenderer;
if (av.hasHiddenColumns())
{
- x = av.getColumnSelection().adjustForHiddenColumns(x);
+ x = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(x);
}
if (x >= av.getAlignment().getWidth())
});
pop.add(item);
- if (av.getColumnSelection().hasHiddenColumns())
+ if (av.getAlignment().getHiddenColumns().hasHiddenColumns())
{
item = new JMenuItem(MessageManager.getString("action.reveal_all"));
item.addActionListener(new ActionListener()
if (av.hasHiddenColumns())
{
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(res);
}
if (res >= av.getAlignment().getWidth())
{
mouseDragging = true;
ColumnSelection cs = av.getColumnSelection();
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
res = Math.max(0, res);
- res = cs.adjustForHiddenColumns(res);
+ res = hidden.adjustForHiddenColumns(res);
res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
- if (av.getColumnSelection().getHiddenColumns() != null)
+ if (av.getAlignment().getHiddenColumns().getListOfCols() != null)
{
- for (int[] region : av.getColumnSelection().getHiddenColumns())
+ for (int[] region : av.getAlignment().getHiddenColumns()
+ .getListOfCols())
{
if (res + 1 == region[0] || res - 1 == region[1])
{
// Fill the selected columns
ColumnSelection cs = av.getColumnSelection();
- int avCharWidth = av.getCharWidth(), avCharHeight = av.getCharHeight();
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ int avCharWidth = av.getCharWidth();
+ int avCharHeight = av.getCharHeight();
if (cs != null)
{
if (av.hasHiddenColumns())
{
- if (cs.isVisible(sel))
+ if (hidden.isVisible(sel))
{
- sel = cs.findColumnPosition(sel);
+ sel = hidden.findColumnPosition(sel);
}
else
{
// draw any hidden column markers
gg.setColor(Color.blue);
int res;
- if (av.getShowHiddenMarkers()
- && av.getColumnSelection().getHiddenColumns() != null)
+
+ if (av.getShowHiddenMarkers() && hidden.getListOfCols() != null)
{
- for (int i = 0; i < av.getColumnSelection().getHiddenColumns()
+ for (int i = 0; i < hidden.getListOfCols()
.size(); i++)
{
- res = av.getColumnSelection().findHiddenRegionPosition(i)
+ res = hidden.findHiddenRegionPosition(i)
- startx;
if (res < 0 || res > widthx)
package jalview.gui;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
if (av.hasHiddenColumns())
{
- startx = av.getColumnSelection().adjustForHiddenColumns(startx);
- endx = av.getColumnSelection().adjustForHiddenColumns(endx);
+ startx = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(startx);
+ endx = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(endx);
}
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
// WEST SCALE
if (av.hasHiddenColumns())
{
- endx = av.getColumnSelection().adjustForHiddenColumns(endx);
+ endx = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(endx);
}
SequenceI seq;
if (av.hasHiddenColumns())
{
- maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1;
+ maxwidth = av.getAlignment().getHiddenColumns()
+ .findColumnPosition(maxwidth) - 1;
}
while ((ypos <= canvasHeight) && (startRes < maxwidth))
{
g.setColor(Color.blue);
int res;
- for (int i = 0; i < av.getColumnSelection().getHiddenColumns()
- .size(); i++)
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ for (int i = 0; i < hidden.getListOfCols().size(); i++)
{
- res = av.getColumnSelection().findHiddenRegionPosition(i)
- - startRes;
+ res = hidden.findHiddenRegionPosition(i) - startRes;
if (res < 0 || res > endx - startRes)
{
}
else
{
- List<int[]> regions = av.getColumnSelection().getHiddenColumns();
+ List<int[]> regions = av.getAlignment().getHiddenColumns()
+ .getListOfCols();
int screenY = 0;
int blockStart = startRes;
import jalview.commands.EditCommand.Edit;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
if (av.hasHiddenColumns())
{
- res = av.getColumnSelection().adjustForHiddenColumns(res);
+ res = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(res);
}
return res;
{
seqCanvas.cursorX += dx;
seqCanvas.cursorY += dy;
+
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+
if (av.hasHiddenColumns()
- && !av.getColumnSelection().isVisible(seqCanvas.cursorX))
+ && !hidden.isVisible(seqCanvas.cursorX))
{
int original = seqCanvas.cursorX - dx;
int maxWidth = av.getAlignment().getWidth();
- while (!av.getColumnSelection().isVisible(seqCanvas.cursorX)
+ while (!hidden.isVisible(seqCanvas.cursorX)
&& seqCanvas.cursorX < maxWidth && seqCanvas.cursorX > 0)
{
seqCanvas.cursorX += dx;
}
if (seqCanvas.cursorX >= maxWidth
- || !av.getColumnSelection().isVisible(seqCanvas.cursorX))
+ || !hidden.isVisible(seqCanvas.cursorX))
{
seqCanvas.cursorX = original;
}
}
if (!av.getWrapAlignment())
{
- while (seqCanvas.cursorX < av.getColumnSelection()
- .adjustForHiddenColumns(av.getRanges().getStartRes()))
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
+ while (seqCanvas.cursorX < hidden.adjustForHiddenColumns(av
+ .getRanges().getStartRes()))
{
if (!ap.scrollRight(false))
{
break;
}
}
- while (seqCanvas.cursorX > av.getColumnSelection()
- .adjustForHiddenColumns(av.getRanges().getEndRes()))
+ while (seqCanvas.cursorX > hidden.adjustForHiddenColumns(av
+ .getRanges().getEndRes()))
{
if (!ap.scrollRight(true))
{
if (av.hasHiddenColumns())
{
fixedColumns = true;
- int y1 = av.getColumnSelection().getHiddenBoundaryLeft(startres);
- int y2 = av.getColumnSelection().getHiddenBoundaryRight(startres);
+ int y1 = av.getAlignment().getHiddenColumns()
+ .getHiddenBoundaryLeft(startres);
+ int y2 = av.getAlignment().getHiddenColumns()
+ .getHiddenBoundaryRight(startres);
if ((insertGap && startres > y1 && lastres < y1)
|| (!insertGap && startres < y2 && lastres > y2))
{
if (sg.getSize() == av.getAlignment().getHeight())
{
- if ((av.hasHiddenColumns() && startres < av
- .getColumnSelection().getHiddenBoundaryRight(startres)))
+ if ((av.hasHiddenColumns() && startres < av.getAlignment()
+ .getHiddenColumns().getHiddenBoundaryRight(startres)))
{
endEditing();
return;
*/
@Override
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
+ HiddenColumns hidden,
SelectionSource source)
{
// TODO: fix this hack - source of messages is align viewport, but SeqPanel
if (copycolsel
&& av.hasHiddenColumns()
- && (av.getColumnSelection() == null || av.getColumnSelection()
- .getHiddenColumns() == null))
+ && (av.getAlignment().getHiddenColumns() == null || av
+ .getAlignment().getHiddenColumns().getListOfCols() == null))
{
System.err.println("Bad things");
}
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.gui.StructureViewer.ViewerType;
try
{
AlignmentI[] als = new Alignment[_alignwith.size()];
- ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
+ HiddenColumns[] alc = new HiddenColumns[_alignwith.size()];
int[] alm = new int[_alignwith.size()];
int a = 0;
{
als[a] = ap.av.getAlignment();
alm[a] = -1;
- alc[a++] = ap.av.getColumnSelection();
+ alc[a++] = ap.av.getAlignment().getHiddenColumns();
}
reply = getBinding().superposeStructures(als, alm, alc);
if (reply != null)
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.BinaryNode;
-import jalview.datamodel.ColumnSelection;
import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.NodeTransformI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
{
}
;
- Object[] alAndColsel = tree.seqData.getAlignmentAndColumnSelection(gc);
+ Object[] alAndColsel = tree.seqData.getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
if (true)
{
// make a new frame!
- AlignFrame af = new AlignFrame(al,
- (ColumnSelection) alAndColsel[1], AlignFrame.DEFAULT_WIDTH,
+ AlignFrame af = new AlignFrame(al, (HiddenColumns) alAndColsel[1],
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
// >>>This is a fix for the moment, until a better solution is
import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.io.VamsasAppDatastore;
import java.util.Iterator;
import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
import uk.ac.vamsas.client.ClientHandle;
import uk.ac.vamsas.client.IClient;
{
// TODO: rationalise : can only clear a selection over a
// referred to object
- ssm.sendSelection(null, null, me);
+ ssm.sendSelection(null, null, null, me);
return;
}
Class type = null;
}
if (send)
{
- ssm.sendSelection(jselection, colsel, me);
+ ssm.sendSelection(jselection, colsel, null, me);
}
// discard message.
for (int c = 0; c < jvobjs.length; c++)
@Override
public void selection(SequenceGroup seqsel,
- ColumnSelection colsel, SelectionSource source)
+ ColumnSelection colsel, HiddenColumns hidden,
+ SelectionSource source)
{
if (vobj2jv == null)
{
}
else
{
- int[] intervals = colsel.getVisibleContigs(
+ // int[] intervals = colsel.getVisibleContigs(
+ // seqsel.getStartRes(), seqsel.getEndRes() + 1);
+ int[] intervals = hidden.getVisibleContigs(
seqsel.getStartRes(), seqsel.getEndRes() + 1);
for (int iv = 0; iv < intervals.length; iv += 2)
{
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.GraphLine;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
public HiddenSequences hidseqs;
- public ColumnSelection hiddencols;
+ public HiddenColumns hiddencols;
public Vector visibleGroups;
public Hashtable hiddenRepSeqs;
public ViewDef(String viewname, HiddenSequences hidseqs,
- ColumnSelection hiddencols, Hashtable hiddenRepSeqs)
+ HiddenColumns hiddencols, Hashtable hiddenRepSeqs)
{
this.viewname = viewname;
this.hidseqs = hidseqs;
*/
public String printAnnotations(AlignmentAnnotation[] annotations,
List<SequenceGroup> list, Hashtable properties,
- ColumnSelection cs, AlignmentI al, ViewDef view)
+ HiddenColumns cs,
+ AlignmentI al, ViewDef view)
{
if (view != null)
{
if (cs != null && cs.hasHiddenColumns())
{
text.append("VIEW_HIDECOLS\t");
- List<int[]> hc = cs.getHiddenColumns();
+ List<int[]> hc = cs.getListOfCols();
boolean comma = false;
for (int[] r : hc)
{
String file, DataSourceType protocol)
{
ColumnSelection colSel = viewport.getColumnSelection();
+ HiddenColumns hidden = viewport.getAlignment().getHiddenColumns();
if (colSel == null)
{
colSel = new ColumnSelection();
}
- boolean rslt = readAnnotationFile(viewport.getAlignment(), colSel,
+ if (hidden == null)
+ {
+ hidden = new HiddenColumns();
+ }
+ boolean rslt = readAnnotationFile(viewport.getAlignment(), hidden,
file, protocol);
- if (rslt && (colSel.hasSelectedColumns() || colSel.hasHiddenColumns()))
+ if (rslt && (colSel.hasSelectedColumns() || hidden.hasHiddenColumns()))
{
viewport.setColumnSelection(colSel);
+ viewport.getAlignment().setHiddenColumns(hidden);
}
return rslt;
return readAnnotationFile(al, null, file, sourceType);
}
- public boolean readAnnotationFile(AlignmentI al, ColumnSelection colSel,
+ public boolean readAnnotationFile(AlignmentI al, HiddenColumns hidden,
String file, DataSourceType sourceType)
{
BufferedReader in = null;
}
if (in != null)
{
- return parseAnnotationFrom(al, colSel, in);
+ return parseAnnotationFrom(al, hidden, in);
}
} catch (Exception ex)
private static String GRAPHLINE = "GRAPHLINE", COMBINE = "COMBINE";
- public boolean parseAnnotationFrom(AlignmentI al, ColumnSelection colSel,
+ public boolean parseAnnotationFrom(AlignmentI al, HiddenColumns hidden,
BufferedReader in) throws Exception
{
nlinesread = 0;
{
if (st.hasMoreTokens())
{
- if (colSel == null)
+ if (hidden == null)
{
- colSel = new ColumnSelection();
+ hidden = new HiddenColumns();
}
- parseHideCols(colSel, st.nextToken());
+ parseHideCols(hidden, st.nextToken());
}
modified = true;
continue;
}
if (sr != null)
{
- if (colSel == null)
+ if (hidden == null)
{
System.err
.println("Cannot process HIDE_INSERTIONS without an alignment view: Ignoring line: "
else
{
// consider deferring this till after the file has been parsed ?
- colSel.hideInsertionsFor(sr);
+ hidden.hideInsertionsFor(sr);
}
}
modified = true;
return modified;
}
- private void parseHideCols(ColumnSelection colSel, String nextToken)
+ private void parseHideCols(HiddenColumns hidden, String nextToken)
{
StringTokenizer inval = new StringTokenizer(nextToken, ",");
while (inval.hasMoreTokens())
from = to = Integer.parseInt(range);
if (from >= 0)
{
- colSel.hideColumns(from, to);
+ hidden.hideColumns(from, to);
}
}
else
}
if (from > 0 && to >= from)
{
- colSel.hideColumns(from, to);
+ hidden.hideColumns(from, to);
}
}
}
return printAnnotations(viewport.isShowAnnotation() ? viewport
.getAlignment().getAlignmentAnnotation() : null, viewport
.getAlignment().getGroups(), viewport.getAlignment()
- .getProperties(), viewport.getColumnSelection(),
+ .getProperties(), viewport.getAlignment().getHiddenColumns(),
viewport.getAlignment(), null);
}
import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
if (source instanceof ComplexAlignFile)
{
- ColumnSelection colSel = ((ComplexAlignFile) source)
- .getColumnSelection();
+ HiddenColumns colSel = ((ComplexAlignFile) source)
+ .getHiddenColumns();
SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
.getHiddenSequences();
String colourSchemeName = ((ComplexAlignFile) source)
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
}
public String formatSequences(FileFormatI format, AlignmentI alignment,
- String[] omitHidden, int[] exportRange, ColumnSelection colSel)
+ String[] omitHidden, int[] exportRange, HiddenColumns hidden)
{
return formatSequences(format, alignment, omitHidden, exportRange,
- getCacheSuffixDefault(format), colSel, null);
+ getCacheSuffixDefault(format), hidden, null);
}
/**
- * hack function to replace seuqences with visible sequence strings before
+ * hack function to replace sequences with visible sequence strings before
* generating a string of the alignment in the given format.
*
* @param format
*/
public String formatSequences(FileFormatI format, AlignmentI alignment,
String[] omitHidden, int[] exportRange, boolean suffix,
- ColumnSelection colSel)
+ HiddenColumns hidden)
{
return formatSequences(format, alignment, omitHidden, exportRange,
- suffix, colSel, null);
+ suffix, hidden, null);
}
public String formatSequences(FileFormatI format, AlignmentI alignment,
String[] omitHidden, int[] exportRange, boolean suffix,
- ColumnSelection colSel, SequenceGroup selgp)
+ HiddenColumns hidden, SequenceGroup selgp)
{
if (omitHidden != null)
{
AlignmentAnnotation na = new AlignmentAnnotation(ala[i]);
if (selgp != null)
{
- colSel.makeVisibleAnnotation(selgp.getStartRes(),
+ hidden.makeVisibleAnnotation(selgp.getStartRes(),
selgp.getEndRes(), na);
}
else
{
- colSel.makeVisibleAnnotation(na);
+ hidden.makeVisibleAnnotation(na);
}
alv.addAnnotation(na);
}
String bioJSON = new FormatAdapter(ap, exportData.getSettings())
.formatSequences(FileFormat.Json, exportData.getAlignment(),
exportData.getOmitHidden(), exportData
- .getStartEndPostions(), ap.getAlignViewport()
- .getColumnSelection());
+.getStartEndPostions(), ap.getAlignViewport()
+ .getAlignment().getHiddenColumns());
return bioJSON;
}
import jalview.api.ComplexAlignFile;
import jalview.api.FeatureSettingsModelI;
import jalview.api.FeaturesDisplayedI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import java.io.IOException;
private boolean showSeqFeatures;
- private ColumnSelection columnSelection;
+ private HiddenColumns hiddenColumns;
private SequenceI[] hiddenSequences;
this.showSeqFeatures = jsonFile.isShowSeqFeatures();
this.globalColourScheme = jsonFile.getGlobalColourScheme();
this.hiddenSequences = jsonFile.getHiddenSequences();
- this.columnSelection = jsonFile.getColumnSelection();
+ this.hiddenColumns = jsonFile.getHiddenColumns();
this.displayedFeatures = jsonFile.getDisplayedFeatures();
} catch (Exception e)
{
}
@Override
- public ColumnSelection getColumnSelection()
+ public HiddenColumns getHiddenColumns()
{
- return columnSelection;
+ return hiddenColumns;
}
- public void setColumnSelection(ColumnSelection columnSelection)
+ public void setHiddenColumns(HiddenColumns hidden)
{
- this.columnSelection = columnSelection;
+ this.hiddenColumns = hidden;
}
@Override
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
private FeatureRenderer fr;
- private List<int[]> hiddenColumns;
+ private List<int[]> hiddenColumnsList;
- private ColumnSelection columnSelection;
+ private HiddenColumns hiddenColumns;
private List<String> hiddenSeqRefs;
// hidden column business
if (getViewport().hasHiddenColumns())
{
- List<int[]> hiddenCols = getViewport().getColumnSelection()
- .getHiddenColumns();
+ List<int[]> hiddenCols = getViewport().getAlignment()
+ .getHiddenColumns()
+ .getListOfCols();
StringBuilder hiddenColsBuilder = new StringBuilder();
for (int[] range : hiddenCols)
{
String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
if (hiddenCols != null && !hiddenCols.isEmpty())
{
- columnSelection = new ColumnSelection();
+ HiddenColumns hidden = new HiddenColumns();
String[] rangeStrings = hiddenCols.split(";");
for (String rangeString : rangeStrings)
{
String[] range = rangeString.split("-");
- columnSelection.hideColumns(Integer.valueOf(range[0]),
+ hidden.hideColumns(Integer.valueOf(range[0]),
Integer.valueOf(range[1]));
}
}
return annotations;
}
- public List<int[]> getHiddenColumns()
- {
- return hiddenColumns;
- }
-
@Override
- public ColumnSelection getColumnSelection()
+ public HiddenColumns getHiddenColumns()
{
- return columnSelection;
+ return hiddenColumns;
}
- public void setColumnSelection(ColumnSelection columnSelection)
+ public void setHiddenColumns(HiddenColumns hidden)
{
- this.columnSelection = columnSelection;
+ this.hiddenColumns = hidden;
}
@Override
import jalview.appletgui.AlignFrame;
import jalview.bin.JalviewLite;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.structure.SelectionSource;
@Override
public void selection(SequenceGroup seqsel, ColumnSelection colsel,
- SelectionSource source)
+ HiddenColumns hidden, SelectionSource source)
{
// System.err.println("Testing selection event relay to jsfunction:"+_listener);
try
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.ProfilesI;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.NucleotideColourScheme;
ResidueShaderI profcolour = null;
private ColumnSelection columnSelection;
+
+ private HiddenColumns hiddenColumns;
private ProfilesI hconsensus;
profcolour = new ResidueShader(col);
}
columnSelection = av.getColumnSelection();
+ hiddenColumns = av.getAlignment().getHiddenColumns();
hconsensus = av.getSequenceConsensusHash();
complementConsensus = av.getComplementConsensusHash();
hStrucConsensus = av.getRnaStructureConsensusHash();
{
if (hasHiddenColumns)
{
- column = columnSelection.adjustForHiddenColumns(startRes + x);
+ column = hiddenColumns.adjustForHiddenColumns(startRes + x);
if (column > row_annotations.length - 1)
{
break;
column = sRes + x;
if (hasHiddenColumns)
{
- column = columnSelection.adjustForHiddenColumns(column);
+ column = hiddenColumns.adjustForHiddenColumns(column);
}
if (column > aaMax)
column = sRes + x;
if (hasHiddenColumns)
{
- column = columnSelection.adjustForHiddenColumns(column);
+ column = hiddenColumns.adjustForHiddenColumns(column);
}
if (column > aaMax)
{
// find bounds and set origin appopriately
// locate first visible position for this sequence
- int[] refbounds = av.getColumnSelection()
+ int[] refbounds = av.getAlignment().getHiddenColumns()
.locateVisibleBoundsOfSequence(refSeq);
refSp = refbounds[0];
{
if (refSeq == null)
{
- iadj = av.getColumnSelection().adjustForHiddenColumns(i - 1) + 1;
+ iadj = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(i - 1) + 1;
string = String.valueOf(iadj);
}
else
{
- iadj = av.getColumnSelection().adjustForHiddenColumns(i - 1);
+ iadj = av.getAlignment().getHiddenColumns()
+ .adjustForHiddenColumns(i - 1);
refN = refSeq.findPosition(iadj);
// TODO show bounds if position is a gap
// - ie L--R -> "1L|2R" for
* - source of the selection event
*/
public void selection(jalview.datamodel.SequenceGroup seqsel,
- jalview.datamodel.ColumnSelection colsel, SelectionSource source);
+ jalview.datamodel.ColumnSelection colsel,
+ jalview.datamodel.HiddenColumns hidden,
+ SelectionSource source);
}
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
public synchronized void sendSelection(
jalview.datamodel.SequenceGroup selection,
- jalview.datamodel.ColumnSelection colsel, SelectionSource source)
+ jalview.datamodel.ColumnSelection colsel, HiddenColumns hidden,
+ SelectionSource source)
{
for (SelectionListener slis : sel_listeners)
{
if (slis != source)
{
- slis.selection(selection, colsel, source);
+ slis.selection(selection, colsel, hidden, source);
}
}
}
import jalview.api.StructureSelectionManagerProvider;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
* an array of corresponding hidden columns for each alignment
* @return
*/
- public abstract String superposeStructures(AlignmentI[] alignments, int[] structureIndices,
- ColumnSelection[] hiddenCols);
+ public abstract String superposeStructures(AlignmentI[] alignments,
+ int[] structureIndices, HiddenColumns[] hiddenCols);
public abstract void setBackgroundColour(Color col);
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SearchResultsI;
toSequences, fromGapChar);
}
- for (int[] hidden : colsel.getHiddenColumns())
+ for (int[] hidden : colsel.getListOfCols())
{
mapHiddenColumns(hidden, codonFrames, mappedColumns, fromSequences,
toSequences, fromGapChar);
* @param fromGapChar
*/
protected static void mapHiddenColumns(int[] hidden,
- List<AlignedCodonFrame> mappings, ColumnSelection mappedColumns,
+ List<AlignedCodonFrame> mappings, HiddenColumns mappedColumns,
List<SequenceI> fromSequences, List<SequenceI> toSequences,
char fromGapChar)
{
*/
package jalview.viewmodel;
-import java.awt.Color;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.Conservation;
import jalview.api.AlignCalcManagerI;
import jalview.datamodel.Annotation;
import jalview.datamodel.CigarArray;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.ProfilesI;
import jalview.datamodel.SearchResultsI;
import jalview.workers.ConsensusThread;
import jalview.workers.StrucConsensusThread;
+import java.awt.Color;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
/**
* base class holding visualization and analysis attributes and common logic for
* an active alignment view displayed in the GUI
}
}
- public void setHiddenColumns(ColumnSelection colsel)
+ public void setHiddenColumns(HiddenColumns hidden)
{
- this.colSel = colsel;
+ this.alignment.setHiddenColumns(hidden);
+ // this.colSel = colsel;
}
@Override
@Override
public boolean hasHiddenColumns()
{
- return colSel != null && colSel.hasHiddenColumns();
+ return colSel != null
+ && alignment.getHiddenColumns().hasHiddenColumns();
}
public void updateHiddenColumns()
return;
}
- colSel.hideSelectedColumns();
+ colSel.hideSelectedColumns(alignment);
setSelectionGroup(null);
isColSelChanged(true);
}
{
if (start == end)
{
- colSel.hideColumns(start);
+ colSel.hideSelectedColumns(start, alignment);
}
else
{
- colSel.hideColumns(start, end);
+ alignment.getHiddenColumns().hideColumns(start, end);
}
isColSelChanged(true);
}
public void showColumn(int col)
{
- colSel.revealHiddenColumns(col);
+ alignment.getHiddenColumns().revealHiddenColumns(col, colSel);
isColSelChanged(true);
}
public void showAllHiddenColumns()
{
- colSel.revealAllHiddenColumns();
+ alignment.getHiddenColumns().revealAllHiddenColumns(colSel);
isColSelChanged(true);
}
@Override
public void invertColumnSelection()
{
- colSel.invertColumnSelection(0, alignment.getWidth());
+ colSel.invertColumnSelection(0, alignment.getWidth(), alignment);
}
@Override
@Override
public CigarArray getViewAsCigars(boolean selectedRegionOnly)
{
- return new CigarArray(alignment, colSel,
+ return new CigarArray(alignment, alignment.getHiddenColumns(),
(selectedRegionOnly ? selectionGroup : null));
}
public jalview.datamodel.AlignmentView getAlignmentView(
boolean selectedOnly, boolean markGroups)
{
- return new AlignmentView(alignment, colSel, selectionGroup,
- colSel != null && colSel.hasHiddenColumns(), selectedOnly,
+ return new AlignmentView(alignment, alignment.getHiddenColumns(),
+ selectionGroup, alignment.getHiddenColumns() != null
+ && alignment.getHiddenColumns().hasHiddenColumns(),
+ selectedOnly,
markGroups);
}
}
selection = new String[iSize];
- if (colSel != null && colSel.hasHiddenColumns())
+ if (alignment.getHiddenColumns() != null
+ && alignment.getHiddenColumns().hasHiddenColumns())
{
- selection = colSel.getVisibleSequenceStrings(start, end, seqs);
+ selection = alignment.getHiddenColumns().getVisibleSequenceStrings(
+ start, end, seqs);
}
else
{
do
{
- if (colSel != null && colSel.hasHiddenColumns())
+ HiddenColumns hidden = alignment.getHiddenColumns();
+ if (hidden != null && hidden.hasHiddenColumns())
{
if (start == 0)
{
- start = colSel.adjustForHiddenColumns(start);
+ start = hidden.adjustForHiddenColumns(start);
}
- end = colSel.getHiddenBoundaryRight(start);
+ end = hidden.getHiddenBoundaryRight(start);
if (start == end)
{
end = max;
regions.add(new int[] { start, end });
- if (colSel != null && colSel.hasHiddenColumns())
+ if (hidden != null && hidden.hasHiddenColumns())
{
- start = colSel.adjustForHiddenColumns(end);
- start = colSel.getHiddenBoundaryLeft(start) + 1;
+ start = hidden.adjustForHiddenColumns(end);
+ start = hidden.getHiddenBoundaryLeft(start) + 1;
}
} while (end < max);
AlignmentAnnotation clone = new AlignmentAnnotation(annot);
if (selectedOnly && selectionGroup != null)
{
- colSel.makeVisibleAnnotation(selectionGroup.getStartRes(),
+ alignment.getHiddenColumns().makeVisibleAnnotation(
+ selectionGroup.getStartRes(),
selectionGroup.getEndRes(), clone);
}
else
{
- colSel.makeVisibleAnnotation(clone);
+ alignment.getHiddenColumns().makeVisibleAnnotation(clone);
}
ala.add(clone);
}
*/
package jalview.viewmodel;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
import java.awt.Graphics;
* viewport position properties
*/
public void updateViewportFromMouse(int mousex, int mousey,
- HiddenSequences hiddenSeqs, ColumnSelection hiddenCols,
+ HiddenSequences hiddenSeqs, HiddenColumns hiddenCols,
ViewportRanges ranges)
{
int x = mousex;
* viewport position properties
*/
public void setBoxPosition(HiddenSequences hiddenSeqs,
- ColumnSelection hiddenCols, ViewportRanges ranges)
+ HiddenColumns hiddenCols, ViewportRanges ranges)
{
int alwidth = ranges.getAbsoluteAlignmentWidth();
int alheight = ranges.getAbsoluteAlignmentHeight();
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
if (predMap != null)
{
Object[] alandcolsel = input
- .getAlignmentAndColumnSelection(getGapChar());
+ .getAlignmentAndHiddenColumns(getGapChar());
sqs = (SequenceI[]) alandcolsel[0];
al = new Alignment(sqs);
alcsel = (ColumnSelection) alandcolsel[1];
{
char gc = getGapChar();
SequenceI[] sqs = (SequenceI[]) input
- .getAlignmentAndColumnSelection(gc)[0];
+ .getAlignmentAndHiddenColumns(gc)[0];
if (this.msaIndex >= sqs.length)
{
throw new Error(
if (res[1] != null)
{
af = new AlignFrame((Alignment) res[0],
- (ColumnSelection) res[1], AlignFrame.DEFAULT_WIDTH,
+ (HiddenColumns) res[1], AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
else
*/
af = new AlignFrame((Alignment) res[0],
- (ColumnSelection) res[1], AlignFrame.DEFAULT_WIDTH,
+ (HiddenColumns) res[1],
+ AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
Desktop.addInternalFrame(af, altitle, AlignFrame.DEFAULT_WIDTH,
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
orders[j] = null;
}
SequenceI[] alignment = (SequenceI[]) newview[0];
- ColumnSelection columnselection = (ColumnSelection) newview[1];
+ HiddenColumns hidden = (HiddenColumns) newview[1];
Alignment al = new Alignment(alignment);
// TODO: add 'provenance' property to alignment from the method notes
// accompanying each subjob
if (newFrame)
{
- AlignFrame af = new AlignFrame(al, columnselection,
+ AlignFrame af = new AlignFrame(al, hidden,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
// initialise with same renderer settings as in parent alignframe.
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
orders[j] = null;
}
SequenceI[] alignment = (SequenceI[]) newview[0];
- ColumnSelection columnselection = (ColumnSelection) newview[1];
+ HiddenColumns hidden = (HiddenColumns) newview[1];
Alignment al = new Alignment(alignment);
// TODO: add 'provenance' property to alignment from the method notes
if (lastProgram != null)
if (newFrame)
{
- displayInNewFrame(al, alorders, columnselection);
+ displayInNewFrame(al, alorders, hidden);
}
else
* @param columnselection
*/
protected void displayInNewFrame(AlignmentI al,
- List<AlignmentOrder> alorders, ColumnSelection columnselection)
+ List<AlignmentOrder> alorders, HiddenColumns hidden)
{
- AlignFrame af = new AlignFrame(al, columnselection,
+ AlignFrame af = new AlignFrame(al, hidden,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
// initialise with same renderer settings as in parent alignframe.
{
// intersect groups with selected region
_input = new AlignmentView(av.getAlignment(),
- av.getColumnSelection(), av.getSelectionGroup(),
+ av.getAlignment()
+ .getHiddenColumns(), av.getSelectionGroup(),
av.hasHiddenColumns(), true, true);
viewTitle = MessageManager.formatMessage(
"label.select_visible_region_of",
{
// use selected region to partition alignment
_input = new AlignmentView(av.getAlignment(),
- av.getColumnSelection(), av.getSelectionGroup(),
+ av.getAlignment()
+ .getHiddenColumns(), av.getSelectionGroup(),
av.hasHiddenColumns(), false, true);
}
viewTitle = MessageManager.formatMessage(
{
// just take selected region intersection
_input = new AlignmentView(av.getAlignment(),
- av.getColumnSelection(), av.getSelectionGroup(),
+ av.getAlignment()
+ .getHiddenColumns(), av.getSelectionGroup(),
av.hasHiddenColumns(), true, true);
viewTitle = MessageManager.formatMessage(
"label.select_visible_region_of",
{
// standard alignment view without selection present
_input = new AlignmentView(av.getAlignment(),
- av.getColumnSelection(), null, av.hasHiddenColumns(), false,
+ av.getAlignment()
+ .getHiddenColumns(), null, av.hasHiddenColumns(), false,
true);
viewTitle = ""
+ (av.hasHiddenColumns() ? (new StringBuffer(" ")
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
private String getStage(Stage stg)
{
if (stg == Stage.SUBMIT)
+ {
return "submitting ";
+ }
if (stg == Stage.POLL)
+ {
return "checking status of ";
+ }
return (" being confused about ");
}
// total number of distinct alignment sets generated by job set.
int numAlSets = 0, als = 0;
List<AlignmentI> destAls = new ArrayList<AlignmentI>();
- List<jalview.datamodel.ColumnSelection> destColsel = new ArrayList<jalview.datamodel.ColumnSelection>();
+ List<jalview.datamodel.HiddenColumns> destColsel = new ArrayList<jalview.datamodel.HiddenColumns>();
List<List<NewickFile>> trees = new ArrayList<List<NewickFile>>();
do
RestJob rj = (RestJob) jobs[nrj];
int contigs[] = input.getVisibleContigs();
AlignmentI destAl = null;
- jalview.datamodel.ColumnSelection destCs = null;
+ jalview.datamodel.HiddenColumns destHCs = null;
// Resolve destAl for this data.
if (als == 0 && rj.isInputContextModified())
{
if (!restClient.isAlignmentModified() && merge)
{
destAl = restClient.av.getAlignment();
- destCs = restClient.av.getColumnSelection();
+ destHCs = restClient.av.getAlignment().getHiddenColumns();
resultDest
.add(restClient.isShowResultsInNewView() ? AddDataTo.newView
: AddDataTo.currentView);
newAlignment = true;
// recreate the input alignment data
Object[] idat = input
- .getAlignmentAndColumnSelection(gapCharacter);
+ .getAlignmentAndHiddenColumns(gapCharacter);
destAl = new Alignment((SequenceI[]) idat[0]);
- destCs = (ColumnSelection) idat[1];
+ destHCs = (HiddenColumns) idat[1];
resultDest.add(AddDataTo.newAlignment);
// but do not add to the alignment panel list - since we need to
// create a whole new alignFrame set.
}
destAls.add(destAl);
- destColsel.add(destCs);
+ destColsel.add(destHCs);
}
}
else
// recover reference to last alignment created for this rest frame
// ready for extension
destAl = destAls.get(als);
- destCs = destColsel.get(als);
+ destHCs = destColsel.get(als);
}
else
{
newview = input.getUpdatedView(rseqs, orders, gapCharacter);
}
destAl = new Alignment((SequenceI[]) newview[0]);
- destCs = (ColumnSelection) newview[1];
+ destHCs = (HiddenColumns) newview[1];
newAlignment = true;
// TODO create alignment from result data with propagated
// references.
destAls.add(destAl);
- destColsel.add(destCs);
+ destColsel.add(destHCs);
resultDest.add(AddDataTo.newAlignment);
throw new Error(
MessageManager
for (AddDataTo action : resultDest)
{
AlignmentI destal;
- ColumnSelection destcs;
+ HiddenColumns destcs;
String alTitle = MessageManager.formatMessage(
"label.webservice_job_title_on", new String[] {
restClient.service.details.Action,
import jalview.datamodel.AlignedCodon;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
AlignmentI alf = new FormatAdapter().readFile(
JAL_1312_example_align_fasta, DataSourceType.PASTE,
FileFormat.Fasta);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(alf, cs);
Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
AlignmentI translated = dna.translateCdna();
int vwidth = 15;
for (int ipos = 0; ipos + vwidth < alf.getWidth(); ipos += vwidth)
{
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
if (ipos > 0)
{
cs.hideColumns(0, ipos - 1);
{
AlignmentI alf = new FormatAdapter().readFile(fasta,
DataSourceType.PASTE, FileFormat.Fasta);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(alf, cs);
Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
AlignmentI translated = dna.translateCdna();
{
AlignmentI alf = new FormatAdapter().readFile(fasta,
DataSourceType.PASTE, FileFormat.Fasta);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
cs.hideColumns(6, 14); // hide codons 3/4/5
cs.hideColumns(24, 35); // hide codons 9-12
cs.hideColumns(177, 191); // hide codons 60-64
*/
AlignmentI cdna = new AlignmentGenerator(true)
.generate(12, 8, 97, 5, 5);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(cdna, cs);
Dna dna = new Dna(av, new int[] { 0, cdna.getWidth() - 1 });
AlignmentI translated = dna.translateCdna();
assertEquals(seqDs, al.getSequenceAt(0).getDatasetSequence()
.getSequenceAsString());
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
AlignViewportI av = new AlignViewport(al, cs);
Dna testee = new Dna(av, new int[] { 0, al.getWidth() - 1 });
AlignmentI reversed = testee.reverseCdna(false);
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
+import jalview.analysis.AlignmentGenerator;
import jalview.gui.JvOptionPane;
import java.util.Arrays;
}
/**
- * Test the method that finds the visible column position of an alignment
- * column, allowing for hidden columns.
- */
- @Test(groups = { "Functional" })
- public void testFindColumnPosition()
- {
- ColumnSelection cs = new ColumnSelection();
- assertEquals(5, cs.findColumnPosition(5));
-
- // hiding column 6 makes no difference
- cs.hideColumns(6, 6);
- assertEquals(5, cs.findColumnPosition(5));
-
- // hiding column 4 moves column 5 to column 4
- cs.hideColumns(4, 4);
- assertEquals(4, cs.findColumnPosition(5));
-
- // hiding column 4 moves column 4 to position 3
- assertEquals(3, cs.findColumnPosition(4));
-
- // hiding columns 1 and 2 moves column 5 to column 2
- cs.hideColumns(1, 2);
- assertEquals(2, cs.findColumnPosition(5));
-
- // check with > 1 hidden column regions
- // where some columns are in the hidden regions
- ColumnSelection cs2 = new ColumnSelection();
- cs2.hideColumns(5, 10);
- cs2.hideColumns(20, 27);
- cs2.hideColumns(40, 44);
-
- // hiding columns 5-10 and 20-27 moves column 8 to column 4
- assertEquals(4, cs2.findColumnPosition(8));
-
- // and moves column 24 to 13
- assertEquals(13, cs2.findColumnPosition(24));
-
- // and moves column 28 to 14
- assertEquals(14, cs2.findColumnPosition(28));
-
- // and moves column 40 to 25
- assertEquals(25, cs2.findColumnPosition(40));
-
- // check when hidden columns start at 0 that the visible column
- // is returned as 0
- ColumnSelection cs3 = new ColumnSelection();
- cs3.hideColumns(0, 4);
- assertEquals(0, cs3.findColumnPosition(2));
-
- }
-
- /**
- * Test the method that finds the visible column position a given distance
- * before another column
- */
- @Test(groups = { "Functional" })
- public void testFindColumnNToLeft()
- {
- ColumnSelection cs = new ColumnSelection();
-
- // test that without hidden columns, findColumnNToLeft returns
- // position n to left of provided position
- int pos = cs.subtractVisibleColumns(3, 10);
- assertEquals(7, pos);
-
- // 0 returns same position
- pos = cs.subtractVisibleColumns(0, 10);
- assertEquals(10, pos);
-
- // overflow to left returns negative number
- pos = cs.subtractVisibleColumns(3, 0);
- assertEquals(-3, pos);
-
- // test that with hidden columns to left of result column
- // behaviour is the same as above
- cs.hideColumns(1, 3);
-
- // position n to left of provided position
- pos = cs.subtractVisibleColumns(3, 10);
- assertEquals(7, pos);
-
- // 0 returns same position
- pos = cs.subtractVisibleColumns(0, 10);
- assertEquals(10, pos);
-
- // test with one set of hidden columns between start and required position
- cs.hideColumns(12, 15);
- pos = cs.subtractVisibleColumns(8, 17);
- assertEquals(5, pos);
-
- // test with two sets of hidden columns between start and required position
- cs.hideColumns(20, 21);
- pos = cs.subtractVisibleColumns(8, 23);
- assertEquals(9, pos);
-
- // repeat last 2 tests with no hidden columns to left of required position
- cs.revealAllHiddenColumns();
-
- // test with one set of hidden columns between start and required position
- cs.hideColumns(12, 15);
- pos = cs.subtractVisibleColumns(8, 17);
- assertEquals(5, pos);
-
- // test with two sets of hidden columns between start and required position
- cs.hideColumns(20, 21);
- pos = cs.subtractVisibleColumns(8, 23);
- assertEquals(9, pos);
-
- }
-
- /**
- * Test the code used to locate the reference sequence ruler origin
- */
- @Test(groups = { "Functional" })
- public void testLocateVisibleBoundsofSequence()
- {
- ColumnSelection cs = new ColumnSelection();
- SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E---");
- assertEquals(2, seq.findIndex(seq.getStart()));
-
- // no hidden columns
- assertEquals(
- Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
- seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
-
- // hidden column on gap after end of sequence - should not affect bounds
- cs.hideColumns(13);
- assertEquals(
- Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
- seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
-
- cs.revealAllHiddenColumns();
- // hidden column on gap before beginning of sequence - should vis bounds by
- // one
- cs.hideColumns(0);
- assertEquals(
- Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 2,
- seq.findIndex(seq.getEnd()) - 2, seq.getStart(),
- seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
-
- cs.revealAllHiddenColumns();
- // hide columns around most of sequence - leave one residue remaining
- cs.hideColumns(1, 3);
- cs.hideColumns(6, 11);
- assertEquals("-D",
- cs.getVisibleSequenceStrings(0, 5, new SequenceI[] { seq })[0]);
- assertEquals(
- Arrays.toString(new int[] { 1, 1, 3, 3,
- seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
- cs.revealAllHiddenColumns();
-
- // hide whole sequence - should just get location of hidden region
- // containing sequence
- cs.hideColumns(1, 11);
- assertEquals(
- Arrays.toString(new int[] { 0, 1, 0, 0,
- seq.findIndex(seq.getStart()) - 1,
- seq.findIndex(seq.getEnd()) - 1 }),
- Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
-
- }
-
- @Test(groups = { "Functional" })
- public void testLocateVisibleBoundsPathologicals()
- {
- // test some pathological cases we missed
- AlignmentI al = new Alignment(new SequenceI[] { new Sequence(
- "refseqGaptest", "KTDVTI----------NFI-----G----L") });
- ColumnSelection cs = new ColumnSelection();
- cs.hideInsertionsFor(al.getSequenceAt(0));
- assertEquals(
- "G",
- ""
- + al.getSequenceAt(0).getCharAt(
- cs.adjustForHiddenColumns(9)));
-
- }
-
- @Test(groups = { "Functional" })
- public void testHideColumns()
- {
- ColumnSelection cs = new ColumnSelection();
- cs.hideColumns(5);
- List<int[]> hidden = cs.getHiddenColumns();
- assertEquals(1, hidden.size());
- assertEquals("[5, 5]", Arrays.toString(hidden.get(0)));
-
- cs.hideColumns(3);
- assertEquals(2, hidden.size());
- // two hidden ranges, in order:
- assertSame(hidden, cs.getHiddenColumns());
- assertEquals("[3, 3]", Arrays.toString(hidden.get(0)));
- assertEquals("[5, 5]", Arrays.toString(hidden.get(1)));
-
- // hiding column 4 expands [3, 3] to [3, 4]
- // and merges to [5, 5] to make [3, 5]
- cs.hideColumns(4);
- hidden = cs.getHiddenColumns();
- assertEquals(1, hidden.size());
- assertEquals("[3, 5]", Arrays.toString(hidden.get(0)));
-
- // clear hidden columns (note they are added to selected)
- cs.revealAllHiddenColumns();
- // it is now actually null but getter returns an empty list
- assertTrue(cs.getHiddenColumns().isEmpty());
-
- cs.hideColumns(3, 6);
- hidden = cs.getHiddenColumns();
- int[] firstHiddenRange = hidden.get(0);
- assertEquals("[3, 6]", Arrays.toString(firstHiddenRange));
-
- // adding a subrange of already hidden should do nothing
- cs.hideColumns(4, 5);
- assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenColumns().get(0));
- cs.hideColumns(3, 5);
- assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenColumns().get(0));
- cs.hideColumns(4, 6);
- assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenColumns().get(0));
- cs.hideColumns(3, 6);
- assertEquals(1, hidden.size());
- assertSame(firstHiddenRange, cs.getHiddenColumns().get(0));
-
- cs.revealAllHiddenColumns();
- cs.hideColumns(2, 4);
- hidden = cs.getHiddenColumns();
- assertEquals(1, hidden.size());
- assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
-
- // extend contiguous with 2 positions overlap
- cs.hideColumns(3, 5);
- assertEquals(1, hidden.size());
- assertEquals("[2, 5]", Arrays.toString(hidden.get(0)));
-
- // extend contiguous with 1 position overlap
- cs.hideColumns(5, 6);
- assertEquals(1, hidden.size());
- assertEquals("[2, 6]", Arrays.toString(hidden.get(0)));
-
- // extend contiguous with overlap both ends:
- cs.hideColumns(1, 7);
- assertEquals(1, hidden.size());
- assertEquals("[1, 7]", Arrays.toString(hidden.get(0)));
- }
-
- /**
* Test the method that hides a specified column including any adjacent
* selected columns. This is a convenience method for the case where multiple
* column regions are selected and then hidden using menu option View | Hide |
@Test(groups = { "Functional" })
public void testHideColumns_withSelection()
{
+ // create random alignment
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+
ColumnSelection cs = new ColumnSelection();
// select columns 4-6
cs.addElement(4);
cs.addElement(5);
cs.addElement(6);
// hide column 5 (and adjacent):
- cs.hideColumns(5);
+ cs.hideSelectedColumns(5, al);
// 4,5,6 now hidden:
- List<int[]> hidden = cs.getHiddenColumns();
+ List<int[]> hidden = al.getHiddenColumns().getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
// none now selected:
assertTrue(cs.getSelected().isEmpty());
// repeat, hiding column 4 (5 and 6)
+ al = gen.generate(50, 20, 123, 5, 5);
cs = new ColumnSelection();
cs.addElement(4);
cs.addElement(5);
cs.addElement(6);
- cs.hideColumns(4);
- hidden = cs.getHiddenColumns();
+ cs.hideSelectedColumns(4, al);
+ hidden = al.getHiddenColumns().getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
assertTrue(cs.getSelected().isEmpty());
// repeat, hiding column (4, 5 and) 6
+ al = gen.generate(50, 20, 123, 5, 5);
cs = new ColumnSelection();
cs.addElement(4);
cs.addElement(5);
cs.addElement(6);
- cs.hideColumns(6);
- hidden = cs.getHiddenColumns();
+ cs.hideSelectedColumns(6, al);
+ hidden = al.getHiddenColumns().getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
assertTrue(cs.getSelected().isEmpty());
// repeat, with _only_ adjacent columns selected
+ al = gen.generate(50, 20, 123, 5, 5);
cs = new ColumnSelection();
cs.addElement(4);
cs.addElement(6);
- cs.hideColumns(5);
- hidden = cs.getHiddenColumns();
+ cs.hideSelectedColumns(5, al);
+ hidden = al.getHiddenColumns().getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
assertTrue(cs.getSelected().isEmpty());
@Test(groups = { "Functional" })
public void testHideSelectedColumns()
{
+ // create random alignment
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+
ColumnSelection cs = new ColumnSelection();
int[] sel = { 2, 3, 4, 7, 8, 9, 20, 21, 22 };
for (int col : sel)
{
cs.addElement(col);
}
- cs.hideColumns(15, 18);
- cs.hideSelectedColumns();
+ HiddenColumns cols = al.getHiddenColumns();
+ cols.hideColumns(15, 18);
+
+ cs.hideSelectedColumns(al);
assertTrue(cs.getSelected().isEmpty());
- List<int[]> hidden = cs.getHiddenColumns();
+ List<int[]> hidden = cols.getListOfCols();
assertEquals(4, hidden.size());
assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
assertEquals("[7, 9]", Arrays.toString(hidden.get(1)));
assertEquals("[0, 4]", Arrays.toString(range.get(0)));
}
- /**
- * Test the method that reveals a range of hidden columns given the start
- * column of the range
- */
- @Test(groups = { "Functional" })
- public void testRevealHiddenColumns()
- {
- ColumnSelection cs = new ColumnSelection();
- cs.hideColumns(5, 8);
- cs.addElement(10);
- cs.revealHiddenColumns(5);
- // hidden columns list now null but getter returns empty list:
- assertTrue(cs.getHiddenColumns().isEmpty());
- // revealed columns are marked as selected (added to selection):
- assertEquals("[10, 5, 6, 7, 8]", cs.getSelected().toString());
-
- // calling with a column other than the range start does nothing:
- cs = new ColumnSelection();
- cs.hideColumns(5, 8);
- List<int[]> hidden = cs.getHiddenColumns();
- cs.revealHiddenColumns(6);
- assertSame(hidden, cs.getHiddenColumns());
- assertTrue(cs.getSelected().isEmpty());
- }
-
- @Test(groups = { "Functional" })
- public void testRevealAllHiddenColumns()
- {
- ColumnSelection cs = new ColumnSelection();
- cs.hideColumns(5, 8);
- cs.hideColumns(2, 3);
- cs.addElement(11);
- cs.addElement(1);
- cs.revealAllHiddenColumns();
-
- /*
- * revealing hidden columns adds them (in order) to the (unordered)
- * selection list
- */
- assertTrue(cs.getHiddenColumns().isEmpty());
- assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", cs.getSelected().toString());
- }
-
- @Test(groups = { "Functional" })
- public void testIsVisible()
- {
- ColumnSelection cs = new ColumnSelection();
- cs.hideColumns(2, 4);
- cs.hideColumns(6, 7);
- assertTrue(cs.isVisible(0));
- assertTrue(cs.isVisible(-99));
- assertTrue(cs.isVisible(1));
- assertFalse(cs.isVisible(2));
- assertFalse(cs.isVisible(3));
- assertFalse(cs.isVisible(4));
- assertTrue(cs.isVisible(5));
- assertFalse(cs.isVisible(6));
- assertFalse(cs.isVisible(7));
- }
-
- @Test(groups = { "Functional" })
- public void testGetVisibleContigs()
- {
- ColumnSelection cs = new ColumnSelection();
- cs.hideColumns(3, 6);
- cs.hideColumns(8, 9);
- cs.hideColumns(12, 12);
-
- // start position is inclusive, end position exclusive:
- int[] visible = cs.getVisibleContigs(1, 13);
- assertEquals("[1, 2, 7, 7, 10, 11]", Arrays.toString(visible));
-
- visible = cs.getVisibleContigs(4, 14);
- assertEquals("[7, 7, 10, 11, 13, 13]", Arrays.toString(visible));
-
- visible = cs.getVisibleContigs(3, 10);
- assertEquals("[7, 7]", Arrays.toString(visible));
-
- visible = cs.getVisibleContigs(4, 6);
- assertEquals("[]", Arrays.toString(visible));
- }
-
@Test(groups = { "Functional" })
public void testInvertColumnSelection()
{
+ // create random alignment
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+
ColumnSelection cs = new ColumnSelection();
cs.addElement(4);
cs.addElement(6);
cs.addElement(8);
- cs.hideColumns(3, 3);
- cs.hideColumns(6, 6);
+
+ HiddenColumns cols = al.getHiddenColumns();
+ cols.hideColumns(3, 3);
+ cols.hideColumns(6, 6);
// invert selection from start (inclusive) to end (exclusive)
- // hidden columns are _not_ changed
- cs.invertColumnSelection(2, 9);
+ cs.invertColumnSelection(2, 9, al);
assertEquals("[2, 5, 7]", cs.getSelected().toString());
- cs.invertColumnSelection(1, 9);
+ cs.invertColumnSelection(1, 9, al);
assertEquals("[1, 4, 8]", cs.getSelected().toString());
}
cs.addElement(0);
cs.addElement(513);
cs.addElement(1);
- cs.hideColumns(3);
- cs.hideColumns(7);
- cs.hideColumns(5, 9);
// same selections added in a different order
ColumnSelection cs2 = new ColumnSelection();
cs2.addElement(513);
cs2.addElement(0);
- // with no hidden columns
- assertFalse(cs.equals(cs2));
- assertFalse(cs2.equals(cs));
-
- // with hidden columns added in a different order
- cs2.hideColumns(6, 9);
- cs2.hideColumns(5, 8);
- cs2.hideColumns(3);
-
assertTrue(cs.equals(cs2));
assertTrue(cs.equals(cs));
assertTrue(cs2.equals(cs));
cs2.removeElement(12);
assertTrue(cs.equals(cs2));
-
- cs2.hideColumns(88);
- assertFalse(cs.equals(cs2));
- /*
- * unhiding a column adds it to selection!
- */
- cs2.revealHiddenColumns(88);
- assertFalse(cs.equals(cs2));
- cs.addElement(88);
- assertTrue(cs.equals(cs2));
}
+ /*
+ cs2.hideSelectedColumns(88);
+ assertFalse(cs.equals(cs2));
+ /*
+ * unhiding a column adds it to selection!
+ */
+ /* cs2.revealHiddenColumns(88);
+ assertFalse(cs.equals(cs2));
+ cs.addElement(88);
+ assertTrue(cs.equals(cs2));
+ */
+
/**
* Test the method that returns selected columns, in the order in which they
* were added
ColumnSelection cs = new ColumnSelection();
cs.addElement(3);
cs.addElement(1);
- cs.hideColumns(10, 11);
- cs.hideColumns(5, 7);
- assertEquals("[5, 7]", Arrays.toString(cs.getHiddenColumns().get(0)));
ColumnSelection cs2 = new ColumnSelection(cs);
assertTrue(cs2.hasSelectedColumns());
- assertTrue(cs2.hasHiddenColumns());
+
// order of column selection is preserved
assertEquals("[3, 1]", cs2.getSelected().toString());
- assertEquals(2, cs2.getHiddenColumns().size());
- // hidden columns are held in column order
- assertEquals("[5, 7]", Arrays.toString(cs2.getHiddenColumns().get(0)));
- assertEquals("[10, 11]", Arrays.toString(cs2.getHiddenColumns().get(1)));
}
- /**
- * Test for the case when a hidden range encloses more one already hidden
- * range
- */
- @Test(groups = { "Functional" })
- public void testHideColumns_subsumingHidden()
- {
- /*
- * JAL-2370 bug scenario:
- * two hidden ranges subsumed by a third
- */
- ColumnSelection cs = new ColumnSelection();
- cs.hideColumns(49, 59);
- cs.hideColumns(69, 79);
- List<int[]> hidden = cs.getHiddenColumns();
- assertEquals(2, hidden.size());
- assertEquals("[49, 59]", Arrays.toString(hidden.get(0)));
- assertEquals("[69, 79]", Arrays.toString(hidden.get(1)));
-
- cs.hideColumns(48, 80);
- hidden = cs.getHiddenColumns();
- assertEquals(1, hidden.size());
- assertEquals("[48, 80]", Arrays.toString(hidden.get(0)));
-
- /*
- * another...joining hidden ranges
- */
- cs = new ColumnSelection();
- cs.hideColumns(10, 20);
- cs.hideColumns(30, 40);
- cs.hideColumns(50, 60);
- // hiding 21-49 should merge to one range
- cs.hideColumns(21, 49);
- hidden = cs.getHiddenColumns();
- assertEquals(1, hidden.size());
- assertEquals("[10, 60]", Arrays.toString(hidden.get(0)));
-
- /*
- * another...lef overlap, subsumption, right overlap,
- * no overlap of existing hidden ranges
- */
- cs = new ColumnSelection();
- cs.hideColumns(10, 20);
- cs.hideColumns(10, 20);
- cs.hideColumns(30, 35);
- cs.hideColumns(40, 50);
- cs.hideColumns(60, 70);
-
- cs.hideColumns(15, 45);
- hidden = cs.getHiddenColumns();
- assertEquals(2, hidden.size());
- assertEquals("[10, 50]", Arrays.toString(hidden.get(0)));
- assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
- }
@Test(groups = { "Functional" })
public void testStretchGroup_expand()
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * 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/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertSame;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.analysis.AlignmentGenerator;
+import jalview.gui.JvOptionPane;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class HiddenColumnsTest
+{
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
+ /**
+ * Test the method that finds the visible column position of an alignment
+ * column, allowing for hidden columns.
+ */
+ @Test(groups = { "Functional" })
+ public void testFindColumnPosition()
+ {
+ HiddenColumns cs = new HiddenColumns();
+ assertEquals(5, cs.findColumnPosition(5));
+
+ // hiding column 6 makes no difference
+ cs.hideColumns(6, 6);
+ assertEquals(5, cs.findColumnPosition(5));
+
+ // hiding column 4 moves column 5 to column 4
+ cs.hideColumns(4, 4);
+ assertEquals(4, cs.findColumnPosition(5));
+
+ // hiding column 4 moves column 4 to position 3
+ assertEquals(3, cs.findColumnPosition(4));
+
+ // hiding columns 1 and 2 moves column 5 to column 2
+ cs.hideColumns(1, 2);
+ assertEquals(2, cs.findColumnPosition(5));
+
+ // check with > 1 hidden column regions
+ // where some columns are in the hidden regions
+ HiddenColumns cs2 = new HiddenColumns();
+ cs2.hideColumns(5, 10);
+ cs2.hideColumns(20, 27);
+ cs2.hideColumns(40, 44);
+
+ // hiding columns 5-10 and 20-27 moves column 8 to column 4
+ assertEquals(4, cs2.findColumnPosition(8));
+
+ // and moves column 24 to 13
+ assertEquals(13, cs2.findColumnPosition(24));
+
+ // and moves column 28 to 14
+ assertEquals(14, cs2.findColumnPosition(28));
+
+ // and moves column 40 to 25
+ assertEquals(25, cs2.findColumnPosition(40));
+
+ // check when hidden columns start at 0 that the visible column
+ // is returned as 0
+ HiddenColumns cs3 = new HiddenColumns();
+ cs3.hideColumns(0, 4);
+ assertEquals(0, cs3.findColumnPosition(2));
+
+ }
+
+ /**
+ * Test the method that finds the visible column position a given distance
+ * before another column
+ */
+ @Test(groups = { "Functional" })
+ public void testFindColumnNToLeft()
+ {
+ HiddenColumns cs = new HiddenColumns();
+
+ // test that without hidden columns, findColumnNToLeft returns
+ // position n to left of provided position
+ int pos = cs.subtractVisibleColumns(3, 10);
+ assertEquals(7, pos);
+
+ // 0 returns same position
+ pos = cs.subtractVisibleColumns(0, 10);
+ assertEquals(10, pos);
+
+ // overflow to left returns negative number
+ pos = cs.subtractVisibleColumns(3, 0);
+ assertEquals(-3, pos);
+
+ // test that with hidden columns to left of result column
+ // behaviour is the same as above
+ cs.hideColumns(1, 3);
+
+ // position n to left of provided position
+ pos = cs.subtractVisibleColumns(3, 10);
+ assertEquals(7, pos);
+
+ // 0 returns same position
+ pos = cs.subtractVisibleColumns(0, 10);
+ assertEquals(10, pos);
+
+ // test with one set of hidden columns between start and required position
+ cs.hideColumns(12, 15);
+ pos = cs.subtractVisibleColumns(8, 17);
+ assertEquals(5, pos);
+
+ // test with two sets of hidden columns between start and required position
+ cs.hideColumns(20, 21);
+ pos = cs.subtractVisibleColumns(8, 23);
+ assertEquals(9, pos);
+
+ // repeat last 2 tests with no hidden columns to left of required position
+ ColumnSelection colsel = new ColumnSelection();
+ cs.revealAllHiddenColumns(colsel);
+
+ // test with one set of hidden columns between start and required position
+ cs.hideColumns(12, 15);
+ pos = cs.subtractVisibleColumns(8, 17);
+ assertEquals(5, pos);
+
+ // test with two sets of hidden columns between start and required position
+ cs.hideColumns(20, 21);
+ pos = cs.subtractVisibleColumns(8, 23);
+ assertEquals(9, pos);
+
+ }
+
+ @Test(groups = { "Functional" })
+ public void testGetVisibleContigs()
+ {
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(3, 6);
+ cs.hideColumns(8, 9);
+ cs.hideColumns(12, 12);
+
+ // start position is inclusive, end position exclusive:
+ int[] visible = cs.getVisibleContigs(1, 13);
+ assertEquals("[1, 2, 7, 7, 10, 11]", Arrays.toString(visible));
+
+ visible = cs.getVisibleContigs(4, 14);
+ assertEquals("[7, 7, 10, 11, 13, 13]", Arrays.toString(visible));
+
+ visible = cs.getVisibleContigs(3, 10);
+ assertEquals("[7, 7]", Arrays.toString(visible));
+
+ visible = cs.getVisibleContigs(4, 6);
+ assertEquals("[]", Arrays.toString(visible));
+ }
+
+ @Test(groups = { "Functional" })
+ public void testEquals()
+ {
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(5, 9);
+
+ // a different set of hidden columns
+ HiddenColumns cs2 = new HiddenColumns();
+
+ // with no hidden columns
+ assertFalse(cs.equals(cs2));
+ assertFalse(cs2.equals(cs));
+
+ // with hidden columns added in a different order
+ cs2.hideColumns(6, 9);
+ cs2.hideColumns(5, 8);
+
+ assertTrue(cs.equals(cs2));
+ assertTrue(cs.equals(cs));
+ assertTrue(cs2.equals(cs));
+ assertTrue(cs2.equals(cs2));
+ }
+
+ @Test(groups = "Functional")
+ public void testCopyConstructor()
+ {
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(10, 11);
+ cs.hideColumns(5, 7);
+ assertEquals("[5, 7]", Arrays.toString(cs.getListOfCols().get(0)));
+
+ HiddenColumns cs2 = new HiddenColumns(cs);
+ assertTrue(cs2.hasHiddenColumns());
+ assertEquals(2, cs2.getListOfCols().size());
+ // hidden columns are held in column order
+ assertEquals("[5, 7]", Arrays.toString(cs2.getListOfCols().get(0)));
+ assertEquals("[10, 11]", Arrays.toString(cs2.getListOfCols().get(1)));
+ }
+
+ /**
+ * Test the code used to locate the reference sequence ruler origin
+ */
+ @Test(groups = { "Functional" })
+ public void testLocateVisibleBoundsofSequence()
+ {
+ // create random alignment
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+
+ HiddenColumns cs = al.getHiddenColumns();
+ ColumnSelection colsel = new ColumnSelection();
+
+ SequenceI seq = new Sequence("RefSeq", "-A-SD-ASD--E---");
+ assertEquals(2, seq.findIndex(seq.getStart()));
+
+ // no hidden columns
+ assertEquals(
+ Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
+ seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1 }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ // hidden column on gap after end of sequence - should not affect bounds
+ colsel.hideSelectedColumns(13, al);
+ assertEquals(
+ Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1, seq.getStart(),
+ seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1 }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ cs.revealAllHiddenColumns(colsel);
+ // hidden column on gap before beginning of sequence - should vis bounds by
+ // one
+ colsel.hideSelectedColumns(0, al);
+ assertEquals(
+ Arrays.toString(new int[] { seq.findIndex(seq.getStart()) - 2,
+ seq.findIndex(seq.getEnd()) - 2, seq.getStart(),
+ seq.getEnd(), seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1 }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ cs.revealAllHiddenColumns(colsel);
+ // hide columns around most of sequence - leave one residue remaining
+ cs.hideColumns(1, 3);
+ cs.hideColumns(6, 11);
+ assertEquals("-D",
+ cs.getVisibleSequenceStrings(0, 5, new SequenceI[] { seq })[0]);
+ assertEquals(
+ Arrays.toString(new int[] { 1, 1, 3, 3,
+ seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1 }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+ cs.revealAllHiddenColumns(colsel);
+
+ // hide whole sequence - should just get location of hidden region
+ // containing sequence
+ cs.hideColumns(1, 11);
+ assertEquals(
+ Arrays.toString(new int[] { 0, 1, 0, 0,
+ seq.findIndex(seq.getStart()) - 1,
+ seq.findIndex(seq.getEnd()) - 1 }),
+ Arrays.toString(cs.locateVisibleBoundsOfSequence(seq)));
+
+ }
+
+ @Test(groups = { "Functional" })
+ public void testLocateVisibleBoundsPathologicals()
+ {
+ // test some pathological cases we missed
+ AlignmentI al = new Alignment(new SequenceI[] { new Sequence(
+ "refseqGaptest", "KTDVTI----------NFI-----G----L") });
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideInsertionsFor(al.getSequenceAt(0));
+ assertEquals(
+ "G",
+ ""
+ + al.getSequenceAt(0).getCharAt(
+ cs.adjustForHiddenColumns(9)));
+
+ }
+
+ @Test(groups = { "Functional" })
+ public void testHideColumns()
+ {
+ // create random alignment
+ AlignmentGenerator gen = new AlignmentGenerator(false);
+ AlignmentI al = gen.generate(50, 20, 123, 5, 5);
+
+ ColumnSelection colsel = new ColumnSelection();
+ HiddenColumns cs = al.getHiddenColumns();
+ colsel.hideSelectedColumns(5, al);
+ List<int[]> hidden = cs.getListOfCols();
+ assertEquals(1, hidden.size());
+ assertEquals("[5, 5]", Arrays.toString(hidden.get(0)));
+
+ colsel.hideSelectedColumns(3, al);
+ assertEquals(2, hidden.size());
+ // two hidden ranges, in order:
+ assertSame(hidden, cs.getListOfCols());
+ assertEquals("[3, 3]", Arrays.toString(hidden.get(0)));
+ assertEquals("[5, 5]", Arrays.toString(hidden.get(1)));
+
+ // hiding column 4 expands [3, 3] to [3, 4]
+ // and merges to [5, 5] to make [3, 5]
+ colsel.hideSelectedColumns(4, al);
+ hidden = cs.getListOfCols();
+ assertEquals(1, hidden.size());
+ assertEquals("[3, 5]", Arrays.toString(hidden.get(0)));
+
+ // clear hidden columns (note they are added to selected)
+ cs.revealAllHiddenColumns(colsel);
+ // it is now actually null but getter returns an empty list
+ assertTrue(cs.getListOfCols().isEmpty());
+
+ cs.hideColumns(3, 6);
+ hidden = cs.getListOfCols();
+ int[] firstHiddenRange = hidden.get(0);
+ assertEquals("[3, 6]", Arrays.toString(firstHiddenRange));
+
+ // adding a subrange of already hidden should do nothing
+ cs.hideColumns(4, 5);
+ assertEquals(1, hidden.size());
+ assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+ cs.hideColumns(3, 5);
+ assertEquals(1, hidden.size());
+ assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+ cs.hideColumns(4, 6);
+ assertEquals(1, hidden.size());
+ assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+ cs.hideColumns(3, 6);
+ assertEquals(1, hidden.size());
+ assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+
+ cs.revealAllHiddenColumns(colsel);
+ cs.hideColumns(2, 4);
+ hidden = cs.getListOfCols();
+ assertEquals(1, hidden.size());
+ assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
+
+ // extend contiguous with 2 positions overlap
+ cs.hideColumns(3, 5);
+ assertEquals(1, hidden.size());
+ assertEquals("[2, 5]", Arrays.toString(hidden.get(0)));
+
+ // extend contiguous with 1 position overlap
+ cs.hideColumns(5, 6);
+ assertEquals(1, hidden.size());
+ assertEquals("[2, 6]", Arrays.toString(hidden.get(0)));
+
+ // extend contiguous with overlap both ends:
+ cs.hideColumns(1, 7);
+ assertEquals(1, hidden.size());
+ assertEquals("[1, 7]", Arrays.toString(hidden.get(0)));
+ }
+
+ /**
+ * Test the method that reveals a range of hidden columns given the start
+ * column of the range
+ */
+ @Test(groups = { "Functional" })
+ public void testRevealHiddenColumns()
+ {
+ ColumnSelection colsel = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(5, 8);
+ colsel.addElement(10);
+ cs.revealHiddenColumns(5, colsel);
+ // hidden columns list now null but getter returns empty list:
+ assertTrue(cs.getListOfCols().isEmpty());
+ // revealed columns are marked as selected (added to selection):
+ assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString());
+
+ // calling with a column other than the range start does nothing:
+ colsel = new ColumnSelection();
+ cs = new HiddenColumns();
+ cs.hideColumns(5, 8);
+ List<int[]> hidden = cs.getListOfCols();
+ cs.revealHiddenColumns(6, colsel);
+ assertSame(hidden, cs.getListOfCols());
+ assertTrue(colsel.getSelected().isEmpty());
+ }
+
+ @Test(groups = { "Functional" })
+ public void testRevealAllHiddenColumns()
+ {
+ HiddenColumns cs = new HiddenColumns();
+ ColumnSelection colsel = new ColumnSelection();
+ cs.hideColumns(5, 8);
+ cs.hideColumns(2, 3);
+ colsel.addElement(11);
+ colsel.addElement(1);
+ cs.revealAllHiddenColumns(colsel);
+
+ /*
+ * revealing hidden columns adds them (in order) to the (unordered)
+ * selection list
+ */
+ assertTrue(cs.getListOfCols().isEmpty());
+ assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected()
+ .toString());
+ }
+
+ @Test(groups = { "Functional" })
+ public void testIsVisible()
+ {
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(2, 4);
+ cs.hideColumns(6, 7);
+ assertTrue(cs.isVisible(0));
+ assertTrue(cs.isVisible(-99));
+ assertTrue(cs.isVisible(1));
+ assertFalse(cs.isVisible(2));
+ assertFalse(cs.isVisible(3));
+ assertFalse(cs.isVisible(4));
+ assertTrue(cs.isVisible(5));
+ assertFalse(cs.isVisible(6));
+ assertFalse(cs.isVisible(7));
+ }
+
+ /**
+ * Test for the case when a hidden range encloses more one already hidden
+ * range
+ */
+ @Test(groups = { "Functional" })
+ public void testHideColumns_subsumingHidden()
+ {
+ /*
+ * JAL-2370 bug scenario:
+ * two hidden ranges subsumed by a third
+ */
+ HiddenColumns cs = new HiddenColumns();
+ cs.hideColumns(49, 59);
+ cs.hideColumns(69, 79);
+ List<int[]> hidden = cs.getListOfCols();
+ assertEquals(2, hidden.size());
+ assertEquals("[49, 59]", Arrays.toString(hidden.get(0)));
+ assertEquals("[69, 79]", Arrays.toString(hidden.get(1)));
+
+ cs.hideColumns(48, 80);
+ hidden = cs.getListOfCols();
+ assertEquals(1, hidden.size());
+ assertEquals("[48, 80]", Arrays.toString(hidden.get(0)));
+
+ /*
+ * another...joining hidden ranges
+ */
+ cs = new HiddenColumns();
+ cs.hideColumns(10, 20);
+ cs.hideColumns(30, 40);
+ cs.hideColumns(50, 60);
+ // hiding 21-49 should merge to one range
+ cs.hideColumns(21, 49);
+ hidden = cs.getListOfCols();
+ assertEquals(1, hidden.size());
+ assertEquals("[10, 60]", Arrays.toString(hidden.get(0)));
+
+ /*
+ * another...left overlap, subsumption, right overlap,
+ * no overlap of existing hidden ranges
+ */
+ cs = new HiddenColumns();
+ cs.hideColumns(10, 20);
+ cs.hideColumns(10, 20);
+ cs.hideColumns(30, 35);
+ cs.hideColumns(40, 50);
+ cs.hideColumns(60, 70);
+
+ cs.hideColumns(15, 45);
+ hidden = cs.getListOfCols();
+ assertEquals(2, hidden.size());
+ assertEquals("[10, 50]", Arrays.toString(hidden.get(0)));
+ assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
+ }
+
+}
*/
assertFalse(alignFrame.hideFeatureColumns("exon", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- assertTrue(alignFrame.getViewport().getColumnSelection().getHiddenColumns()
+ assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getListOfCols()
.isEmpty());
assertFalse(alignFrame.hideFeatureColumns("exon", false));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- assertTrue(alignFrame.getViewport().getColumnSelection().getHiddenColumns()
+ assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getListOfCols()
.isEmpty());
/*
*/
assertFalse(alignFrame.hideFeatureColumns("Metal", true));
assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
- List<int[]> hidden = alignFrame.getViewport().getColumnSelection()
- .getHiddenColumns();
+ List<int[]> hidden = alignFrame.getViewport().getAlignment()
+ .getHiddenColumns()
+ .getListOfCols();
assertTrue(hidden.isEmpty());
/*
* [1-3], [6-8] base zero
*/
assertTrue(alignFrame.hideFeatureColumns("Turn", true));
- hidden = alignFrame.getViewport().getColumnSelection().getHiddenColumns();
+ hidden = alignFrame.getViewport().getAlignment().getHiddenColumns()
+ .getListOfCols();
assertEquals(hidden.size(), 2);
assertEquals(hidden.get(0)[0], 1);
assertEquals(hidden.get(0)[1], 3);
import static org.testng.AssertJUnit.assertTrue;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.gui.JvOptionPane;
import jalview.io.AnnotationFile.ViewDef;
try
{
AlignmentI al = readAlignmentFile(f);
- ColumnSelection cs = new ColumnSelection();
+ HiddenColumns cs = new HiddenColumns();
assertTrue(
"Test "
+ testname
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
private HashMap<String, SequenceGroup> expectedGrps = new HashMap<String, SequenceGroup>();
- private ColumnSelection expectedColSel = new ColumnSelection();
+ private HiddenColumns expectedColSel = new HiddenColumns();
private SequenceI[] expectedHiddenSeqs = new SequenceI[1];
TEST_SEQ_HEIGHT = expectedSeqs.size();
TEST_GRP_HEIGHT = expectedGrps.size();
TEST_ANOT_HEIGHT = expectedAnnots.size();
- TEST_CS_HEIGHT = expectedColSel.getHiddenColumns().size();
+ TEST_CS_HEIGHT = expectedColSel.getListOfCols().size();
AlignExportSettingI exportSettings = new AlignExportSettingI()
{
jf = (JSONFile) formatAdapter.getAlignFile();
AlignFrame af = new AlignFrame(alignment, jf.getHiddenSequences(),
- jf.getColumnSelection(), AlignFrame.DEFAULT_WIDTH,
+ jf.getHiddenColumns(), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
af.getViewport().setShowSequenceFeatures(jf.isShowSeqFeatures());
String colourSchemeName = jf.getGlobalColourScheme();
@Test(groups = { "Functional" })
public void hiddenColsTest()
{
- ColumnSelection cs = testJsonFile.getColumnSelection();
+ HiddenColumns cs = testJsonFile.getHiddenColumns();
Assert.assertNotNull(cs);
- Assert.assertNotNull(cs.getHiddenColumns());
- List<int[]> hiddenCols = cs.getHiddenColumns();
+ Assert.assertNotNull(cs.getListOfCols());
+ List<int[]> hiddenCols = cs.getListOfCols();
Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT);
Assert.assertEquals(hiddenCols.get(0), expectedColSel
- .getHiddenColumns().get(0),
+ .getListOfCols().get(0),
"Mismatched hidden columns!");
}
import jalview.api.SequenceRenderer;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.Sequence;
@Override
public String superposeStructures(AlignmentI[] als, int[] alm,
- ColumnSelection[] alc)
+ HiddenColumns[] alc)
{
return null;
}
* Column 0 in protein picks up Seq2/L, Seq3/G which map to cols 0-4 and 0-3
* in dna respectively, overall 0-4
*/
- proteinSelection.hideColumns(0);
+ proteinSelection.hideSelectedColumns(0);
ColumnSelection dnaSelection = MappingUtils.mapColumnSelection(
proteinSelection, proteinView, dnaView);
assertEquals("[]", dnaSelection.getSelected().toString());
- List<int[]> hidden = dnaSelection.getHiddenColumns();
+ List<int[]> hidden = dnaSelection.getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[0, 4]", Arrays.toString(hidden.get(0)));
assertEquals("[0]", proteinSelection.getSelected().toString());
// deselect these or hideColumns will be expanded to include 0
proteinSelection.clear();
- proteinSelection.hideColumns(1);
+ proteinSelection.hideSelectedColumns(1);
dnaSelection = MappingUtils.mapColumnSelection(proteinSelection,
proteinView, dnaView);
- hidden = dnaSelection.getHiddenColumns();
+ hidden = dnaSelection.getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
*/
proteinSelection.revealAllHiddenColumns();
proteinSelection.clear();
- proteinSelection.hideColumns(2);
+ proteinSelection.hideSelectedColumns(2);
dnaSelection = MappingUtils.mapColumnSelection(proteinSelection,
proteinView, dnaView);
- assertTrue(dnaSelection.getHiddenColumns().isEmpty());
+ assertTrue(dnaSelection.getListOfCols().isEmpty());
/*
* Column 3 in protein picks up Seq1/P, Seq2/Q, Seq3/S which map to columns
*/
proteinSelection.revealAllHiddenColumns();
proteinSelection.clear();
- proteinSelection.hideColumns(3); // 5-10 hidden in dna
+ proteinSelection.hideSelectedColumns(3); // 5-10 hidden in dna
proteinSelection.addElement(1); // 0-3 selected in dna
dnaSelection = MappingUtils.mapColumnSelection(proteinSelection,
proteinView, dnaView);
assertEquals("[0, 1, 2, 3]", dnaSelection.getSelected().toString());
- hidden = dnaSelection.getHiddenColumns();
+ hidden = dnaSelection.getListOfCols();
assertEquals(1, hidden.size());
assertEquals("[5, 10]", Arrays.toString(hidden.get(0)));
*/
proteinSelection.revealAllHiddenColumns();
proteinSelection.clear();
- proteinSelection.hideColumns(1);
- proteinSelection.hideColumns(3);
+ proteinSelection.hideSelectedColumns(1);
+ proteinSelection.hideSelectedColumns(3);
dnaSelection = MappingUtils.mapColumnSelection(proteinSelection,
proteinView, dnaView);
- hidden = dnaSelection.getHiddenColumns();
+ hidden = dnaSelection.getListOfCols();
assertEquals(2, hidden.size());
assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
assertEquals("[5, 10]", Arrays.toString(hidden.get(1)));
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
- ColumnSelection hiddenCols = new ColumnSelection();
+ HiddenColumns hiddenCols = new HiddenColumns();
@BeforeClass(alwaysRun = true)
public void setUpJvOptionPane()
{
al.getHiddenSequences().showAll(hiddenRepSequences);
}
- hiddenCols.revealAllHiddenColumns();
+ ColumnSelection colsel = new ColumnSelection();
+ hiddenCols.revealAllHiddenColumns(colsel);
vpranges = new ViewportRanges(al);
vpranges.setStartRes(0);
viewHeight = vpranges.getEndSeq() - vpranges.getStartSeq() + 1;
viewWidth = vpranges.getEndRes() - vpranges.getStartRes() + 1;
- ColumnSelection hiddenCols = new ColumnSelection();
+ HiddenColumns hiddenCols = new HiddenColumns();
od = new OverviewDimensions(vpranges, true);
// Initial box sizing - default path through code