|
||||||||||
| 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.SimpleGappedSymbolList
public class SimpleGappedSymbolList
This implementation of GappedSymbolList wraps a SymbolList, allowing you to insert gaps. Please note that this is a view onto another SymbolList. Gaps created and removed are only in the view not the underlying original. This means that any gaps present in the original cannot be manipulated in this view. To manipulate the original you would need to use Edit objects.
| Nested Class Summary | |
|---|---|
protected static class |
SimpleGappedSymbolList.Block
An aligned block. |
| Nested classes/interfaces inherited from class org.biojava.bio.symbol.AbstractSymbolList |
|---|
AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslater |
| Field Summary |
|---|
| Fields inherited from interface org.biojava.bio.symbol.SymbolList |
|---|
EDIT, EMPTY_LIST |
| Constructor Summary | |
|---|---|
SimpleGappedSymbolList(SymbolList source)
Create a new SimpleGappedSymbolList that will view source. |
|
| Method Summary | |
|---|---|
void |
addGapInSource(int pos)
Add a gap at pos within the source coordinates. |
void |
addGapInView(int pos)
Add a single gap at pos within the view coordintates. |
void |
addGapsInSource(int pos,
int length)
Add length gaps at pos within the source coordinates. |
void |
addGapsInView(int pos,
int length)
Add length gaps at pos within the view coordinates. |
List |
BlockIterator()
Get list of the un-gapped region of the SymbolList. |
void |
dumpBlocks()
Debugging method |
protected int |
findSourceBlock(int indx)
Finds the index of the block containing the source coordinate indx. |
protected int |
findSourceGap(int indx)
Finds the index of the Block before the gap at indx within the following gap. |
protected int |
findViewBlock(int indx)
Finds the index of the Block containing indx within the view ranges. |
protected int |
findViewGap(int indx)
Finds the index of the Block before the gap at indx within the view range. |
int |
firstNonGap()
Return the index of the first Symbol that is not a Gap character. |
Location |
gappedToLocation(Location l)
Translates a Location from the gapped view into the underlying sequence. |
Alphabet |
getAlphabet()
The alphabet that this SymbolList is over. |
SymbolList |
getSourceSymbolList()
Return the underlying (ungapped) SymbolList. |
Location |
getUngappedLocation()
Get a Location that contains exactly those positions that are not gaps. |
protected boolean |
isSane()
|
int |
lastNonGap()
Return the index of the last Symbol that is not a Gap character. |
int |
length()
The number of symbols in this SymbolList. |
Location |
locationToGapped(Location l)
Translate a Location onto the gapped view, splitting blocks if necessary |
void |
removeGap(int pos)
Remove a single gap at position pos in this GappedSymbolList. |
void |
removeGaps(int pos,
int length)
Remove some gaps at position pos in this GappedSymbolList. |
protected void |
renumber(int i,
int delta)
Renumber the view indexes from block, adding delta to each offset. |
int |
sourceToView(int indx)
Coordinate conversion from source to view. |
protected int |
sourceToView(SimpleGappedSymbolList.Block b,
int indx)
Coordinate conversion from source to view. |
Symbol |
symbolAt(int indx)
Return the symbol at index, counting from 1. |
int |
viewToSource(int indx)
Coordinate conversion from view to source. |
protected int |
viewToSource(SimpleGappedSymbolList.Block b,
int indx)
Coordinate conversion from view to source. |
| 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 class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.biojava.bio.symbol.SymbolList |
|---|
edit, iterator, seqString, subList, subStr, toList |
| Methods inherited from interface org.biojava.utils.Changeable |
|---|
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener |
| Constructor Detail |
|---|
public SimpleGappedSymbolList(SymbolList source)
source - the underlying sequence| Method Detail |
|---|
protected final int findSourceBlock(int indx)
indx - the index to find
protected final int findViewBlock(int indx)
If indx is not within a view block, then it is the index of a gap. The method will return -(indx+1) where indx is the block emediately following the gap.
indx - the index to find within a view range.
protected final int findSourceGap(int indx)
indx - the index to find within a gap
protected final int findViewGap(int indx)
If indx is in-fact a real symbol, then there will be no Block before it. In this case, the method returns -2. It returns -1 if indx is within the leading gaps and blocks.size()-1 if it is within the trailing gaps.
indx - the index to find within a view range
protected final int viewToSource(SimpleGappedSymbolList.Block b,
int indx)
b - the block containing indxindx - the index to project
public final int viewToSource(int indx)
throws IndexOutOfBoundsException
GappedSymbolListIf the index can be projected onto the source, the index it projects onto is returned. If it falls within a gap, then the index of the first symbol after the run of gaps is negated and returned. If the index is after the last block of symbols (and therefore in the trailing list of gaps), then it returns -(length + 1).
viewToSource in interface GappedSymbolListindx - the index to project
IndexOutOfBoundsException - if indx is not a valid view index
protected final int sourceToView(SimpleGappedSymbolList.Block b,
int indx)
b - the block containing indxindx - the index to project
public final int sourceToView(int indx)
throws IndexOutOfBoundsException
GappedSymbolList
sourceToView in interface GappedSymbolListindx - the index to project
IndexOutOfBoundsException - if indx is not a valid source index
protected final void renumber(int i,
int delta)
This adjusts viewStart and viewEnd to be += delta for each block i->blocks.size(), and sets the total length to += delta.
i - the first
public void addGapInView(int pos)
throws IndexOutOfBoundsException
GappedSymbolListthis.symbolAt(pos) will then return gap. Adding a gap at 1 will prepend gaps. Adding a gap at (length+1) will append a gap.
addGapInView in interface GappedSymbolListpos - the position to add a gap before
IndexOutOfBoundsException - if pos is not within 1->length+1
public void addGapsInView(int pos,
int length)
throws IndexOutOfBoundsException
GappedSymbolListthis.symbolAt(i) will then return gap for i = (pos .. pos+count-1). Adding gaps at 1 will prepend gaps. Adding gaps at (length+1) will append gaps.
addGapsInView in interface GappedSymbolListpos - the position to add a gap beforelength - the number of gaps to insert
IndexOutOfBoundsException - if pos is not within 1->length+1
public void addGapInSource(int pos)
throws IndexOutOfBoundsException
GappedSymbolList
addGapInSource in interface GappedSymbolListpos - where to add the gap
IndexOutOfBoundsException - if pos is not within 1->source.length()
public void addGapsInSource(int pos,
int length)
GappedSymbolList
addGapsInSource in interface GappedSymbolListpos - where to add the gaplength - how many gaps to add
public void removeGap(int pos)
throws IndexOutOfBoundsException,
IllegalSymbolException
GappedSymbolList
removeGap in interface GappedSymbolListpos - where to remove the gap
IndexOutOfBoundsException - if pos is not within 1..length
IllegalSymbolException - if the symbol at pos is not a gap
public void removeGaps(int pos,
int length)
throws IndexOutOfBoundsException,
IllegalSymbolException
GappedSymbolList
removeGaps in interface GappedSymbolListpos - where to remove the gapslength - how many to remove
IndexOutOfBoundsException - if pos is not within 1..length() or if
some of the Symbols within pos->(pos+length-1) are not gap Symbols
IllegalSymbolException - if the symbol at pos is not a gappublic Alphabet getAlphabet()
SymbolList
Every symbol within this SymbolList is a member of this alphabet.
alphabet.contains(symbol) == true
for each symbol that is within this sequence.
getAlphabet in interface SymbolListpublic int length()
SymbolList
length in interface SymbolList
public Symbol symbolAt(int indx)
throws IndexOutOfBoundsException
SymbolList
symbolAt in interface SymbolListindx - the offset into this SymbolList
IndexOutOfBoundsException - if index is less than 1, or greater than
the length of the symbol listpublic int firstNonGap()
GappedSymbolListAll symbols before firstNonGap are leading gaps. firstNonGap is effectively the index in the view of symbol 1 in the original sequence.
firstNonGap in interface GappedSymbolListpublic int lastNonGap()
GappedSymbolListAll symbols after lastNonGap untill length are trailing gaps. lastNonGap is effectively the index in the view of symbol length in the original sequence.
lastNonGap in interface GappedSymbolListpublic List BlockIterator()
The gapped symbol list can be represented as a list of ungapped regions. Given a list of start-stop pairs in the ungapped coordinate system each with a corresponding pair of start-stop pairs in the gapped view, the entire gapped list can be reconstructed.
public void dumpBlocks()
public Location locationToGapped(Location l)
public Location gappedToLocation(Location l)
public SymbolList getSourceSymbolList()
GappedSymbolList
getSourceSymbolList in interface GappedSymbolListpublic Location getUngappedLocation()
GappedSymbolListThis will be a Location that contains every symbol in the underlying ungapped sequence. Every symbol not in the Location is not from the underlying sequence and is a gap.
getUngappedLocation in interface GappedSymbolListprotected boolean isSane()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||