Class SimpleGappedSymbolList
- All Implemented Interfaces:
Serializable
,GappedSymbolList
,SymbolList
,Changeable
- Direct Known Subclasses:
SimpleGappedSequence
- Since:
- 1.3
- Author:
- Matthew Pocock
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final class
An aligned block.Nested classes/interfaces inherited from class org.biojava.bio.symbol.AbstractSymbolList
AbstractSymbolList.EditScreener, AbstractSymbolList.EditTranslater
-
Field Summary
Fields inherited from interface org.biojava.bio.symbol.SymbolList
EDIT, EMPTY_LIST
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleGappedSymbolList
(Alphabet alpha) SimpleGappedSymbolList
(GappedSymbolList gappedSource) Create a new SimpleGappedSymbolList that will view source, inheriting all existing gaps.SimpleGappedSymbolList
(SymbolList source) Create a new SimpleGappedSymbolList that will view source. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Get list of the un-gapped region of the SymbolList.void
Debugging methodprotected final int
findSourceBlock
(int indx) Finds the index of the block containing the source coordinate indx.protected final int
findSourceGap
(int indx) Finds the index of the Block before the gap at indx within the following gap.protected final int
findViewBlock
(int indx) Finds the index of the Block containing indx within the view ranges.protected final int
findViewGap
(int indx) Finds the index of the Block before the gap at indx within the view range.int
Return the index of the first Symbol that is not a Gap character.Translates a Location from the gapped view into the underlying sequence.The alphabet that this SymbolList is over.Return the underlying (ungapped) SymbolList.Get a Location that contains exactly those positions that are not gaps.protected boolean
isSane()
int
Return the index of the last Symbol that is not a Gap character.int
length()
The number of symbols in this SymbolList.Translate a Location onto the gapped view, splitting blocks if necessaryvoid
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 final void
renumber
(int i, int delta) Renumber the view indexes from block, adding delta to each offset.final int
sourceToView
(int indx) Coordinate conversion from source to view.protected final int
sourceToView
(SimpleGappedSymbolList.Block b, int indx) Coordinate conversion from source to view.symbolAt
(int indx) Return the symbol at index, counting from 1.final int
viewToSource
(int indx) Coordinate conversion from view to source.protected final 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, toString
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Constructor Details
-
SimpleGappedSymbolList
Create a new SimpleGappedSymbolList that will view source, inheriting all existing gaps.- Parameters:
gappedSource
- the underlying sequence
-
SimpleGappedSymbolList
Create a new SimpleGappedSymbolList that will view source.- Parameters:
source
- the underlying sequence
-
SimpleGappedSymbolList
-
-
Method Details
-
addGapInSource
Description copied from interface:GappedSymbolList
Add a gap at pos within the source coordinates.- Specified by:
addGapInSource
in interfaceGappedSymbolList
- Parameters:
pos
- where to add the gap- Throws:
IndexOutOfBoundsException
- if pos is not within 1->source.length()
-
addGapInView
Description copied from interface:GappedSymbolList
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.
- Specified by:
addGapInView
in interfaceGappedSymbolList
- Parameters:
pos
- the position to add a gap before- Throws:
IndexOutOfBoundsException
- if pos is not within 1->length+1
-
addGapsInSource
Description copied from interface:GappedSymbolList
Add length gaps at pos within the source coordinates.- Specified by:
addGapsInSource
in interfaceGappedSymbolList
- Parameters:
pos
- where to add the gaplength
- how many gaps to add
-
addGapsInView
Description copied from interface:GappedSymbolList
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.
- Specified by:
addGapsInView
in interfaceGappedSymbolList
- 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
-
BlockIterator
Get list of the un-gapped region of the SymbolList.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.
- Returns:
- a List of Block instances
-
dumpBlocks
Debugging method -
firstNonGap
Description copied from interface:GappedSymbolList
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.
- Specified by:
firstNonGap
in interfaceGappedSymbolList
- Returns:
- the index of the first character not to be a gap
-
gappedToLocation
Translates a Location from the gapped view into the underlying sequence. End points that are in gaps are moved 'inwards' to shorten the location.- Since:
- 1.3
-
getAlphabet
Description copied from interface:SymbolList
The alphabet that this SymbolList is over.Every symbol within this SymbolList is a member of this alphabet.
alphabet.contains(symbol) == true
for each symbol that is within this sequence.- Specified by:
getAlphabet
in interfaceSymbolList
- Returns:
- the alphabet
-
getSourceSymbolList
Description copied from interface:GappedSymbolList
Return the underlying (ungapped) SymbolList.- Specified by:
getSourceSymbolList
in interfaceGappedSymbolList
-
getUngappedLocation
Description copied from interface:GappedSymbolList
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.
- Specified by:
getUngappedLocation
in interfaceGappedSymbolList
- Returns:
- a new Location that contains all non-gap symbols
-
lastNonGap
Description copied from interface:GappedSymbolList
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.
- Specified by:
lastNonGap
in interfaceGappedSymbolList
- Returns:
- the index of the last character not to be a gap
-
length
Description copied from interface:SymbolList
The number of symbols in this SymbolList.- Specified by:
length
in interfaceSymbolList
- Returns:
- the length
-
locationToGapped
Translate a Location onto the gapped view, splitting blocks if necessary- Since:
- 1.3
-
removeGap
Description copied from interface:GappedSymbolList
Remove a single gap at position pos in this GappedSymbolList.- Specified by:
removeGap
in interfaceGappedSymbolList
- 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
public void removeGaps(int pos, int length) throws IndexOutOfBoundsException, IllegalSymbolException Description copied from interface:GappedSymbolList
Remove some gaps at position pos in this GappedSymbolList.- Specified by:
removeGaps
in interfaceGappedSymbolList
- 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
-
sourceToView
Description copied from interface:GappedSymbolList
Coordinate conversion from source to view.- Specified by:
sourceToView
in interfaceGappedSymbolList
- 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
-
symbolAt
Description copied from interface:SymbolList
Return the symbol at index, counting from 1.- Specified by:
symbolAt
in interfaceSymbolList
- Parameters:
indx
- the offset into this SymbolList- Returns:
- the Symbol at that index
- Throws:
IndexOutOfBoundsException
- if index is less than 1, or greater than the length of the symbol list
-
viewToSource
Description copied from interface:GappedSymbolList
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).
- Specified by:
viewToSource
in interfaceGappedSymbolList
- 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
-
findSourceBlock
Finds the index of the block containing the source coordinate indx.- Parameters:
indx
- the index to find- Returns:
- the index of the Block containing indx
-
findSourceGap
Finds the index of the Block before the gap at indx within the following gap.- Parameters:
indx
- the index to find within a gap- Returns:
- the index of the block with indx in the gap
-
findViewBlock
Finds the index of the Block containing indx within the view ranges.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.
- Parameters:
indx
- the index to find within a view range.- Returns:
- the index of the block containing index or one less than the negative of the index of the block following the gap
-
findViewGap
Finds the index of the Block before the gap at indx within the view range.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.
- Parameters:
indx
- the index to find within a view range- Returns:
- the index of the block with indx in the following gap
-
isSane
-
renumber
Renumber the view indexes from block, adding delta to each offset.This adjusts viewStart and viewEnd to be += delta for each block i->blocks.size(), and sets the total length to += delta.
- Parameters:
i
- the first
-
sourceToView
Coordinate conversion from source to view.- Parameters:
b
- the block containing indxindx
- the index to project- Returns:
- the position of indx projected from source to view
-
viewToSource
Coordinate conversion from view to source.- Parameters:
b
- the block containing indxindx
- the index to project- Returns:
- the position of indx projected from view to source
-