|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.aisb.bio.things.Sequence
This is the basis for any implementation of any sequence.
Classes and methods that work on sequences should refer to this,
and not directly to the classes that extend it. It is an implementation of
the List interface, which is an extension of the Collection interface. This
means there are already a lot of sophisticated Java tools that will work directly
on it. It also means that you ought not assume the implementations are thread safe.
There is a lot of "junk code" here. We create a ArrayList
and wrap it with a bunch of methods that validate the inputs against the type of sequence
we have, for inputs that would modify the contents. Very little of that code is worth
looking at. However, doing this allows us to focus on adding interesting methods while
preserving the List and Collection interfaces.
Of particular note is the loadFromString method. This takes a string of characters
representing a sequence. It then generates an actual Sequence of the Monomers represented
by those characters.
We can tighten this up a lot later on. This was just the easiest implementation for me to blast out quickly.
| Field Summary | |
Class |
type
|
| Constructor Summary | |
Sequence()
|
|
Sequence(Class monomer)
|
|
Sequence(Class monomer,
String sequence)
|
|
Sequence(int count)
|
|
| Method Summary | |
void |
add(int index,
Object element)
|
boolean |
add(Object o)
|
boolean |
addAll(Collection c)
|
boolean |
addAll(int index,
Collection c)
|
void |
appendFromString(String input)
|
void |
clear()
|
boolean |
contains(Object o)
|
boolean |
containsAll(Collection c)
|
Object |
get(int index)
|
String |
getComment()
|
String |
getFasta()
Return this sequence in FASTA format. |
Class |
getType()
|
int |
indexOf(Object o)
|
boolean |
isEmpty()
|
Iterator |
iterator()
|
int |
lastIndexOf(Object o)
|
ListIterator |
listIterator()
|
ListIterator |
listIterator(int index)
|
void |
loadFromString(String input)
Take a string that makes sense given the type of sequence this is. |
Object |
remove(int index)
|
boolean |
remove(Object o)
|
boolean |
removeAll(Collection c)
|
boolean |
retainAll(Collection c)
|
Object |
set(int index,
Object element)
|
void |
setComment(String comment)
|
void |
setType(Class type)
Set the type. |
void |
setType(String type)
|
int |
size()
|
List |
subList(int fromIndex,
int toIndex)
|
Object[] |
toArray()
|
Object[] |
toArray(Object[] a)
|
String |
toString()
|
void |
validate(Collection c)
|
void |
validate(Object element)
This method validates every object added to the sequence. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
equals, hashCode |
| Field Detail |
public Class type
| Constructor Detail |
public Sequence(Class monomer)
public Sequence(Class monomer,
String sequence)
public Sequence(int count)
public Sequence()
| Method Detail |
public Class getType()
public void setType(String type)
public void setType(Class type)
AminoAcid, attempts to add an
object of type Nucleotide will fail. However, attempts to add elements of a
subclass of AminoAcid, such as a class describing some constrained set of amino
acids, will succeed.
Every class used must be descended from Monomer.
type - The type to set.public String getFasta()
public String getComment()
public void setComment(String comment)
comment - The comment to set.public void validate(Object element)
element - The element to be added to the sequence.public void validate(Collection c)
public void loadFromString(String input)
setType on that new Sequence to teach it what it's
a sequence of, and pass that string into the loadFromString method, and we're done.
input - public void appendFromString(String input)
public String toString()
public void add(int index,
Object element)
add in interface Listpublic boolean add(Object o)
add in interface Listpublic boolean addAll(Collection c)
addAll in interface List
public boolean addAll(int index,
Collection c)
addAll in interface Listpublic void clear()
clear in interface Listpublic boolean contains(Object o)
contains in interface Listpublic boolean containsAll(Collection c)
containsAll in interface Listpublic Object get(int index)
get in interface Listpublic int indexOf(Object o)
indexOf in interface Listpublic boolean isEmpty()
isEmpty in interface Listpublic Iterator iterator()
iterator in interface Listpublic int lastIndexOf(Object o)
lastIndexOf in interface Listpublic ListIterator listIterator()
listIterator in interface Listpublic ListIterator listIterator(int index)
listIterator in interface Listpublic Object remove(int index)
remove in interface Listpublic boolean remove(Object o)
remove in interface Listpublic boolean removeAll(Collection c)
removeAll in interface Listpublic boolean retainAll(Collection c)
retainAll in interface List
public Object set(int index,
Object element)
set in interface Listpublic int size()
size in interface List
public List subList(int fromIndex,
int toIndex)
subList in interface Listpublic Object[] toArray()
toArray in interface Listpublic Object[] toArray(Object[] a)
toArray in interface List
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||