uk.ac.man.bioinf.sequence.group
Class GroupSequenceAlignment

java.lang.Object
  |
  +--uk.ac.man.bioinf.sequence.group.AbstractGappedSequenceGroup
        |
        +--uk.ac.man.bioinf.sequence.group.GroupSequenceAlignment
All Implemented Interfaces:
AlignmentEventProvider, AlignmentListener, EventListener, GappedSequenceGroup, Identifiable, SequenceAlignment, SequenceEventProvider, SequenceGroup, SequenceListener, VetoableSequenceListener
Direct Known Subclasses:
CinemaGroup

public class GroupSequenceAlignment
extends AbstractGappedSequenceGroup
implements SequenceAlignment, AlignmentListener

GroupSequenceAlignment.java This is a sequence group which also reflects a sequence alignment. The sequences will be given out in the same order, as they are in the SequenceAlignment. A given group is linked specifically to a single SequenceAlignment. If sequences are removed from the SequenceAlignment then they are automatically removed from this class. Created: Thu Jun 1 23:20:37 2000

Version:
$Id: GroupSequenceAlignment.java,v 1.9 2001/04/11 17:04:43 lord Exp $
Author:
Phillip Lord

Constructor Summary
GroupSequenceAlignment(SequenceAlignment alignment)
          Start an empty sequence group associated with the given sequence alignment.
GroupSequenceAlignment(SequenceAlignment alignment, IntArrayList seqArray)
          Starts an Sequence group with the sequences given in the IntArrayList
 
Method Summary
 void addAlignmentListener(AlignmentListener listener)
          Add a listener specifically interested in events connected with the MSA.
 void addSequence(GappedSequence seq, int inset)
          Adds a sequence to the current alignment.
 void addSequenceListener(SequenceListener listener)
          Adds the specified sequence listener.
 void addSequenceToGroup(Sequence sequence)
          Adds a sequence to this group.
 void addVetoableAlignmentListener(VetoableAlignmentListener listener)
          Adds a listener interested in vetoing multiple sequence alignment specific events.
 void addVetoableSequenceListener(VetoableSequenceListener listener)
          Adds the specified vetoable sequence listener.
 void changeOccurred(AlignmentEvent event)
          method signalled after a change has occured to a multiple alignment
 void changeOccurred(SequenceEvent event)
          Method called when a change occurs
 void clearSequences()
          Empty the group of sequences
 boolean containsSequence(Sequence sequence)
          Does this group contain the sequence
 Identifier getIdentifier()
           
 int getInset(int index)
          Returns the inset of sequence within the alignment.
 int getLength()
          Returns the length of the alignment (i.e: the longest sequence).
 int getNumberSequences()
          Returns the total number of sequences in the alignment.
 GappedSequence getSequenceAt(int index)
          Provides the sequence at a particular location in the alignment.
 int getSequenceIndex(GappedSequence sequence)
          Returns the index in the alignment of a provided sequence.
 Sequence[] getSequences()
          Get all the sequences in this group.
 SequenceType getSequenceType()
          Returns the sequence type of the alignment (e.g: protein sequences).
 SequenceAlignment getSubAlignment(int startPos, int endPos, int startSeq, int endSeq)
          Returns a sub-alignment, given the exact location in this alignment.
 SequenceAlignment getSubAlignment(SequenceAlignmentRectangle rect)
           
 Iterator iterator()
          Returns an iterator of all the sequences.
 void removeAlignmentListener(AlignmentListener listener)
          Removes a multiple sequence alignment listener.
 GappedSequence removeSequence(int seqIndex)
          Removes a sequence from the alignment.
 void removeSequenceFromGroup(Sequence sequence)
          Removes a sequence from this group
 void removeSequenceListener(SequenceListener listener)
          Removes the specified sequence listener.
 void removeVetoableAlignmentListener(VetoableAlignmentListener listener)
          Removes a vetoable multiple sequence alignment listener.
 void removeVetoableSequenceListener(VetoableSequenceListener listener)
          Removes the specified vetoable sequence listener.
 void setInset(int seqIndex, int size)
          Sets the inset of a sequence within the alignment.
 void vetoableChangeOccurred(VetoableAlignmentEvent event)
           
 void vetoableChangeOccurred(VetoableSequenceEvent event)
          Method signalled before a prospective change occurs
 
Methods inherited from class uk.ac.man.bioinf.sequence.group.AbstractGappedSequenceGroup
getGappedSequences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupSequenceAlignment

public GroupSequenceAlignment(SequenceAlignment alignment)
Start an empty sequence group associated with the given sequence alignment.

