|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.biojava.bio.symbol.AbstractSymbolList | +--org.biojava.bio.symbol.GappedSymbolList
This implementation of SymbolList wraps another one, allowing you to insert gaps.
You could make a SymbolList that contains gaps directly. However, this leaves you with a nasty problem if you wish to support gap-edit operations. Also, the original SymbolList must either be coppied or lost.
GappedSymbolList solves these problems. It wraps up a source sequence, and views it through a data-structure that places gaps. You can add and remove the gaps by using the public API.
For gap-insert operations, the insert index is the position that will become a gap. The symbol currently there will move to a higher index. To insert leading gaps, add gaps at index 1. To insert trailing gaps, add gaps at index length+1.
Constructor Summary | |
GappedSymbolList(SymbolList source)
Create a new GappedSymbolList 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. |
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. |
Alphabet |
getAlphabet()
The alphabet that this SymbolList is over. |
int |
lastNonGap()
Return the index of the last Symbol that is not a Gap character. |
int |
length()
The number of symbols in this SymbolList. |
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. |
protected int |
sourceToView(org.biojava.bio.symbol.GappedSymbolList.Block b,
int indx)
Coordinate conversion from source to view. |
int |
sourceToView(int indx)
Coordinate conversion from source to view. |
Symbol |
symbolAt(int indx)
Return the symbol at index, counting from 1. |
protected int |
viewToSource(org.biojava.bio.symbol.GappedSymbolList.Block b,
int indx)
Coordinate conversion from view to source. |
int |
viewToSource(int indx)
Coordinate conversion from view to source. |
Methods inherited from class org.biojava.bio.symbol.AbstractSymbolList |
iterator,
seqString,
subList,
subStr,
toList |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public GappedSymbolList(SymbolList source)
source
- the underlying sequenceMethod Detail |
protected final int findSourceBlock(int indx)
indx
- the index to findprotected 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 -1.
indx
- the index to find within a view range.protected final int findSourceGap(int indx)
indx
- the index to find within a gapprotected 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 rangeprotected final int viewToSource(org.biojava.bio.symbol.GappedSymbolList.Block b, int indx)
b
- the block containing indxindx
- the index to projectpublic final int viewToSource(int indx) throws java.lang.IndexOutOfBoundsException
indx
- the index to projectprotected final int sourceToView(org.biojava.bio.symbol.GappedSymbolList.Block b, int indx)
b
- the block containing indxindx
- the index to projectpublic final int sourceToView(int indx) throws java.lang.IndexOutOfBoundsException
indx
- the index to projectprotected 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
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.
pos
- the position to add a gap beforepublic void addGapsInView(int pos, int length) throws java.lang.IndexOutOfBoundsException
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.
pos
- the position to add a gap beforelength
- the number of gaps to insertpublic void addGapInSource(int pos) throws java.lang.IndexOutOfBoundsException
pos
- where to add the gappublic void addGapsInSource(int pos, int length)
pos
- where to add the gaplength
- how many gaps to addpublic void removeGap(int pos) throws java.lang.IndexOutOfBoundsException, IllegalSymbolException
pos
- where to remove the gappublic void removeGaps(int pos, int length) throws java.lang.IndexOutOfBoundsException, IllegalSymbolException
pos
- where to remove the gapslength
- how many to removepublic Alphabet getAlphabet()
Every symbol within this SymbolList is a member of this alphabet.
alphabet.contains(symbol) == true
for each symbol that is within this sequence.
public int length()
public Symbol symbolAt(int indx) throws java.lang.IndexOutOfBoundsException
index
- the ofset into this SymbolListpublic int firstNonGap()
All symbols before firstNonGap are leading gaps. firstNonGap is effectively the index in the view of symbol 1 in the original sequence.
public int lastNonGap()
All symbols after lastNonGap untill length are trailing gaps. lastNonGap is effectively the index in the view of symbol length in the original sequence.
public void dumpBlocks()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |