public class SimpleSymbolList extends AbstractSymbolList implements ChangeListener, Serializable
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.getTokenization("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.
AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslaterChangeListener.AlwaysVetoListener, ChangeListener.ChangeEventRecorder, ChangeListener.LoggingListenerALWAYS_VETO, LOG_TO_OUTEDIT, EMPTY_LIST| Constructor and Description |
|---|
SimpleSymbolList(Alphabet alpha)
Construct an empty SimpleSymbolList.
|
SimpleSymbolList(Alphabet alpha,
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,
String seqString)
Construct a SymbolList from a string.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
equals, hashCode, iterator, seqString, subStr, toList, toStringaddChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListeneraddChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListenerpublic SimpleSymbolList(Alphabet alpha)
alpha - The alphabet of legal symbols in this list.public SimpleSymbolList(Alphabet alpha, 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.ClassCastException - if rList contains objects which do not implement Symbol.public SimpleSymbolList(SymbolTokenization parser, 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)
public Alphabet getAlphabet()
getAlphabet in interface SymbolListpublic int length()
length in interface SymbolListpublic Symbol symbolAt(int pos)
symbolAt in interface SymbolListpos - Position in biological coordinates (1..length)public SymbolList subList(int start, int end)
subList in interface SymbolListsubList in class AbstractSymbolListstart - the first symbol of the new SymbolListend - the last symbol (inclusive) of the new SymbolListpublic void edit(Edit edit) throws IndexOutOfBoundsException, IllegalAlphabetException, ChangeVetoException
edit() is now supported using the ChangeEvent system. SubLists do NOT reflect edits.
edit in interface SymbolListedit in class AbstractSymbolListedit - the Edit to performIndexOutOfBoundsException - if the edit does not lie within the
SymbolListIllegalAlphabetException - if the SymbolList to insert has an
incompatible alphabetChangeVetoException - if either the SymboList does not support the
edit, or if the change was vetoedpublic void preChange(ChangeEvent cev) throws ChangeVetoException
preChange in interface ChangeListenercev - An event encapsulating the change which is about
to take place.ChangeVetoException - Description of Exceptionpublic void postChange(ChangeEvent cev)
ChangeListenerCalled 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 ChangeListenercev - An event encapsulating the change which has
occured.public void addSymbol(Symbol sym) throws IllegalSymbolException, ChangeVetoException
sym - Symbol to addIllegalSymbolException - if the Symbol is not in this list's alphabetChangeVetoExceptionpublic Symbol[] getSymbolArray()
Copyright © 2020 BioJava. All rights reserved.