|
NeoBio API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--neobio.alignment.CharSequence
This class implements a sequence of characters stored as an array that provides random access to any position in constant time.
The input can come from any source, provided it is encapsulated in a proper
Reader
instance. The stream is expected to be ready (i.e. the next
read
operation must return the first character of the sequence) and it is
not closed when its end is reached, so the client is allowed to reset it and maybe use
it for another purpose.
Sequences can contain letters only although lines started with the
COMMENT_CHAR
character ('>') are regarded as comments and are completely
skipped. White spaces (including tabs, line feeds and carriage returns) are also
ignored throughout.
This class is used by two sequence alignment algorithms: SmithWaterman and NeedlemanWunsch.
SmithWaterman
,
NeedlemanWunsch
Field Summary | |
protected static char |
COMMENT_CHAR
The character used to start a comment line in a sequence file. |
protected char[] |
sequence
Stores the sequence as an array of characters. |
Constructor Summary | |
CharSequence(java.io.Reader reader)
Creates a new instance of a CharSequence , loading the sequence data
from the Reader input stream. |
Method Summary | |
char |
charAt(int pos)
Returns the character at a given position. |
int |
length()
Returns the number of characters of this sequence. |
java.lang.String |
toString()
Returns a string representation of the sequence. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final char COMMENT_CHAR
protected char[] sequence
Constructor Detail |
public CharSequence(java.io.Reader reader) throws java.io.IOException, InvalidSequenceException
CharSequence
, loading the sequence data
from the Reader
input stream.
reader
- source of characters for this sequence
java.io.IOException
- if an I/O exception occurs when reading the input
InvalidSequenceException
- if the input does not contain a valid sequenceMethod Detail |
public int length()
public char charAt(int pos)
length()
. This
is convinient for sequence alignment algorithms based on a classic dynamic
programming matrix since the sequences usually start at row/column 1. This method
does not check boundaries, therefore an ArrayIndexOutOfBoundsException
may be raised if pos
is out of bounds.
pos
- position of character (from 1 to length()
inclusive)
public java.lang.String toString()
toString
in class java.lang.Object
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |