Class SimpleAlignment
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojava.bio.symbol.AbstractSymbolList
-
- org.biojava.bio.alignment.SimpleAlignment
-
- All Implemented Interfaces:
Serializable
,Alignment
,SymbolList
,Changeable
- Direct Known Subclasses:
AlignmentPair
public class SimpleAlignment extends AbstractSymbolList implements Alignment, Serializable
A simple implementation of an Alignment.This is a simple-stupid implementation that is made from a set of same-lengthed SymbolList objects each with an associated label. It does not handle differently lengthed sequences and doesn't contain any gap-editing concepts.
- Author:
- Matthew Pocock, Greg Cox, Nimesh Singh
- See Also:
- Serialized Form
-
-
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.bio.alignment.Alignment
Alignment.SymbolListIterator
-
-
Field Summary
-
Fields inherited from interface org.biojava.bio.symbol.SymbolList
EDIT, EMPTY_LIST
-
-
Constructor Summary
Constructors Constructor Description SimpleAlignment(Map<String,SymbolList> labelToResList)
Generate an alignment from a list of SymbolLists.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
finalize()
Alphabet
getAlphabet()
The alphabet that this SymbolList is over.List<String>
getLabels()
The list of SymbolLists in the alignment.int
getScore()
int
length()
The number of symbols in this SymbolList.void
setScore(int score)
Alignment
subAlignment(Set<String> labels, Location loc)
Make a view onto this alignment.Symbol
symbolAt(int index)
Return the symbol at index, counting from 1.Symbol
symbolAt(String label, int column)
Retrieve a symbol by label and column.SymbolList
symbolListForLabel(String label)
Retrieve a single row of the alignment by label.Iterator<SymbolList>
symbolListIterator()
Creates an Iterator over the SymbolLists in the alignment.-
Methods inherited from class org.biojava.bio.symbol.AbstractSymbolList
edit, equals, hashCode, iterator, seqString, subList, subStr, toList, toString
-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Constructor Detail
-
SimpleAlignment
public SimpleAlignment(Map<String,SymbolList> labelToResList) throws IllegalArgumentException
Generate an alignment from a list of SymbolLists.The SymbolLists must all be of the same length.
- Parameters:
labelToResList
- the label-to-symbol list mapping- Throws:
IllegalArgumentException
- if the SymbolLists are not the same length
-
-
Method Detail
-
length
public int length()
Description copied from interface:SymbolList
The number of symbols in this SymbolList.- Specified by:
length
in interfaceSymbolList
- Returns:
- the length
-
getAlphabet
public Alphabet getAlphabet()
Description copied from interface:SymbolList
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.- Specified by:
getAlphabet
in interfaceSymbolList
- Returns:
- the alphabet
-
symbolAt
public Symbol symbolAt(int index)
Description copied from interface:SymbolList
Return the symbol at index, counting from 1.- Specified by:
symbolAt
in interfaceSymbolList
- Parameters:
index
- the offset into this SymbolList- Returns:
- the Symbol at that index
-
getLabels
public List<String> getLabels()
Description copied from interface:Alignment
The list of SymbolLists in the alignment.
The index in the list is the same as the index in the alignment. Each SymbolList object will only be in the alignment once. However, a single underlying SymbolList may have more than one view within an alignment, each represented by a different GappedSymbolList.
-
symbolAt
public Symbol symbolAt(String label, int column)
Description copied from interface:Alignment
Retrieve a symbol by label and column.
-
subAlignment
public Alignment subAlignment(Set<String> labels, Location loc) throws NoSuchElementException
Description copied from interface:Alignment
Make a view onto this alignment.
If labels is null, then each label will be kept. Otherwise, only those in labels will be kept. If loc is null, then the entire length of the alignment will be kept. If loc is not null, then only the columns within the location will be kept.
- Specified by:
subAlignment
in interfaceAlignment
- Parameters:
labels
- the Set of sequences to include by labelloc
- the Location to include- Returns:
- a sub Alignment
- Throws:
NoSuchElementException
- if labels contains any item that is not a label
-
symbolListForLabel
public SymbolList symbolListForLabel(String label) throws NoSuchElementException
Description copied from interface:Alignment
Retrieve a single row of the alignment by label.- Specified by:
symbolListForLabel
in interfaceAlignment
- Parameters:
label
- the object from which to retrieve the symbol list- Returns:
- a SymbolList that contains each token in a row of the alignment
- Throws:
NoSuchElementException
- if there is no row for 'label'
-
symbolListIterator
public Iterator<SymbolList> symbolListIterator()
Description copied from interface:Alignment
Creates an Iterator over the SymbolLists in the alignment. This should be similar to iterating over the labels and then fetching each SymbolList, but the order is not guaranteed to be the same.- Specified by:
symbolListIterator
in interfaceAlignment
- Returns:
- an Iterator
-
getScore
public int getScore()
- Returns:
-
setScore
public void setScore(int score)
- Parameters:
score
-
-
-