import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
/**
* Transient object compactly representing a 'view' of an alignment - with
*/
private class ScGroup
{
- public Vector seqs;
+ public List<SeqCigar> seqs;
public SequenceGroup sg;
ScGroup()
{
- seqs = new Vector();
+ seqs = new ArrayList<SeqCigar>();
+ }
+
+ /**
+ * @param seq
+ * @return true if seq was not a member before and was added to group
+ */
+ public boolean add(SeqCigar seq)
+ {
+ if (!seq.isMemberOf(this))
+ {
+ seqs.add(seq);
+ seq.setGroupMembership(this);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param seq
+ * @return true if seq was a member and was removed from group
+ */
+ public boolean remove(SeqCigar seq)
+ {
+ if (seq.removeGroupMembership(this))
+ {
+ seqs.remove(seq);
+ return true;
+ }
+ return false;
+ }
+
+ public int size()
+ {
+ return seqs.size();
}
}
* vector of selected seqCigars. This vector is also referenced by each
* seqCigar contained in it.
*/
- private Vector selected;
+ private ScGroup selected;
/**
* Construct an alignmentView from a live jalview alignment view. Note -
if (selection != null && selection.getSize() > 0)
{
List<SequenceI> sel = selection.getSequences(null);
- this.selected = new Vector();
+ this.selected = new ScGroup();
selseqs = selection
.getSequencesInOrder(alignment, selectedRegionOnly);
}
if (selection != null && selection.getSize() > 0
&& !selectedRegionOnly)
{
- sequences[csi].setGroupMembership(selected);
- selected.addElement(sequences[csi]);
+ selected.add(sequences[csi]);
}
if (seqsets != null)
{
{
if ((seqsets.get(sg)).contains(selseqs[i]))
{
- sequences[csi].setGroupMembership(sgrps[sg]);
sgrps[sg].sg.deleteSequence(selseqs[i], false);
- sgrps[sg].seqs.addElement(sequences[csi]);
+ sgrps[sg].add(sequences[csi]);
if (!addedgps[sg])
{
if (scGroups == null)
+ sgr.sg.getEndRes());
for (int s = 0; s < sgr.seqs.size(); s++)
{
- if (!((SeqCigar) sgr.seqs.elementAt(s)).isMemberOf(sgr))
+ // JBPnote this should be a unit test for ScGroup
+ if (!sgr.seqs.get(s).isMemberOf(sgr))
{
- os.println("** WARNING: sequence "
- + ((SeqCigar) sgr.seqs.elementAt(s)).toString()
+ os.println("** WARNING: sequence " + sgr.seqs.get(s).toString()
+ " is not marked as member of group.");
}
}