Parameters:
alignment - the alignment

GroupSequenceAlignment

public GroupSequenceAlignment(SequenceAlignment alignment,
                              IntArrayList seqArray)
Starts an Sequence group with the sequences given in the IntArrayList

Parameters:
alignment -
seqArray -
Method Detail

getSequences

public Sequence[] getSequences()
Description copied from interface: SequenceGroup
Get all the sequences in this group.

Specified by:
getSequences in interface SequenceGroup
Returns:

addSequenceToGroup

public void addSequenceToGroup(Sequence sequence)
Adds a sequence to this group.

Specified by:
addSequenceToGroup in interface SequenceGroup
Parameters:
sequence - the sequence
Throws:
IllegalArgumentException - if this sequence is not part of the associated SequenceAlignment

addSequence

public void addSequence(GappedSequence seq,
                        int inset)
                 throws AlignmentVetoException
Description copied from interface: SequenceAlignment
Adds a sequence to the current alignment. If listeners are listening to the alignment, they will be able to veto the add (thats the idea atleast).

Specified by:
addSequence in interface SequenceAlignment
Parameters:
seq - the sequence to be added
inset - the sequence inset
AlignmentVetoException

getLength

public int getLength()
Description copied from interface: SequenceAlignment
Returns the length of the alignment (i.e: the longest sequence).

Specified by:
getLength in interface SequenceAlignment
Returns:
length of alignment

removeSequenceFromGroup

public void removeSequenceFromGroup(Sequence sequence)
Description copied from interface: SequenceGroup
Removes a sequence from this group

Specified by:
removeSequenceFromGroup in interface SequenceGroup
Parameters:
sequence - the sequence

removeSequence

public GappedSequence removeSequence(int seqIndex)
                              throws AlignmentVetoException
Description copied from interface: SequenceAlignment
Removes a sequence from the alignment. It requires the knowledge of the sequence location in the alignment.

Specified by:
removeSequence in interface SequenceAlignment
Parameters:
seqIndex - the index of the sequence
Returns:
the sequence
AlignmentVetoException

setInset

public void setInset(int seqIndex,
                     int size)
              throws AlignmentVetoException
Description copied from interface: SequenceAlignment
Sets the inset of a sequence within the alignment. An inset of zero will mean that the first element starts at the left most position of the alignment.

Special N.B.: This was put into the interface because it was felt that there would not be any instances when you would not wish to do this (apart from a read-only alignment, in which case there are ways and means).

Specified by:
setInset in interface SequenceAlignment
Parameters:
seqIndex - the index of the sequence
size - the size of the inset
AlignmentVetoException

clearSequences

public void clearSequences()
Description copied from interface: SequenceGroup
Empty the group of sequences

Specified by:
clearSequences in interface SequenceGroup

getNumberSequences

public int getNumberSequences()
Description copied from interface: SequenceAlignment
Returns the total number of sequences in the alignment.

Specified by:
getNumberSequences in interface SequenceAlignment
Returns:
the number of sequences

containsSequence

public boolean containsSequence(Sequence sequence)
Description copied from interface: SequenceGroup
Does this group contain the sequence

Specified by:
containsSequence in interface SequenceGroup
Parameters:
sequence - the sequence
Returns:
true if containined

iterator

public Iterator iterator()
Description copied from interface: SequenceGroup
Returns an iterator of all the sequences. This should be fail fast if the group is modified whilst the iterator is being used.

Specified by:
iterator in interface SequenceGroup
Returns:

getSequenceAt

public GappedSequence getSequenceAt(int index)
Description copied from interface: SequenceAlignment
Provides the sequence at a particular location in the alignment. The indexing STARTS AT 1, and not 0.

Specified by:
getSequenceAt in interface SequenceAlignment
Parameters:
index - the index of the target sequence
Returns:
the sequence of interest

getSubAlignment

public SequenceAlignment getSubAlignment(int startPos,
                                         int endPos,
                                         int startSeq,
                                         int endSeq)
Description copied from interface: SequenceAlignment
Returns a sub-alignment, given the exact location in this alignment.

Specified by:
getSubAlignment in interface SequenceAlignment
Parameters:
startPos - the start position for the sub-alignment (i.e: x1)
endPos - the length of the sub alignment
startSeq - the first sequence in the current alignment to be included in the sub-alignment (i.e: y1)
Returns:
the sub-alignment

getSubAlignment

public SequenceAlignment getSubAlignment(SequenceAlignmentRectangle rect)
Specified by:
getSubAlignment in interface SequenceAlignment

