Interface GappedSymbolList
-
- All Superinterfaces:
Changeable
,SymbolList
- All Known Subinterfaces:
GappedSequence
- All Known Implementing Classes:
SimpleGappedSequence
,SimpleGappedSymbolList
public interface GappedSymbolList extends SymbolList
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.
- Since:
- 1.3
- Author:
- Matthew Pocock
-
-
Field Summary
-
Fields inherited from interface org.biojava.bio.symbol.SymbolList
EDIT, EMPTY_LIST
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from interface org.biojava.bio.symbol.SymbolList
edit, getAlphabet, iterator, length, seqString, subList, subStr, symbolAt, toList
-
-
-
-
Method Detail
-
getSourceSymbolList
SymbolList getSourceSymbolList()
Return the underlying (ungapped) SymbolList.- Since:
- 1.4
-
viewToSource
int viewToSource(int indx) throws IndexOutOfBoundsException
Coordinate conversion from view to source.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).
- Parameters:
indx
- the index to project- Returns:
- the position of indx projected from view to source
- Throws:
IndexOutOfBoundsException
- if indx is not a valid view index
-
sourceToView
int sourceToView(int indx) throws IndexOutOfBoundsException
Coordinate conversion from source to view.- Parameters:
indx
- the index to project- Returns:
- the position of indx projected from source to view
- Throws:
IndexOutOfBoundsException
- if indx is not a valid source index
-
addGapInView
void addGapInView(int pos) throws IndexOutOfBoundsException
Add a single gap at pos within the view coordintates.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.
- Parameters:
pos
- the position to add a gap before- Throws:
IndexOutOfBoundsException
- if pos is not within 1->length+1
-
addGapsInView
void addGapsInView(int pos, int length) throws IndexOutOfBoundsException
Add length gaps at pos within the view coordinates.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.
- Parameters:
pos
- the position to add a gap beforelength
- the number of gaps to insert- Throws:
IndexOutOfBoundsException
- if pos is not within 1->length+1
-
addGapInSource
void addGapInSource(int pos) throws IndexOutOfBoundsException
Add a gap at pos within the source coordinates.- Parameters:
pos
- where to add the gap- Throws:
IndexOutOfBoundsException
- if pos is not within 1->source.length()
-
addGapsInSource
void addGapsInSource(int pos, int length) throws IndexOutOfBoundsException
Add length gaps at pos within the source coordinates.- Parameters:
pos
- where to add the gaplength
- how many gaps to add- Throws:
IndexOutOfBoundsException
- if pos is not within 1->source.length()
-
removeGap
void removeGap(int pos) throws IndexOutOfBoundsException, IllegalSymbolException
Remove a single gap at position pos in this GappedSymbolList.- Parameters:
pos
- where to remove the gap- Throws:
IndexOutOfBoundsException
- if pos is not within 1..lengthIllegalSymbolException
- if the symbol at pos is not a gap
-
removeGaps
void removeGaps(int pos, int length) throws IndexOutOfBoundsException, IllegalSymbolException
Remove some gaps at position pos in this GappedSymbolList.- Parameters:
pos
- where to remove the gapslength
- how many to remove- Throws:
IndexOutOfBoundsException
- 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 gap
-
firstNonGap
int firstNonGap()
Return the index of the first Symbol that is not a Gap character.All symbols before firstNonGap are leading gaps. firstNonGap is effectively the index in the view of symbol 1 in the original sequence.
- Returns:
- the index of the first character not to be a gap
-
lastNonGap
int lastNonGap()
Return the index of the last Symbol that is not a Gap character.All symbols after lastNonGap untill length are trailing gaps. lastNonGap is effectively the index in the view of symbol length in the original sequence.
- Returns:
- the index of the last character not to be a gap
-
getUngappedLocation
Location getUngappedLocation()
Get a Location that contains exactly those positions that are not gaps.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.
- Returns:
- a new Location that contains all non-gap symbols
-
-