org.biojava.bio.symbol
Interface SymbolList

All Known Subinterfaces:
Alignment, Sequence, StatePath
All Known Implementing Classes:
AbstractSymbolList, SymbolList.EmptySymbolList, TranslatedSymbolList, SymbolListAdapter

public interface SymbolList

A sequence of symbols that belong to an alphabet.

This uses biological coordinates (1 to length).

Author:
Matthew Pocock

Inner Class Summary
static class SymbolList.EmptySymbolList
          The empty immutable implementation.
 
Field Summary
static SymbolList EMPTY_LIST
          A useful object that represents an empty symbol list, to avoid returning null.
 
Method Summary
 Alphabet getAlphabet()
          The alphabet that this SymbolList is over.
 java.util.Iterator iterator()
          An Iterator over all Symbols in this SymbolList.
 int length()
          The number of symbols in this SymbolList.
 java.lang.String seqString()
          Stringify this symbol list.
 SymbolList subList(int start, int end)
          Return a new SymbolList for the symbols start to end inclusive.
 java.lang.String subStr(int start, int end)
          Return a region of this symbol list as a String.
 Symbol symbolAt(int index)
          Return the symbol at index, counting from 1.
 java.util.List toList()
          Returns a List of symbols.
 

Field Detail

EMPTY_LIST

public static final SymbolList EMPTY_LIST
A useful object that represents an empty symbol list, to avoid returning null.
Method Detail

getAlphabet

public Alphabet getAlphabet()
The alphabet that this SymbolList is over.

Every symbol within this SymbolList is a member of this alphabet. alphabet.contains(symbol) == true for each symbol that is within this sequence.

Returns:
the alphabet

length

public int length()
The number of symbols in this SymbolList.
Returns:
the length

symbolAt

public Symbol symbolAt(int index)
                throws java.lang.IndexOutOfBoundsException
Return the symbol at index, counting from 1.
Parameters:
index - the ofset into this SymbolList
Returns:
the Symbol at that index
Throws:
java.lang.IndexOutOfBoundsException - if index is less than 1, or greater than the length of the symbol list

toList

public java.util.List toList()
Returns a List of symbols.

This is an immutable list of symbols. Do not edit it.

Returns:
a List of Symbols

iterator

public java.util.Iterator iterator()
An Iterator over all Symbols in this SymbolList.

This is an ordered iterator over the Symbols. It cannot be used to edit the underlying symbols.

Returns:
an iterator

subList

public SymbolList subList(int start,
                          int end)
                   throws java.lang.IndexOutOfBoundsException
Return a new SymbolList for the symbols start to end inclusive.

The resulting SymbolList will count from 1 to (end-start + 1) inclusive, and refer to the symbols start to end of the original sequence.

Parameters:
start - the first symbol of the new SymbolList
end - the last symbol (inclusive) of the new SymbolList

seqString

public java.lang.String seqString()
Stringify this symbol list.

It is expected that this will use the symbol's token to render each symbol. It should be parsable back into a SymbolList using the default token parser for this alphabet.

Returns:
a string representation of the symbol list

subStr

public java.lang.String subStr(int start,
                               int end)
                        throws java.lang.IndexOutOfBoundsException
Return a region of this symbol list as a String.

This should use the same rules as seqString.

Parameters:
start - the first symbol to include
end - the last symbol to include
Returns:
the string representation
Throws:
java.lang.IndexOutOfBoundsException - if either start or end are not within the sequence