2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import jalview.util.MessageManager;
24 import jalview.util.ShiftList;
26 import java.io.PrintStream;
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import java.util.List;
32 * Transient object compactly representing a 'view' of an alignment - with
33 * discontinuities marked. Extended in Jalview 2.7 to optionally record sequence
34 * groups and specific selected regions on the alignment.
36 public class AlignmentView
38 private SeqCigar[] sequences = null;
40 private int[] contigs = null;
42 private int width = 0;
44 private int firstCol = 0;
47 * one or more ScGroup objects, which are referenced by each seqCigar's group
50 private List<ScGroup> scGroups = null;
52 private boolean isNa = false;
55 * false if the view concerns peptides
65 * Group defined over SeqCigars. Unlike AlignmentI associated groups, each
66 * SequenceGroup hold just the essential properties for the group, but no
67 * references to the sequences involved. SeqCigars hold references to the
68 * seuqenceGroup entities themselves.
72 public List<SeqCigar> seqs;
74 public SequenceGroup sg;
78 seqs = new ArrayList<>();
83 * @return true if seq was not a member before and was added to group
85 public boolean add(SeqCigar seq)
87 if (!seq.isMemberOf(this))
90 seq.setGroupMembership(this);
102 * @return true if seq was a member and was removed from group
104 public boolean remove(SeqCigar seq)
106 if (seq.removeGroupMembership(this))
119 public SequenceGroup getNewSequenceGroup(char c)
121 SequenceGroup newsg = new SequenceGroup(sg);
122 for (SeqCigar seq : seqs)
124 newsg.addSequence(seq.getSeq(c), false);
131 * vector of selected seqCigars. This vector is also referenced by each
132 * seqCigar contained in it.
134 private ScGroup selected;
137 * Construct an alignmentView from a live jalview alignment view. Note -
138 * hidden rows will be excluded from alignmentView Note: JAL-1179
141 * - alignment as referenced by an AlignViewport
142 * @param columnSelection
145 * @param hasHiddenColumns
146 * - mark the hidden columns in columnSelection as hidden in the view
147 * @param selectedRegionOnly
148 * - when set, only include the selected region in the view,
149 * otherwise just mark the selected region on the constructed view.
150 * @param recordGroups
151 * - when set, any groups on the given alignment will be marked on
154 public AlignmentView(AlignmentI alignment, HiddenColumns hidden,
155 SequenceGroup selection, boolean hasHiddenColumns,
156 boolean selectedRegionOnly, boolean recordGroups)
158 // refactored from AlignViewport.getAlignmentView(selectedOnly);
159 this(new jalview.datamodel.CigarArray(alignment,
160 (hasHiddenColumns ? hidden : null),
161 (selectedRegionOnly ? selection : null)),
162 (selectedRegionOnly && selection != null)
163 ? selection.getStartRes()
165 isNa = alignment.isNucleotide();
166 // walk down SeqCigar array and Alignment Array - optionally restricted by
168 // test group membership for each sequence in each group, store membership
169 // and record non-empty groups in group list.
170 // record / sub-select selected region on the alignment view
172 if (selection != null && selection.getSize() > 0)
174 this.selected = new ScGroup();
175 selseqs = selection.getSequencesInOrder(alignment,
180 selseqs = alignment.getSequencesArray();
183 List<List<SequenceI>> seqsets = new ArrayList<>();
184 // get the alignment's group list and make a copy
185 List<SequenceGroup> grps = new ArrayList<>();
186 List<SequenceGroup> gg = alignment.getGroups();
188 ScGroup[] sgrps = null;
189 boolean addedgps[] = null;
192 if (selection != null && selectedRegionOnly)
194 // trim annotation to the region being stored.
195 // strip out any groups that do not actually intersect with the
196 // visible and selected region
197 int ssel = selection.getStartRes(), esel = selection.getEndRes();
198 List<SequenceGroup> isg = new ArrayList<>();
199 for (SequenceGroup sg : grps)
201 if (!(sg.getStartRes() > esel || sg.getEndRes() < ssel))
203 // adjust bounds of new group, if necessary.
204 if (sg.getStartRes() < ssel)
206 sg.setStartRes(ssel);
208 if (sg.getEndRes() > esel)
212 sg.setStartRes(sg.getStartRes() - ssel + 1);
213 sg.setEndRes(sg.getEndRes() - ssel + 1);
221 sgrps = new ScGroup[grps.size()];
222 addedgps = new boolean[grps.size()];
223 for (int g = 0; g < sgrps.length; g++)
225 SequenceGroup sg = grps.get(g);
226 sgrps[g] = new ScGroup();
227 sgrps[g].sg = new SequenceGroup(sg);
229 // can't set entry 0 in an empty list
230 // seqsets.set(g, sg.getSequences(null));
231 seqsets.add(sg.getSequences());
233 // seqsets now contains vectors (should be sets) for each group, so we can
234 // track when we've done with the group
237 for (int i = 0; i < selseqs.length; i++)
239 if (selseqs[i] != null)
241 if (selection != null && selection.getSize() > 0
242 && !selectedRegionOnly)
244 selected.add(sequences[csi]);
248 for (int sg = 0; sg < sgrps.length; sg++)
250 if ((seqsets.get(sg)).contains(selseqs[i]))
252 sgrps[sg].sg.deleteSequence(selseqs[i], false);
253 sgrps[sg].add(sequences[csi]);
256 if (scGroups == null)
258 scGroups = new ArrayList<>();
261 scGroups.add(sgrps[sg]);
269 // finally, delete the remaining sequences (if any) not selected
270 for (int sg = 0; sg < sgrps.length; sg++)
272 SequenceI[] sqs = sgrps[sg].sg.getSequencesAsArray(null);
273 for (int si = 0; si < sqs.length; si++)
275 sgrps[sg].sg.deleteSequence(sqs[si], false);
282 * construct an alignmentView from a SeqCigarArray. Errors are thrown if the
283 * seqcigararray.isSeqCigarArray() flag is not set.
285 public AlignmentView(CigarArray seqcigararray)
287 if (!seqcigararray.isSeqCigarArray())
290 "Implementation Error - can only make an alignment view from a CigarArray of sequences.");
292 // contigs = seqcigararray.applyDeletions();
293 contigs = seqcigararray.getDeletedRegions();
294 sequences = seqcigararray.getSeqCigarArray();
295 width = seqcigararray.getWidth(); // visible width
299 * Create an alignmentView where the first column corresponds with the
300 * 'firstcol' column of some reference alignment
305 public AlignmentView(CigarArray sdata, int firstcol)
311 public void setSequences(SeqCigar[] sequences)
313 this.sequences = sequences;
316 public void setContigs(int[] contigs)
318 this.contigs = contigs;
321 public SeqCigar[] getSequences()
327 * @see CigarArray.getDeletedRegions
328 * @return int[] { vis_start, sym_start, length }
330 public int[] getContigs()
336 * get the full alignment and a columnselection object marking the hidden
339 * @param gapCharacter
341 * @return Object[] { SequenceI[], ColumnSelection}
343 public Object[] getAlignmentAndHiddenColumns(char gapCharacter)
345 HiddenColumns hidden = new HiddenColumns();
347 return new Object[] { SeqCigar.createAlignmentSequences(sequences,
348 gapCharacter, hidden, contigs),
353 * return the visible alignment corresponding to this view. Sequences in this
354 * alignment are edited versions of the parent sequences - where hidden
355 * regions have been removed. NOTE: the sequence data in this alignment is not
361 public AlignmentI getVisibleAlignment(char c)
363 SequenceI[] aln = getVisibleSeqs(c);
365 AlignmentI vcal = new Alignment(aln);
366 addPrunedGroupsInOrder(vcal, -1, -1, true);
371 * add groups from view to the given alignment
377 * -1 or gstart to width-1
379 * - true if vcal is alignment of the visible regions of the view
380 * (e.g. as returned from getVisibleAlignment)
382 private void addPrunedGroupsInOrder(AlignmentI vcal, int gstart, int gend,
386 if (gstart > -1 && gstart <= gend)
391 SequenceI[] aln = vcal.getSequencesArray();
394 * prune any groups to the visible coordinates of the alignment.
397 int nvg = (scGroups != null) ? scGroups.size() : 0;
400 SequenceGroup[] nsg = new SequenceGroup[nvg];
401 for (int g = 0; g < nvg; g++)
403 SequenceGroup sg = scGroups.get(g).sg;
406 if (sg.getStartRes() > gend || sg.getEndRes() < gstart)
414 // clone group properties
415 nsg[g] = new SequenceGroup(sg);
417 // may need to shift/trim start and end ?
418 if (r && !viscontigs)
420 // Not fully tested code - routine not yet called with
422 if (nsg[g].getStartRes() < gstart)
424 nsg[g].setStartRes(0);
428 nsg[g].setStartRes(nsg[g].getStartRes() - gstart);
429 nsg[g].setEndRes(nsg[g].getEndRes() - gstart);
431 if (nsg[g].getEndRes() > (gend - gstart))
433 nsg[g].setEndRes(gend - gstart);
439 // prune groups to cover just the visible positions between
444 ShiftList prune = new ShiftList();
447 // adjust for start of alignment within visible window.
448 prune.addShift(gstart, -gstart); //
450 for (int h = 0; h < contigs.length; h += 3)
453 prune.addShift(p + contigs[h + 1],
454 contigs[h + 2] - contigs[h + 1]);
456 p = contigs[h + 1] + contigs[h + 2];
458 for (int g = 0; g < nsg.length; g++)
462 int s = nsg[g].getStartRes(), t = nsg[g].getEndRes();
477 nsg[g].setStartRes(s);
484 for (int nsq = 0; nsq < aln.length; nsq++)
486 for (int g = 0; g < nvg; g++)
489 && sequences[nsq].isMemberOf(scGroups.get(g)))
491 nsg[g].addSequence(aln[nsq], false);
495 for (int g = 0; g < nvg; g++)
497 if (nsg[g] != null && nsg[g].getSize() > 0)
499 vcal.addGroup(nsg[g]);
509 * generate sequence array corresponding to the visible parts of the
513 * gap character to use to recreate the alignment
516 private SequenceI[] getVisibleSeqs(char c)
518 SequenceI[] aln = new SequenceI[sequences.length];
519 for (int i = 0, j = sequences.length; i < j; i++)
521 aln[i] = sequences[i].getSeq(c);
522 // Remove hidden regions from sequence
523 aln[i].setSequence(getASequenceString(c, i));
529 * creates new alignment objects for all contiguous visible segments
534 * @param regionOfInterest
535 * specify which sequences to include (or null to include all
537 * @return AlignmentI[] - all alignments where each sequence is a subsequence
538 * constructed from visible contig regions of view
540 public AlignmentI[] getVisibleContigAlignments(char c)
543 int[] vcontigs = getVisibleContigs();
544 SequenceI[][] contigviews = getVisibleContigs(c);
545 AlignmentI[] vcals = new AlignmentI[contigviews.length];
546 for (nvc = 0; nvc < contigviews.length; nvc++)
548 vcals[nvc] = new Alignment(contigviews[nvc]);
549 if (scGroups != null && scGroups.size() > 0)
551 addPrunedGroupsInOrder(vcals[nvc], vcontigs[nvc * 2],
552 vcontigs[nvc * 2 + 1], true);
559 * build a string excluding hidden regions from a particular sequence in the
566 private String getASequenceString(char c, int n)
569 String fullseq = sequences[n].getSequenceString(c);
574 for (int h = 0; h < contigs.length; h += 3)
576 sqn += fullseq.substring(p, contigs[h + 1]);
577 p = contigs[h + 1] + contigs[h + 2];
579 sqn += fullseq.substring(p);
589 * get an array of visible sequence strings for a view on an alignment using
590 * the given gap character uses getASequenceString
596 public String[] getSequenceStrings(char c)
598 String[] seqs = new String[sequences.length];
599 for (int n = 0; n < sequences.length; n++)
601 seqs[n] = getASequenceString(c, n);
608 * @return visible number of columns in alignment view
610 public int getWidth()
615 protected void setWidth(int width)
621 * get the contiguous subalignments in an alignment view.
623 * @param gapCharacter
625 * @return SequenceI[][]
627 public SequenceI[][] getVisibleContigs(char gapCharacter)
631 if (sequences == null || width <= 0)
635 if (contigs != null && contigs.length > 0)
640 for (int contig = 0; contig < contigs.length; contig += 3)
642 if ((contigs[contig + 1] - start) > 0)
646 fwidth += contigs[contig + 2]; // end up with full region width
647 // (including hidden regions)
648 start = contigs[contig + 1] + contigs[contig + 2];
654 smsa = new SequenceI[njobs][];
657 for (int contig = 0; contig < contigs.length; contig += 3)
659 if (contigs[contig + 1] - start > 0)
661 SequenceI mseq[] = new SequenceI[sequences.length];
662 for (int s = 0; s < mseq.length; s++)
664 mseq[s] = sequences[s].getSeq(gapCharacter)
665 .getSubSequence(start, contigs[contig + 1]);
670 start = contigs[contig + 1] + contigs[contig + 2];
674 SequenceI mseq[] = new SequenceI[sequences.length];
675 for (int s = 0; s < mseq.length; s++)
677 mseq[s] = sequences[s].getSeq(gapCharacter).getSubSequence(start,
686 smsa = new SequenceI[1][];
687 smsa[0] = new SequenceI[sequences.length];
688 for (int s = 0; s < sequences.length; s++)
690 smsa[0][s] = sequences[s].getSeq(gapCharacter);
697 * return full msa and hidden regions with visible blocks replaced with new
703 * AlignmentOrder[] corresponding to each SequenceI[] block.
706 public Object[] getUpdatedView(SequenceI[][] nvismsa,
707 AlignmentOrder[] orders, char gapCharacter)
709 if (sequences == null || width <= 0)
711 throw new Error(MessageManager
712 .getString("error.empty_view_cannot_be_updated"));
717 "nvismsa==null. use getAlignmentAndColumnSelection() instead.");
719 if (contigs != null && contigs.length > 0)
721 SequenceI[] alignment = new SequenceI[sequences.length];
722 // ColumnSelection columnselection = new ColumnSelection();
723 HiddenColumns hidden = new HiddenColumns();
724 if (contigs != null && contigs.length > 0)
730 for (int contig = 0; contig < contigs.length; contig += 3)
732 owidth += contigs[contig + 2]; // recover final column width
733 if (contigs[contig + 1] - start > 0)
735 int swidth = 0; // subalignment width
736 if (nvismsa[j] != null)
738 SequenceI mseq[] = nvismsa[j];
739 AlignmentOrder order = (orders == null) ? null : orders[j];
741 if (mseq.length != sequences.length)
743 throw new Error(MessageManager.formatMessage(
744 "error.mismatch_between_number_of_sequences_in_block",
746 { Integer.valueOf(j).toString(),
747 Integer.valueOf(mseq.length).toString(),
748 Integer.valueOf(sequences.length)
751 swidth = mseq[0].getLength(); // JBPNote: could ensure padded
753 for (int s = 0; s < mseq.length; s++)
755 if (alignment[s] == null)
757 alignment[s] = mseq[s];
762 .setSequence(alignment[s].getSequenceAsString()
763 + mseq[s].getSequenceAsString());
764 if (mseq[s].getStart() <= mseq[s].getEnd())
766 alignment[s].setEnd(mseq[s].getEnd());
770 order.updateSequence(mseq[s], alignment[s]);
777 // recover original alignment block or place gaps
780 // recover input data
781 for (int s = 0; s < sequences.length; s++)
783 SequenceI oseq = sequences[s].getSeq(gapCharacter)
784 .getSubSequence(start, contigs[contig + 1]);
785 if (swidth < oseq.getLength())
787 swidth = oseq.getLength();
789 if (alignment[s] == null)
796 .setSequence(alignment[s].getSequenceAsString()
797 + oseq.getSequenceAsString());
798 if (oseq.getEnd() >= oseq.getStart())
800 alignment[s].setEnd(oseq.getEnd());
810 // advance to begining of visible region
811 start = contigs[contig + 1] + contigs[contig + 2];
812 // add hidden segment to right of next region
813 for (int s = 0; s < sequences.length; s++)
815 SequenceI hseq = sequences[s].getSeq(gapCharacter)
816 .getSubSequence(contigs[contig + 1], start);
817 if (alignment[s] == null)
823 alignment[s].setSequence(alignment[s].getSequenceAsString()
824 + hseq.getSequenceAsString());
825 if (hseq.getEnd() >= hseq.getStart())
827 alignment[s].setEnd(hseq.getEnd());
831 // mark hidden segment as hidden in the new alignment
832 hidden.hideColumns(nwidth, nwidth + contigs[contig + 2] - 1);
833 nwidth += contigs[contig + 2];
835 // Do final segment - if it exists
836 if (j < nvismsa.length)
839 if (nvismsa[j] != null)
841 SequenceI mseq[] = nvismsa[j];
842 AlignmentOrder order = (orders != null) ? orders[j] : null;
843 swidth = mseq[0].getLength();
844 for (int s = 0; s < mseq.length; s++)
846 if (alignment[s] == null)
848 alignment[s] = mseq[s];
852 alignment[s].setSequence(alignment[s].getSequenceAsString()
853 + mseq[s].getSequenceAsString());
854 if (mseq[s].getEnd() >= mseq[s].getStart())
856 alignment[s].setEnd(mseq[s].getEnd());
860 order.updateSequence(mseq[s], alignment[s]);
869 // recover input data or place gaps
872 // recover input data
873 for (int s = 0; s < sequences.length; s++)
875 SequenceI oseq = sequences[s].getSeq(gapCharacter)
876 .getSubSequence(start, owidth + 1);
877 if (swidth < oseq.getLength())
879 swidth = oseq.getLength();
881 if (alignment[s] == null)
888 .setSequence(alignment[s].getSequenceAsString()
889 + oseq.getSequenceAsString());
890 if (oseq.getEnd() >= oseq.getStart())
892 alignment[s].setEnd(oseq.getEnd());
901 throw new Error(MessageManager
902 .getString("error.padding_not_yet_implemented"));
908 return new Object[] { alignment, hidden };
912 if (nvismsa.length != 1)
914 throw new Error(MessageManager.formatMessage(
915 "error.mismatch_between_visible_blocks_to_update_and_number_of_contigs_in_view",
917 { Integer.valueOf(nvismsa.length).toString() }));
919 if (nvismsa[0] != null)
921 return new Object[] { nvismsa[0], new HiddenColumns() };
925 return getAlignmentAndHiddenColumns(gapCharacter);
931 * returns simple array of start end positions of visible range on alignment.
932 * vis_start and vis_end are inclusive - use
933 * SequenceI.getSubSequence(vis_start, vis_end+1) to recover visible sequence
934 * from underlying alignment.
936 * @return int[] { start_i, end_i } for 1<i<n visible regions.
938 public int[] getVisibleContigs()
940 if (contigs != null && contigs.length > 0)
945 for (int contig = 0; contig < contigs.length; contig += 3)
947 if ((contigs[contig + 1] - start) > 0)
951 fwidth += contigs[contig + 2]; // end up with full region width
952 // (including hidden regions)
953 start = contigs[contig + 1] + contigs[contig + 2];
959 int viscontigs[] = new int[nvis * 2];
962 for (int contig = 0; contig < contigs.length; contig += 3)
964 if ((contigs[contig + 1] - start) > 0)
966 viscontigs[nvis] = start;
967 viscontigs[nvis + 1] = contigs[contig + 1] - 1; // end is inclusive
970 start = contigs[contig + 1] + contigs[contig + 2];
974 viscontigs[nvis] = start;
975 viscontigs[nvis + 1] = fwidth - 1; // end is inclusive
982 return new int[] { 0, width - 1 };
988 * @return position of first visible column of AlignmentView within its
989 * parent's alignment reference frame
991 public int getAlignmentOrigin()
997 * compute a deletion map for the current view according to the given
1001 * (as returned from SequenceI.gapMap())
1002 * @return int[] {intersection of visible regions with gapMap)
1004 public int[] getVisibleContigMapFor(int[] gapMap)
1006 int[] delMap = null;
1007 int[] viscontigs = getVisibleContigs();
1010 if (viscontigs != null)
1012 // viscontigs maps from a subset of the gapMap to the gapMap, so it will
1013 // always be equal to or shorter than gapMap
1014 delMap = new int[gapMap.length];
1015 for (int contig = 0; contig < viscontigs.length; contig += 2)
1018 while (spos < gapMap.length && gapMap[spos] < viscontigs[contig])
1022 while (spos < gapMap.length
1023 && gapMap[spos] <= viscontigs[contig + 1])
1025 delMap[i++] = spos++;
1028 int tmap[] = new int[i];
1029 System.arraycopy(delMap, 0, tmap, 0, i);
1036 * apply the getSeq(gc) method to each sequence cigar, and return the array of
1037 * edited sequences, optionally with hidden regions removed.
1040 * gap character to use for insertions
1042 * remove hidden regions from sequences. Note: currently implemented
1043 * in a memory inefficient way - space needed is 2*result set for
1046 * @return SequenceI[]
1048 public SequenceI[] getEditedSequences(char gc, boolean delete)
1050 SeqCigar[] msf = getSequences();
1051 SequenceI[] aln = new SequenceI[msf.length];
1052 for (int i = 0, j = msf.length; i < j; i++)
1054 aln[i] = msf[i].getSeq(gc);
1058 String[] sqs = getSequenceStrings(gc);
1059 for (int i = 0; i < sqs.length; i++)
1061 aln[i].setSequence(sqs[i]);
1068 public static void summariseAlignmentView(AlignmentView view,
1071 os.print("View has " + view.sequences.length + " of which ");
1072 if (view.selected == null)
1078 os.print(" " + view.selected.size());
1080 os.println(" are selected.");
1081 os.print("View is " + view.getWidth() + " columns wide");
1083 int[] contigs = view.getContigs();
1084 if (contigs != null)
1086 viswid = view.width;
1087 for (int i = 0; i < contigs.length; i += 3)
1089 viswid += contigs[i + 2];
1091 os.println("with " + viswid + " visible columns spread over "
1092 + contigs.length / 3 + " regions.");
1096 viswid = view.width;
1099 if (view.scGroups != null)
1101 os.println("There are " + view.scGroups.size()
1102 + " groups defined on the view.");
1103 for (int g = 0; g < view.scGroups.size(); g++)
1105 ScGroup sgr = view.scGroups.get(g);
1106 os.println("Group " + g + ": Name = " + sgr.sg.getName()
1107 + " Contains " + sgr.seqs.size() + " Seqs.");
1108 os.println("This group runs from " + sgr.sg.getStartRes() + " to "
1109 + sgr.sg.getEndRes());
1110 for (int s = 0; s < sgr.seqs.size(); s++)
1112 // JBPnote this should be a unit test for ScGroup
1113 if (!sgr.seqs.get(s).isMemberOf(sgr))
1115 os.println("** WARNING: sequence " + sgr.seqs.get(s).toString()
1116 + " is not marked as member of group.");
1120 AlignmentI visal = view.getVisibleAlignment('-');
1123 os.println("Vis. alignment is " + visal.getWidth()
1124 + " wide and has " + visal.getHeight() + " seqs.");
1125 if (visal.getGroups() != null && visal.getGroups().size() > 0)
1129 for (SequenceGroup sg : visal.getGroups())
1131 os.println("Group " + (i++) + " begins at column "
1132 + sg.getStartRes() + " and ends at " + sg.getEndRes());
1139 public static void testSelectionViews(AlignmentI alignment,
1140 HiddenColumns hidden, SequenceGroup selection)
1142 System.out.println("Testing standard view creation:\n");
1143 AlignmentView view = null;
1147 "View with no hidden columns, no limit to selection, no groups to be collected:");
1148 view = new AlignmentView(alignment, hidden, selection, false, false,
1150 summariseAlignmentView(view, System.out);
1152 } catch (Exception e)
1154 e.printStackTrace();
1156 "Failed to generate alignment with selection but no groups marked.");
1161 "View with no hidden columns, no limit to selection, and all groups to be collected:");
1162 view = new AlignmentView(alignment, hidden, selection, false, false,
1164 summariseAlignmentView(view, System.out);
1165 } catch (Exception e)
1167 e.printStackTrace();
1169 "Failed to generate alignment with selection marked but no groups marked.");
1174 "View with no hidden columns, limited to selection and no groups to be collected:");
1175 view = new AlignmentView(alignment, hidden, selection, false, true,
1177 summariseAlignmentView(view, System.out);
1178 } catch (Exception e)
1180 e.printStackTrace();
1182 "Failed to generate alignment with selection restricted but no groups marked.");
1187 "View with no hidden columns, limited to selection, and all groups to be collected:");
1188 view = new AlignmentView(alignment, hidden, selection, false, true,
1190 summariseAlignmentView(view, System.out);
1191 } catch (Exception e)
1193 e.printStackTrace();
1195 "Failed to generate alignment with selection restricted and groups marked.");
1200 "View *with* hidden columns, no limit to selection, no groups to be collected:");
1201 view = new AlignmentView(alignment, hidden, selection, true, false,
1203 summariseAlignmentView(view, System.out);
1204 } catch (Exception e)
1206 e.printStackTrace();
1208 "Failed to generate alignment with selection but no groups marked.");
1213 "View *with* hidden columns, no limit to selection, and all groups to be collected:");
1214 view = new AlignmentView(alignment, hidden, selection, true, false,
1216 summariseAlignmentView(view, System.out);
1217 } catch (Exception e)
1219 e.printStackTrace();
1221 "Failed to generate alignment with selection marked but no groups marked.");
1226 "View *with* hidden columns, limited to selection and no groups to be collected:");
1227 view = new AlignmentView(alignment, hidden, selection, true, true,
1229 summariseAlignmentView(view, System.out);
1230 } catch (Exception e)
1232 e.printStackTrace();
1234 "Failed to generate alignment with selection restricted but no groups marked.");
1239 "View *with* hidden columns, limited to selection, and all groups to be collected:");
1240 view = new AlignmentView(alignment, hidden, selection, true, true,
1242 summariseAlignmentView(view, System.out);
1243 } catch (Exception e)
1245 e.printStackTrace();
1247 "Failed to generate alignment with selection restricted and groups marked.");
1253 * return pruned visible sequences in each group in alignment view
1258 public Collection<? extends AnnotatedCollectionI> getVisibleGroups(char c)
1260 ArrayList<SequenceGroup> groups = new ArrayList<>();
1261 for (ScGroup sc : scGroups)
1263 SequenceGroup sg = sc.getNewSequenceGroup(c);