ScGroup()
{
- seqs = new ArrayList<SeqCigar>();
+ seqs = new ArrayList<>();
}
/**
* - when set, any groups on the given alignment will be marked on
* the view
*/
- public AlignmentView(AlignmentI alignment,
- HiddenColumns hidden,
- SequenceGroup selection,
- boolean hasHiddenColumns, boolean selectedRegionOnly,
- boolean recordGroups)
+ public AlignmentView(AlignmentI alignment, HiddenColumns hidden,
+ SequenceGroup selection, boolean hasHiddenColumns,
+ boolean selectedRegionOnly, boolean recordGroups)
{
// refactored from AlignViewport.getAlignmentView(selectedOnly);
this(new jalview.datamodel.CigarArray(alignment,
(hasHiddenColumns ? hidden : null),
(selectedRegionOnly ? selection : null)),
- (selectedRegionOnly && selection != null) ? selection
- .getStartRes() : 0);
+ (selectedRegionOnly && selection != null)
+ ? selection.getStartRes()
+ : 0);
isNa = alignment.isNucleotide();
// walk down SeqCigar array and Alignment Array - optionally restricted by
// selected region.
SequenceI[] selseqs;
if (selection != null && selection.getSize() > 0)
{
- List<SequenceI> sel = selection.getSequences(null);
this.selected = new ScGroup();
- selseqs = selection
- .getSequencesInOrder(alignment, selectedRegionOnly);
+ selseqs = selection.getSequencesInOrder(alignment,
+ selectedRegionOnly);
}
else
{
selseqs = alignment.getSequencesArray();
}
- List<List<SequenceI>> seqsets = new ArrayList<List<SequenceI>>();
+ List<List<SequenceI>> seqsets = new ArrayList<>();
// get the alignment's group list and make a copy
- List<SequenceGroup> grps = new ArrayList<SequenceGroup>();
+ List<SequenceGroup> grps = new ArrayList<>();
List<SequenceGroup> gg = alignment.getGroups();
grps.addAll(gg);
ScGroup[] sgrps = null;
// strip out any groups that do not actually intersect with the
// visible and selected region
int ssel = selection.getStartRes(), esel = selection.getEndRes();
- List<SequenceGroup> isg = new ArrayList<SequenceGroup>();
+ List<SequenceGroup> isg = new ArrayList<>();
for (SequenceGroup sg : grps)
{
if (!(sg.getStartRes() > esel || sg.getEndRes() < ssel))
{
if (scGroups == null)
{
- scGroups = new ArrayList<ScGroup>();
+ scGroups = new ArrayList<>();
}
addedgps[sg] = true;
scGroups.add(sgrps[sg]);
{
HiddenColumns hidden = new HiddenColumns();
- return new Object[] {
- SeqCigar.createAlignmentSequences(sequences, gapCharacter, hidden,
- contigs), hidden };
+ return new Object[] { SeqCigar.createAlignmentSequences(sequences,
+ gapCharacter, hidden, contigs),
+ hidden };
}
/**
* - true if vcal is alignment of the visible regions of the view
* (e.g. as returned from getVisibleAlignment)
*/
- private void addPrunedGroupsInOrder(AlignmentI vcal, int gstart,
- int gend, boolean viscontigs)
+ private void addPrunedGroupsInOrder(AlignmentI vcal, int gstart, int gend,
+ boolean viscontigs)
{
boolean r = false;
if (gstart > -1 && gstart <= gend)
for (int h = 0; h < contigs.length; h += 3)
{
{
- prune.addShift(p + contigs[h + 1], contigs[h + 2]
- - contigs[h + 1]);
+ prune.addShift(p + contigs[h + 1],
+ contigs[h + 2] - contigs[h + 1]);
}
p = contigs[h + 1] + contigs[h + 2];
}
SequenceI mseq[] = new SequenceI[sequences.length];
for (int s = 0; s < mseq.length; s++)
{
- mseq[s] = sequences[s].getSeq(gapCharacter).getSubSequence(
- start, contigs[contig + 1]);
+ mseq[s] = sequences[s].getSeq(gapCharacter)
+ .getSubSequence(start, contigs[contig + 1]);
}
smsa[j] = mseq;
j++;
{
if (sequences == null || width <= 0)
{
- throw new Error(
- MessageManager
- .getString("error.empty_view_cannot_be_updated"));
+ throw new Error(MessageManager
+ .getString("error.empty_view_cannot_be_updated"));
}
if (nvismsa == null)
{
j++;
if (mseq.length != sequences.length)
{
- throw new Error(
- MessageManager
- .formatMessage(
- "error.mismatch_between_number_of_sequences_in_block",
- new String[] {
- Integer.valueOf(j).toString(),
- Integer.valueOf(mseq.length)
- .toString(),
- Integer.valueOf(
- sequences.length)
- .toString() }));
+ throw new Error(MessageManager.formatMessage(
+ "error.mismatch_between_number_of_sequences_in_block",
+ new String[]
+ { Integer.valueOf(j).toString(),
+ Integer.valueOf(mseq.length).toString(),
+ Integer.valueOf(sequences.length)
+ .toString() }));
}
swidth = mseq[0].getLength(); // JBPNote: could ensure padded
// here.
}
else
{
- alignment[s].setSequence(alignment[s]
- .getSequenceAsString()
- + mseq[s].getSequenceAsString());
+ alignment[s]
+ .setSequence(alignment[s].getSequenceAsString()
+ + mseq[s].getSequenceAsString());
if (mseq[s].getStart() <= mseq[s].getEnd())
{
alignment[s].setEnd(mseq[s].getEnd());
}
else
{
- alignment[s].setSequence(alignment[s]
- .getSequenceAsString()
- + oseq.getSequenceAsString());
+ alignment[s]
+ .setSequence(alignment[s].getSequenceAsString()
+ + oseq.getSequenceAsString());
if (oseq.getEnd() >= oseq.getStart())
{
alignment[s].setEnd(oseq.getEnd());
}
}
// mark hidden segment as hidden in the new alignment
- hidden.hideColumns(nwidth, nwidth + contigs[contig + 2]
- - 1);
+ hidden.hideColumns(nwidth, nwidth + contigs[contig + 2] - 1);
nwidth += contigs[contig + 2];
}
// Do final segment - if it exists
}
else
{
- alignment[s].setSequence(alignment[s]
- .getSequenceAsString()
- + oseq.getSequenceAsString());
+ alignment[s]
+ .setSequence(alignment[s].getSequenceAsString()
+ + oseq.getSequenceAsString());
if (oseq.getEnd() >= oseq.getStart())
{
alignment[s].setEnd(oseq.getEnd());
else
{
// place gaps.
- throw new Error(
- MessageManager
- .getString("error.padding_not_yet_implemented"));
+ throw new Error(MessageManager
+ .getString("error.padding_not_yet_implemented"));
}
}
}
{
if (nvismsa.length != 1)
{
- throw new Error(
- MessageManager
- .formatMessage(
- "error.mismatch_between_visible_blocks_to_update_and_number_of_contigs_in_view",
- new String[] { Integer.valueOf(
- nvismsa.length).toString() }));
+ throw new Error(MessageManager.formatMessage(
+ "error.mismatch_between_visible_blocks_to_update_and_number_of_contigs_in_view",
+ new String[]
+ { Integer.valueOf(nvismsa.length).toString() }));
}
if (nvismsa[0] != null)
{
- return new Object[] { nvismsa[0], new ColumnSelection() };
+ return new Object[] { nvismsa[0], new HiddenColumns() };
}
else
{
if (start < fwidth)
{
viscontigs[nvis] = start;
- viscontigs[nvis + 1] = fwidth; // end is inclusive
+ viscontigs[nvis + 1] = fwidth - 1; // end is inclusive
nvis += 2;
}
return viscontigs;
}
else
{
- return new int[] { 0, width };
+ return new int[] { 0, width - 1 };
}
}
AlignmentView view = null;
try
{
- System.out
- .println("View with no hidden columns, no limit to selection, no groups to be collected:");
+ System.out.println(
+ "View with no hidden columns, no limit to selection, no groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, false, false,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection but no groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection but no groups marked.");
}
try
{
- System.out
- .println("View with no hidden columns, no limit to selection, and all groups to be collected:");
+ System.out.println(
+ "View with no hidden columns, no limit to selection, and all groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, false, false,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection marked but no groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection marked but no groups marked.");
}
try
{
- System.out
- .println("View with no hidden columns, limited to selection and no groups to be collected:");
+ System.out.println(
+ "View with no hidden columns, limited to selection and no groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, false, true,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection restricted but no groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection restricted but no groups marked.");
}
try
{
- System.out
- .println("View with no hidden columns, limited to selection, and all groups to be collected:");
+ System.out.println(
+ "View with no hidden columns, limited to selection, and all groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, false, true,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection restricted and groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection restricted and groups marked.");
}
try
{
- System.out
- .println("View *with* hidden columns, no limit to selection, no groups to be collected:");
+ System.out.println(
+ "View *with* hidden columns, no limit to selection, no groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, true, false,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection but no groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection but no groups marked.");
}
try
{
- System.out
- .println("View *with* hidden columns, no limit to selection, and all groups to be collected:");
+ System.out.println(
+ "View *with* hidden columns, no limit to selection, and all groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, true, false,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection marked but no groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection marked but no groups marked.");
}
try
{
- System.out
- .println("View *with* hidden columns, limited to selection and no groups to be collected:");
+ System.out.println(
+ "View *with* hidden columns, limited to selection and no groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, true, true,
false);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection restricted but no groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection restricted but no groups marked.");
}
try
{
- System.out
- .println("View *with* hidden columns, limited to selection, and all groups to be collected:");
+ System.out.println(
+ "View *with* hidden columns, limited to selection, and all groups to be collected:");
view = new AlignmentView(alignment, hidden, selection, true, true,
true);
summariseAlignmentView(view, System.out);
} catch (Exception e)
{
e.printStackTrace();
- System.err
- .println("Failed to generate alignment with selection restricted and groups marked.");
+ System.err.println(
+ "Failed to generate alignment with selection restricted and groups marked.");
}
}