getSequenceType

public SequenceType getSequenceType()
Description copied from interface: SequenceAlignment
Returns the sequence type of the alignment (e.g: protein sequences).

Specified by:
getSequenceType in interface SequenceAlignment
Returns:
the sequence type

getInset

public int getInset(int index)
Description copied from interface: SequenceAlignment
Returns the inset of sequence within the alignment. A inset of 0 means that the first element means that the Sequence starts at the left most position of the alignment

Specified by:
getInset in interface SequenceAlignment
Parameters:
index - the sequence index
Returns:
the inset or preceeding number of gaps

getSequenceIndex

public int getSequenceIndex(GappedSequence sequence)
Description copied from interface: SequenceAlignment
Returns the index in the alignment of a provided sequence.

Specified by:
getSequenceIndex in interface SequenceAlignment
Parameters:
sequence - the query sequence
Returns:
the index of the sequence, or -1 if not found

removeAlignmentListener

public void removeAlignmentListener(AlignmentListener listener)
Description copied from interface: AlignmentEventProvider
Removes a multiple sequence alignment listener.

Specified by:
removeAlignmentListener in interface AlignmentEventProvider
Parameters:
listener - the listener to be removed

addAlignmentListener

public void addAlignmentListener(AlignmentListener listener)
Description copied from interface: AlignmentEventProvider
Add a listener specifically interested in events connected with the MSA.

Specified by:
addAlignmentListener in interface AlignmentEventProvider
Parameters:
listener - a multiple sequence alignment listener

removeVetoableAlignmentListener

public void removeVetoableAlignmentListener(VetoableAlignmentListener listener)
Description copied from interface: AlignmentEventProvider
Removes a vetoable multiple sequence alignment listener.

Specified by:
removeVetoableAlignmentListener in interface AlignmentEventProvider
Parameters:
listener - the listener to be removed

addVetoableAlignmentListener

public void addVetoableAlignmentListener(VetoableAlignmentListener listener)
Description copied from interface: AlignmentEventProvider
Adds a listener interested in vetoing multiple sequence alignment specific events.

Specified by:
addVetoableAlignmentListener in interface AlignmentEventProvider
Parameters:
listener - a vetoable multiple sequence alignment listener

changeOccurred

public void changeOccurred(SequenceEvent event)
Description copied from interface: SequenceListener
Method called when a change occurs

Specified by:
changeOccurred in interface SequenceListener
Parameters:
event -

vetoableChangeOccurred

public void vetoableChangeOccurred(VetoableSequenceEvent event)
                            throws SequenceVetoException
Description copied from interface: VetoableSequenceListener
Method signalled before a prospective change occurs

Specified by:
vetoableChangeOccurred in interface VetoableSequenceListener
Parameters:
event - the event
Throws:
SequenceVetoException - if the listener does not wish the event to occur.

changeOccurred

public void changeOccurred(AlignmentEvent event)
Description copied from interface: AlignmentListener
method signalled after a change has occured to a multiple alignment

Specified by:
changeOccurred in interface AlignmentListener
Parameters:
event - the event type

vetoableChangeOccurred

public void vetoableChangeOccurred(VetoableAlignmentEvent event)
                            throws AlignmentVetoException
AlignmentVetoException

addSequenceListener

public void addSequenceListener(SequenceListener listener)
Description copied from interface: SequenceEventProvider
Adds the specified sequence listener.

Specified by:
addSequenceListener in interface SequenceEventProvider
Parameters:
listener - the sequence listener

removeSequenceListener

public void removeSequenceListener(SequenceListener listener)
Description copied from interface: SequenceEventProvider
Removes the specified sequence listener.

Specified by:
removeSequenceListener in interface SequenceEventProvider
Parameters:
listener - the sequence listener

addVetoableSequenceListener

public void addVetoableSequenceListener(VetoableSequenceListener listener)
Description copied from interface: SequenceEventProvider
Adds the specified vetoable sequence listener.

Specified by:
addVetoableSequenceListener in interface SequenceEventProvider
Parameters:
listener - the vetoable sequence listener

removeVetoableSequenceListener

public void removeVetoableSequenceListener(VetoableSequenceListener listener)
Description copied from interface: SequenceEventProvider
Removes the specified vetoable sequence listener.

Specified by:
removeVetoableSequenceListener in interface SequenceEventProvider
Parameters:
listener - the vetoable sequence listener

getIdentifier

public Identifier getIdentifier()
Specified by:
getIdentifier in interface Identifiable