+ public static void summariseAlignmentView(AlignmentView view,
+ PrintStream os)
+ {
+ os.print("View has " + view.sequences.length + " of which ");
+ if (view.selected == null)
+ {
+ os.print("None");
+ }
+ else
+ {
+ os.print(" " + view.selected.size());
+ }
+ os.println(" are selected.");
+ os.print("View is " + view.getWidth() + " columns wide");
+ int viswid = 0;
+ int[] contigs = view.getContigs();
+ if (contigs != null)
+ {
+ viswid = view.width;
+ for (int i = 0; i < contigs.length; i += 3)
+ {
+ viswid += contigs[i + 2];
+ }
+ os.println("with " + viswid + " visible columns spread over "
+ + contigs.length / 3 + " regions.");
+ }
+ else
+ {
+ viswid = view.width;
+ os.println(".");
+ }
+ if (view.scGroups != null)
+ {
+ os.println("There are " + view.scGroups.size()
+ + " groups defined on the view.");
+ for (int g = 0; g < view.scGroups.size(); g++)
+ {
+ ScGroup sgr = view.scGroups.get(g);
+ os.println("Group " + g + ": Name = " + sgr.sg.getName()
+ + " Contains " + sgr.seqs.size() + " Seqs.");
+ os.println("This group runs from " + sgr.sg.getStartRes() + " to "
+ + sgr.sg.getEndRes());
+ for (int s = 0; s < sgr.seqs.size(); s++)
+ {
+ // JBPnote this should be a unit test for ScGroup
+ if (!sgr.seqs.get(s).isMemberOf(sgr))
+ {
+ os.println("** WARNING: sequence " + sgr.seqs.get(s).toString()
+ + " is not marked as member of group.");
+ }
+ }
+ }
+ AlignmentI visal = view.getVisibleAlignment('-');
+ if (visal != null)
+ {
+ os.println("Vis. alignment is " + visal.getWidth()
+ + " wide and has " + visal.getHeight() + " seqs.");
+ if (visal.getGroups() != null && visal.getGroups().size() > 0)
+ {
+
+ int i = 1;
+ for (SequenceGroup sg : visal.getGroups())
+ {
+ os.println("Group " + (i++) + " begins at column "
+ + sg.getStartRes() + " and ends at " + sg.getEndRes());
+ }
+ }
+ }
+ }
+ }
+
+ public static void testSelectionViews(AlignmentI alignment,
+ HiddenColumns hidden, SequenceGroup selection)
+ {
+ System.out.println("Testing standard view creation:\n");
+ AlignmentView view = null;
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+ try
+ {
+ 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.");
+ }
+
+ }