|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This extends SymbolList with API for manipulating, inserting and deleting 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 will maintain 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.
Nested Class Summary |
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 |
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. |
int |
firstNonGap()
Return the index of the first Symbol that is not a Gap character. |
SymbolList |
getSourceSymbolList()
Return the underlying (ungapped) SymbolList. |
int |
lastNonGap()
Return the index of the last Symbol that is not a Gap character. |
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. |
int |
sourceToView(int indx)
Coordinate conversion from source to view. |
int |
viewToSource(int indx)
Coordinate conversion from view to source. |
Methods inherited from interface org.biojava.bio.symbol.SymbolList |
edit, getAlphabet, iterator, length, seqString, subList, subStr, symbolAt, toList |
Methods inherited from interface org.biojava.utils.Changeable |
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener |
Method Detail |
public SymbolList getSourceSymbolList()
public int viewToSource(int indx) throws java.lang.IndexOutOfBoundsException
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).
indx
- the index to project
java.lang.IndexOutOfBoundsException
- if indx is not a valid view indexpublic int sourceToView(int indx) throws java.lang.IndexOutOfBoundsException
indx
- the index to project
java.lang.IndexOutOfBoundsException
- if indx is not a valid source indexpublic 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 before
java.lang.IndexOutOfBoundsException
- if pos is not within 1->length+1public 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 insert
java.lang.IndexOutOfBoundsException
- if pos is not within 1->length+1public void addGapInSource(int pos) throws java.lang.IndexOutOfBoundsException
pos
- where to add the gap
java.lang.IndexOutOfBoundsException
- if pos is not within 1->source.length()public void addGapsInSource(int pos, int length) throws java.lang.IndexOutOfBoundsException
pos
- where to add the gaplength
- how many gaps to add
java.lang.IndexOutOfBoundsException
- if pos is not within 1->source.length()public void removeGap(int pos) throws java.lang.IndexOutOfBoundsException, IllegalSymbolException
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
pos
- where to remove the gapslength
- how many to remove
java.lang.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 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.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |