uk.ac.man.bioinf.sequence.complex
Class DefaultGappedComplexSequence

java.lang.Object
  |
  +--uk.ac.man.bioinf.sequence.AbstractSequence
        |
        +--uk.ac.man.bioinf.sequence.AbstractMutableSequence
              |
              +--uk.ac.man.bioinf.sequence.complex.AbstractComplexSequence
                    |
                    +--uk.ac.man.bioinf.sequence.complex.DefaultGappedComplexSequence
All Implemented Interfaces:
ComplexSequence, GappedComplexSequence, GappedSequence, Identifiable, MutableSequence, Sequence, SequenceEventProvider

public class DefaultGappedComplexSequence
extends AbstractComplexSequence
implements GappedComplexSequence

DefaultGappedComplexSequence.java Created: Tue Dec 5 16:55:11 2000

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

Constructor Summary
DefaultGappedComplexSequence(Element[] elements, ComplexSequenceType type)
           
 
Method Summary
 void deleteGapAt(int param1)
          Delete the element at index.
 void deleteGapAt(int param1, int param2)
          Delete the elements starting at index for the specified length
 ComplexElement getComplexElementAt(int index)
           
 Element getElementAt(int index)
          Returns an element at a given location.
 char getElementAtAsChar(int param1)
          Returns the character of an target element.
 GappedSequence getElementsAsGappedSequence(Element[] param1, SequenceType param2)
           
 GappedSequence getElementsAsGappedSequence(Element[] param1, SequenceType param2, Identifier param3)
           
 Element getGappedElementAt(int index)
           
 char getGappedElementAtAsChar(int param1)
           
 int getGappedLength()
          Returns the gapped length of this sequence.
 int getGappedPositionOf(int param1)
          Translate between the gapped index, and the ungapped index
 char[] getGappedSequenceAsChars()
           
 Element[] getGappedSequenceAsElements()
           
 GappedSequence getGappedSubSequence(int param1, int param2)
           
 Identifier getIdentifier()
           
 int getLength()
          Returns the length of the sequence.
 char[] getSequenceAsChars()
          Returns the sequence as an array of characters.
 ComplexElement[] getSequenceAsComplexElements()
           
 Element[] getSequenceAsElements()
          Returns the sequence as an array of elements.
 Sequence getSubSequence(int param1, int param2)
          Returns a sub-sequence from the current sequence.
 int getUngappedPositionOf(int param1)
          Translate between the gapped position and the ungapped position.
 void insertGapAt(int param1)
           
 void insertGapAt(int param1, int param2)
          Inserts the elements at this position.
protected  ComplexElement setElementAtQuietly(ComplexElement elem, int index)
           
 
Methods inherited from class uk.ac.man.bioinf.sequence.complex.AbstractComplexSequence
addModificationAt, checkComplexSequenceType, checkComplexSequenceType, checkSequenceType, checkSequenceType, getComplexElementAtAsChar, getComplexSequenceAsChars, getComplexSequenceTypeException, getComplexType, removeModificationAt
 
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, getSequenceIndexException, getSequenceType, getSequenceTypeException
 
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.Sequence
getSequenceType
 
Methods inherited from interface uk.ac.man.bioinf.sequence.event.SequenceEventProvider
addSequenceListener, addVetoableSequenceListener, removeSequenceListener, removeVetoableSequenceListener
 
Methods inherited from interface uk.ac.man.bioinf.sequence.complex.ComplexSequence
addModificationAt, getComplexElementAtAsChar, getComplexSequenceAsChars, removeModificationAt
 

Constructor Detail

DefaultGappedComplexSequence

public DefaultGappedComplexSequence(Element[] elements,
                                    ComplexSequenceType type)
Method Detail

getComplexElementAt

public ComplexElement getComplexElementAt(int index)
Specified by:
getComplexElementAt in interface ComplexSequence

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

getSequenceAsComplexElements

public ComplexElement[] getSequenceAsComplexElements()

setElementAtQuietly

protected ComplexElement setElementAtQuietly(ComplexElement elem,
                                             int index)
Specified by:
setElementAtQuietly in class AbstractComplexSequence

getIdentifier

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

getElementsAsGappedSequence

public GappedSequence getElementsAsGappedSequence(Element[] param1,
                                                  SequenceType param2,
                                                  Identifier param3)

getElementsAsGappedSequence

public GappedSequence getElementsAsGappedSequence(Element[] param1,
                                                  SequenceType param2)

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

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

getGappedSubSequence

public GappedSequence getGappedSubSequence(int param1,
                                           int param2)
Specified by:
getGappedSubSequence in interface GappedSequence

getGappedSequenceAsElements

public Element[] getGappedSequenceAsElements()
Specified by:
getGappedSequenceAsElements 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 param1)
Description copied from interface: GappedSequence
Translate between the gapped index, and the ungapped index

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

getUngappedPositionOf

public int getUngappedPositionOf(int param1)
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:
param1 -
Returns:

insertGapAt

public void insertGapAt(int param1)
                 throws SequenceVetoException
Specified by:
insertGapAt in interface GappedSequence
SequenceVetoException

insertGapAt

public void insertGapAt(int param1,
                        int param2)
                 throws SequenceVetoException
Description copied from interface: GappedSequence
Inserts the elements at this position. If the index is one longer than the length of the sequence the sequence will be extended.

Specified by:
insertGapAt in interface GappedSequence
Parameters:
param1 - the index at which to insert
SequenceVetoException

deleteGapAt

public void deleteGapAt(int param1)
                 throws SequenceVetoException
Description copied from interface: GappedSequence
Delete the element at index.

Specified by:
deleteGapAt in interface GappedSequence
Parameters:
param1 - the index to delete
Returns:
the element which has just been deleted
SequenceVetoException

deleteGapAt

public void deleteGapAt(int param1,
                        int param2)
                 throws SequenceVetoException
Description copied from interface: GappedSequence
Delete the elements starting at index for the specified length

Specified by:
deleteGapAt in interface GappedSequence
Parameters:
param1 - the index to start at
param2 - the length to delete
Returns:
the elements just deleted
SequenceVetoException

getGappedElementAtAsChar

public char getGappedElementAtAsChar(int param1)
Specified by:
getGappedElementAtAsChar in interface GappedSequence

getGappedSequenceAsChars

public char[] getGappedSequenceAsChars()
Specified by:
getGappedSequenceAsChars in interface GappedSequence

getSubSequence

public Sequence getSubSequence(int param1,
                               int param2)
Description copied from interface: Sequence
Returns a sub-sequence from the current sequence.

Specified by:
getSubSequence in interface Sequence
Overrides:
getSubSequence in class AbstractSequence
Parameters:
param1 - the initial index of the sub-sequence
Returns:
the sub-sequence

getSequenceAsChars

public char[] getSequenceAsChars()
Description copied from interface: Sequence
Returns the sequence as an array of characters.

Specified by:
getSequenceAsChars in interface Sequence
Overrides:
getSequenceAsChars in class AbstractSequence
Returns:
the sequence

getElementAtAsChar

public char getElementAtAsChar(int param1)
Description copied from interface: Sequence
Returns the character of an target element.

Specified by:
getElementAtAsChar in interface Sequence
Overrides:
getElementAtAsChar in class AbstractSequence
Parameters:
param1 - the location of the target element
Returns:
the element character