|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava.utils.AbstractChangeable
org.biojava.bio.symbol.AbstractSymbolList
org.biojava.bio.symbol.SimpleSymbolList
public class SimpleSymbolList
Basic implementation of SymbolList. This is currently backed by a normal Java array.
SimpleSymbolList is now editable. edit() has been implemented in a way that edits are relatively inefficient, but symbolAt() is very efficient.
A new constructor SimpleSymbolList(SymbolParser,String) has been added so you can now simply turn a String into a SymbolList. This is mostly to provide a simple way to create a SymbolList for people just trying to get their feet wet. So here is an example.
String seqString = "gaattc";
FiniteAlphabet dna = (FiniteAlphabet) AlphabetManager.alphabetForName("DNA");
SymbolParser parser = dna.getParser("token");
SymbolList mySl = new SimpleSymbolList (parser,seqString);
System.out.println("Look at my sequence " + mySl.seqString());
with the right parser you should be able to make a protein sequence from the String "AspAlaValIleAsp"
subList() is implemented such that subLists are views of the original until such time as the underlying SymbolList is edited in a way that would modify the subList, at which point the subList gets its own array of Symbols and does not reflect the edit to the original. When subList() is called on another subList (which is a veiw SimpleSymbolList) the new SimpleSymbolList is a view of the original, not the subList.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.biojava.bio.symbol.AbstractSymbolList |
---|
AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslater |
Nested classes/interfaces inherited from interface org.biojava.utils.ChangeListener |
---|
ChangeListener.AlwaysVetoListener, ChangeListener.ChangeEventRecorder, ChangeListener.LoggingListener |
Field Summary |
---|
Fields inherited from interface org.biojava.utils.ChangeListener |
---|
ALWAYS_VETO, LOG_TO_OUT |
Fields inherited from interface org.biojava.bio.symbol.SymbolList |
---|
EDIT, EMPTY_LIST |
Constructor Summary | |
---|---|
SimpleSymbolList(Alphabet alpha)
Construct an empty SimpleSymbolList. |
|
SimpleSymbolList(Alphabet alpha,
java.util.List rList)
Construct a SymbolList containing the symbols in the specified list. |
|
SimpleSymbolList(Symbol[] symbols,
int length,
Alphabet alphabet)
Construct a SimpleSymbolList given the Symbol array that backs it. |
|
SimpleSymbolList(SymbolList sl)
Construct a copy of an existing SymbolList. |
|
SimpleSymbolList(SymbolTokenization parser,
java.lang.String seqString)
Construct a SymbolList from a string. |
Method Summary | |
---|---|
void |
addSymbol(Symbol sym)
Add a new Symbol to the end of this list. |
void |
edit(Edit edit)
Apply and edit to the SymbolList as specified by Edit. |
protected void |
finalize()
|
Alphabet |
getAlphabet()
Get the alphabet of this SymbolList. |
Symbol[] |
getSymbolArray()
Return the Java Symbol[] array that backs this object. |
int |
length()
Get the length of this SymbolList. |
void |
postChange(ChangeEvent cev)
Called when a change has just taken place. |
void |
preChange(ChangeEvent cev)
On preChange() we convert the SymolList to a non-veiw version, giving it its own copy of symbols |
SymbolList |
subList(int start,
int end)
create a subList of the original, this will be a view until either the original symbolList or the sublist is edited |
Symbol |
symbolAt(int pos)
Find a symbol at a specified offset in the SymbolList. |
Methods inherited from class org.biojava.bio.symbol.AbstractSymbolList |
---|
equals, hashCode, iterator, seqString, subStr, toList, toString |
Methods inherited from class org.biojava.utils.AbstractChangeable |
---|
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.biojava.utils.Changeable |
---|
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener |
Constructor Detail |
---|
public SimpleSymbolList(Alphabet alpha)
alpha
- The alphabet of legal symbols in this list.public SimpleSymbolList(Alphabet alpha, java.util.List rList) throws IllegalSymbolException
alpha
- The alphabet of legal symbols for this list.rList
- A Java List of symbols.
IllegalSymbolException
- if a Symbol is not in the specified alphabet.
java.lang.ClassCastException
- if rList contains objects which do not implement Symbol.public SimpleSymbolList(SymbolTokenization parser, java.lang.String seqString) throws IllegalSymbolException
parser
- A SymbolParser for whatever your string is -- e.g. alphabet.getParser("token").seqString
- A Java List of symbols.
IllegalSymbolException
- if a Symbol is not in the specified alphabet.public SimpleSymbolList(SymbolList sl)
sl
- the list to copy.public SimpleSymbolList(Symbol[] symbols, int length, Alphabet alphabet)
Method Detail |
---|
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public Alphabet getAlphabet()
getAlphabet
in interface SymbolList
public int length()
length
in interface SymbolList
public Symbol symbolAt(int pos)
symbolAt
in interface SymbolList
pos
- Position in biological coordinates (1..length)
public SymbolList subList(int start, int end)
subList
in interface SymbolList
subList
in class AbstractSymbolList
start
- the first symbol of the new SymbolListend
- the last symbol (inclusive) of the new SymbolListpublic void edit(Edit edit) throws java.lang.IndexOutOfBoundsException, IllegalAlphabetException, ChangeVetoException
edit() is now supported using the ChangeEvent system. SubLists do NOT reflect edits.
edit
in interface SymbolList
edit
in class AbstractSymbolList
edit
- the Edit to perform
java.lang.IndexOutOfBoundsException
- if the edit does not lie within the
SymbolList
IllegalAlphabetException
- if the SymbolList to insert has an
incompatible alphabet
ChangeVetoException
- if either the SymboList does not support the
edit, or if the change was vetoedpublic void preChange(ChangeEvent cev) throws ChangeVetoException
preChange
in interface ChangeListener
cev
- An event encapsulating the change which is about
to take place.
ChangeVetoException
- Description of Exceptionpublic void postChange(ChangeEvent cev)
ChangeListener
Called when a change has just taken place.
This method is the place to perform any behavior in response to the change event.
postChange
in interface ChangeListener
cev
- An event encapsulating the change which has
occured.public void addSymbol(Symbol sym) throws IllegalSymbolException, ChangeVetoException
sym
- Symbol to add
IllegalSymbolException
- if the Symbol is not in this list's alphabet
ChangeVetoException
public Symbol[] getSymbolArray()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |