public interface GappedSymbolList extends SymbolList
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.
EDIT, EMPTY_LIST
Modifier and Type | Method and Description |
---|---|
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.
|
Location |
getUngappedLocation()
Get a Location that contains exactly those positions that are not gaps.
|
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.
|
edit, getAlphabet, iterator, length, seqString, subList, subStr, symbolAt, toList
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
SymbolList getSourceSymbolList()
int viewToSource(int indx) throws 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 projectIndexOutOfBoundsException
- if indx is not a valid view indexint sourceToView(int indx) throws IndexOutOfBoundsException
indx
- the index to projectIndexOutOfBoundsException
- if indx is not a valid source indexvoid addGapInView(int pos) throws 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 beforeIndexOutOfBoundsException
- if pos is not within 1->length+1void addGapsInView(int pos, int length) throws 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 insertIndexOutOfBoundsException
- if pos is not within 1->length+1void addGapInSource(int pos) throws IndexOutOfBoundsException
pos
- where to add the gapIndexOutOfBoundsException
- if pos is not within 1->source.length()void addGapsInSource(int pos, int length) throws IndexOutOfBoundsException
pos
- where to add the gaplength
- how many gaps to addIndexOutOfBoundsException
- if pos is not within 1->source.length()void removeGap(int pos) throws IndexOutOfBoundsException, IllegalSymbolException
pos
- where to remove the gapIndexOutOfBoundsException
- if pos is not within 1..lengthIllegalSymbolException
- if the symbol at pos is not a gapvoid removeGaps(int pos, int length) throws IndexOutOfBoundsException, IllegalSymbolException
pos
- where to remove the gapslength
- how many to removeIndexOutOfBoundsException
- if pos is not within 1..length() or if some of the Symbols
within pos->(pos+length-1) are not gap SymbolsIllegalSymbolException
- if the symbol at pos is not a gapint firstNonGap()
All symbols before firstNonGap are leading gaps. firstNonGap is effectively the index in the view of symbol 1 in the original sequence.
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.
Location getUngappedLocation()
This 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.
Copyright © 2014 BioJava. All rights reserved.