uk.ac.man.bioinf.analysis.consensus
Class DefaultConsensusSequence

java.lang.Object
  |
  +--uk.ac.man.bioinf.sequence.AbstractSequence
        |
        +--uk.ac.man.bioinf.sequence.AbstractMutableSequence
              |
              +--uk.ac.man.bioinf.sequence.alignment.AbstractGappedSequence
                    |
                    +--uk.ac.man.bioinf.analysis.consensus.DefaultConsensusSequence
All Implemented Interfaces:
AlignmentListener, ConsensusSequence, EventListener, GappedSequence, Identifiable, MutableSequence, Sequence, SequenceEventProvider, SequenceListener
Direct Known Subclasses:
ThreadedConsensusSequence

public class DefaultConsensusSequence
extends AbstractGappedSequence
implements ConsensusSequence, AlignmentListener, SequenceListener

DefaultConsensusSequence.java Created: Thu Jun 15 17:00:04 2000

Version:
$Id: DefaultConsensusSequence.java,v 1.8 2001/04/11 17:04:41 lord Exp $
Author:
Phillip Lord

Constructor Summary
DefaultConsensusSequence(ConsensusCalculator calculator)
           
 
Method Summary
protected  void calcConsensus()
           
 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 deleteGapAtQuietly(int index)
           
 void destroy()
           
protected  void fireChangeEvent()
           
 ConsensusCalculator getConsensusCalculator()
           
 Element getElementAt(int index)
          Returns an element at a given location.
 Element getGappedElementAt(int index)
           
 int getGappedLength()
          Returns the gapped length of this sequence.
 int getGappedPositionOf(int index)
          Translate between the gapped index, and the ungapped index
 Element[] getGappedSequenceAsElements()
           
 GappedSequence getGappedSubSequence(int start, int length)
           
 Identifier getIdentifier()
           
 int getLength()
          Returns the length of the sequence.
 Element[] getSequenceAsElements()
          Returns the sequence as an array of elements.
 int getUngappedPositionOf(int index)
          Translate between the gapped position and the ungapped position.
 void insertGapAtQuietly(int index)
           
protected  void installAlignmentListeners(ConsensusCalculator cons)
           
protected  void installVetoListeners()
           
 void setConsensusCalculator(ConsensusCalculator calculator)
           
protected  void uninstallAlignmentListners(ConsensusCalculator cons)
           
protected  void validate()
           
 
Methods inherited from class uk.ac.man.bioinf.sequence.alignment.AbstractGappedSequence
checkGappedRange, checkGappedRangeForInsert, deleteGapAt, deleteGapAt, getGappedElementAtAsChar, getGappedSequenceAsChars, getGappedSequenceIndexException, insertGapAt, insertGapAt
 
Methods inherited from class uk.ac.man.bioinf.sequence.AbstractMutableSequence
addSequenceListener, addVetoableSequenceListener, fireSequenceEvent, fireVetoableSequenceEvent, hasListeners, removeSequenceListener, removeVetoableSequenceListener
 
Methods inherited from class uk.ac.man.bioinf.sequence.AbstractSequence
checkRange, checkSequenceType, checkSequenceType, getElementAtAsChar, getSequenceAsChars, getSequenceIndexException, getSequenceType, getSequenceTypeException, getSubSequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.man.bioinf.sequence.alignment.GappedSequence
deleteGapAt, deleteGapAt, getGappedElementAtAsChar, getGappedSequenceAsChars, insertGapAt, insertGapAt
 
Methods inherited from interface uk.ac.man.bioinf.sequence.Sequence
getElementAtAsChar, getSequenceAsChars, getSequenceType, getSubSequence
 
Methods inherited from interface uk.ac.man.bioinf.sequence.event.SequenceEventProvider
addSequenceListener, addVetoableSequenceListener, removeSequenceListener, removeVetoableSequenceListener
 

Constructor Detail

DefaultConsensusSequence

public DefaultConsensusSequence(ConsensusCalculator calculator)
Method Detail

installVetoListeners

protected void installVetoListeners()

installAlignmentListeners

protected void installAlignmentListeners(ConsensusCalculator cons)

uninstallAlignmentListners

protected void uninstallAlignmentListners(ConsensusCalculator cons)

validate

protected void validate()

fireChangeEvent

protected void fireChangeEvent()

calcConsensus

protected void calcConsensus()

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 -

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

getElementAt

public Element getElementAt(int index)
Description copied from interface: Sequence
Returns an element at a given location.

Specified by:
getElementAt in interface Sequence
Parameters:
index - the location of the target element
Returns:
the element

getGappedElementAt

public Element getGappedElementAt(int index)
Specified by:
getGappedElementAt in interface GappedSequence

getGappedLength

public int getGappedLength()
Description copied from interface: GappedSequence
Returns the gapped length of this sequence. That is the length of the sequence including its gaps. Conversely this means that the getLength method of the Sequence interface returns the length of the sequence ignoring the gaps.

Specified by:
getGappedLength in interface GappedSequence
Returns:
the length

getGappedPositionOf

public int getGappedPositionOf(int index)
Description copied from interface: GappedSequence
Translate between the gapped index, and the ungapped index

Specified by:
getGappedPositionOf in interface GappedSequence
Parameters:
index - the ungapped position
Returns:
the gapped position of the equivalent element

getGappedSequenceAsElements

public Element[] getGappedSequenceAsElements()
Specified by:
getGappedSequenceAsElements in interface GappedSequence

getGappedSubSequence

public GappedSequence getGappedSubSequence(int start,
                                           int length)
Specified by:
getGappedSubSequence in interface GappedSequence

getUngappedPositionOf

public int getUngappedPositionOf(int index)
Description copied from interface: GappedSequence
Translate between the gapped position and the ungapped position. I havent quite decided what to do at the moment if the index refers to a gap. One idea is to throw a NoSuchSequenceElementException which makes a certain amount of sense but isnt really that useful. Perhaps a better idea is to run -(insertion-point) where the insertion point is the nearest element before the current requested position which is not a gap. That way a value less than 0 would indicate a gap and would also return a useful value

Specified by:
getUngappedPositionOf in interface GappedSequence
Parameters:
index -
Returns:

getLength

public int getLength()
Description copied from interface: Sequence
Returns the length of the sequence.

Specified by:
getLength in interface Sequence
Returns:
the length of the sequence

getSequenceAsElements

public Element[] getSequenceAsElements()
Description copied from interface: Sequence
Returns the sequence as an array of elements.

Specified by:
getSequenceAsElements in interface Sequence
Returns:
the sequence

getIdentifier

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

setConsensusCalculator

public void setConsensusCalculator(ConsensusCalculator calculator)
Specified by:
setConsensusCalculator in interface ConsensusSequence

getConsensusCalculator

public ConsensusCalculator getConsensusCalculator()
Specified by:
getConsensusCalculator in interface ConsensusSequence

deleteGapAtQuietly

public void deleteGapAtQuietly(int index)
Specified by:
deleteGapAtQuietly in class AbstractGappedSequence

insertGapAtQuietly

public void insertGapAtQuietly(int index)
Specified by:
insertGapAtQuietly in class AbstractGappedSequence

destroy

public void destroy()
Specified by:
destroy in interface ConsensusSequence