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 classAn 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 TypeMethodDescriptionvoidaddGapInSource(int pos) Add a gap at pos within the source coordinates.voidaddGapInView(int pos) Add a single gap at pos within the view coordintates.voidaddGapsInSource(int pos, int length) Add length gaps at pos within the source coordinates.voidaddGapsInView(int pos, int length) Add length gaps at pos within the view coordinates.Get list of the un-gapped region of the SymbolList.voidDebugging methodprotected final intfindSourceBlock(int indx) Finds the index of the block containing the source coordinate indx.protected final intfindSourceGap(int indx) Finds the index of the Block before the gap at indx within the following gap.protected final intfindViewBlock(int indx) Finds the index of the Block containing indx within the view ranges.protected final intfindViewGap(int indx) Finds the index of the Block before the gap at indx within the view range.intReturn 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 booleanisSane()intReturn the index of the last Symbol that is not a Gap character.intlength()The number of symbols in this SymbolList.Translate a Location onto the gapped view, splitting blocks if necessaryvoidremoveGap(int pos) Remove a single gap at position pos in this GappedSymbolList.voidremoveGaps(int pos, int length) Remove some gaps at position pos in this GappedSymbolList.protected final voidrenumber(int i, int delta) Renumber the view indexes from block, adding delta to each offset.final intsourceToView(int indx) Coordinate conversion from source to view.protected final intsourceToView(SimpleGappedSymbolList.Block b, int indx) Coordinate conversion from source to view.symbolAt(int indx) Return the symbol at index, counting from 1.final intviewToSource(int indx) Coordinate conversion from view to source.protected final intviewToSource(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, toStringMethods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:GappedSymbolListAdd a gap at pos within the source coordinates.- Specified by:
addGapInSourcein interfaceGappedSymbolList- Parameters:
pos- where to add the gap- Throws:
IndexOutOfBoundsException- if pos is not within 1->source.length()
-
addGapInView
Description copied from interface:GappedSymbolListAdd 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:
addGapInViewin 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:GappedSymbolListAdd length gaps at pos within the source coordinates.- Specified by:
addGapsInSourcein interfaceGappedSymbolList- Parameters:
pos- where to add the gaplength- how many gaps to add
-
addGapsInView
Description copied from interface:GappedSymbolListAdd 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:
addGapsInViewin 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:GappedSymbolListReturn 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:
firstNonGapin 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:SymbolListThe alphabet that this SymbolList is over.Every symbol within this SymbolList is a member of this alphabet.
alphabet.contains(symbol) == truefor each symbol that is within this sequence.- Specified by:
getAlphabetin interfaceSymbolList- Returns:
- the alphabet
-
getSourceSymbolList
Description copied from interface:GappedSymbolListReturn the underlying (ungapped) SymbolList.- Specified by:
getSourceSymbolListin interfaceGappedSymbolList
-
getUngappedLocation
Description copied from interface:GappedSymbolListGet 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:
getUngappedLocationin interfaceGappedSymbolList- Returns:
- a new Location that contains all non-gap symbols
-
lastNonGap
Description copied from interface:GappedSymbolListReturn 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:
lastNonGapin interfaceGappedSymbolList- Returns:
- the index of the last character not to be a gap
-
length
Description copied from interface:SymbolListThe number of symbols in this SymbolList.- Specified by:
lengthin interfaceSymbolList- Returns:
- the length
-
locationToGapped
Translate a Location onto the gapped view, splitting blocks if necessary- Since:
- 1.3
-
removeGap
Description copied from interface:GappedSymbolListRemove a single gap at position pos in this GappedSymbolList.- Specified by:
removeGapin 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:GappedSymbolListRemove some gaps at position pos in this GappedSymbolList.- Specified by:
removeGapsin 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:GappedSymbolListCoordinate conversion from source to view.- Specified by:
sourceToViewin 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:SymbolListReturn the symbol at index, counting from 1.- Specified by:
symbolAtin 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:GappedSymbolListCoordinate 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:
viewToSourcein 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
-