|
|||||||||||
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
This implementation of GappedSymbolList wraps a SymbolList, allowing you to insert gaps.
Nested Class Summary | |
class |
SimpleGappedSymbolList.Block
An aligned block. |
Nested classes inherited from class org.biojava.bio.symbol.AbstractSymbolList |
AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslater |
Nested classes inherited from class org.biojava.bio.symbol.SymbolList |
SymbolList.EmptySymbolList |
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. |
java.util.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. |
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 |
Methods inherited from class org.biojava.utils.AbstractChangeable |
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, isUnchanging, removeChangeListener, removeChangeListener |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, 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 sequenceMethod 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 java.lang.IndexOutOfBoundsException
GappedSymbolList
If 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 GappedSymbolList
indx
- the index to project
java.lang.IndexOutOfBoundsException
- if indx is not a valid view indexprotected final int sourceToView(SimpleGappedSymbolList.Block b, int indx)
b
- the block containing indxindx
- the index to project
public final int sourceToView(int indx) throws java.lang.IndexOutOfBoundsException
GappedSymbolList
sourceToView
in interface GappedSymbolList
indx
- the index to project
java.lang.IndexOutOfBoundsException
- if indx is not a valid source indexprotected 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 firstpublic void addGapInView(int pos) throws java.lang.IndexOutOfBoundsException
GappedSymbolList
this.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 GappedSymbolList
pos
- the position to add a gap before
java.lang.IndexOutOfBoundsException
- if pos is not within 1->length+1public void addGapsInView(int pos, int length) throws java.lang.IndexOutOfBoundsException
GappedSymbolList
this.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 GappedSymbolList
pos
- the position to add a gap beforelength
- the number of gaps to insert
java.lang.IndexOutOfBoundsException
- if pos is not within 1->length+1public void addGapInSource(int pos) throws java.lang.IndexOutOfBoundsException
GappedSymbolList
addGapInSource
in interface GappedSymbolList
pos
- where to add the gap
java.lang.IndexOutOfBoundsException
- if pos is not within 1->source.length()public void addGapsInSource(int pos, int length)
GappedSymbolList
addGapsInSource
in interface GappedSymbolList
pos
- where to add the gaplength
- how many gaps to addpublic void removeGap(int pos) throws java.lang.IndexOutOfBoundsException, IllegalSymbolException
GappedSymbolList
removeGap
in interface GappedSymbolList
pos
- where to remove the gap
java.lang.IndexOutOfBoundsException
- if pos is not within 1..length
IllegalSymbolException
- if the symbol at pos is not a gappublic void removeGaps(int pos, int length) throws java.lang.IndexOutOfBoundsException, IllegalSymbolException
GappedSymbolList
removeGaps
in interface GappedSymbolList
pos
- where to remove the gapslength
- how many to remove
IllegalSymbolException
- if the symbol at pos is not a gap
java.lang.IndexOutOfBoundsException
- if pos is not within 1..length() or if
some of the Symbols within pos->(pos+length-1) are not gap Symbolspublic 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 SymbolList
public int length()
SymbolList
length
in interface SymbolList
public Symbol symbolAt(int indx) throws java.lang.IndexOutOfBoundsException
SymbolList
symbolAt
in interface SymbolList
indx
- the offset into this SymbolList
java.lang.IndexOutOfBoundsException
- if index is less than 1, or greater than
the length of the symbol listpublic int firstNonGap()
GappedSymbolList
All symbols before firstNonGap are leading gaps. firstNonGap is effectively the index in the view of symbol 1 in the original sequence.
firstNonGap
in interface GappedSymbolList
public int lastNonGap()
GappedSymbolList
All 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 GappedSymbolList
public java.util.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()
getSourceSymbolList
in interface GappedSymbolList
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |