Class ThinRichSequence
- All Implemented Interfaces:
Comparable,Annotatable,FeatureHolder,Sequence,SymbolList,Changeable,BioEntry,RichSequence,RankedCrossRefable,RichAnnotatable
- Direct Known Subclasses:
SimpleRichSequence
- Since:
- 1.5
- Author:
- Richard Holland
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarderNested classes/interfaces inherited from interface org.biojava.bio.seq.FeatureHolder
FeatureHolder.EmptyFeatureHolderNested classes/interfaces inherited from interface org.biojavax.bio.seq.RichSequence
RichSequence.IOTools, RichSequence.Terms, RichSequence.Tools -
Field Summary
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATIONFields inherited from interface org.biojavax.bio.BioEntry
COMMENT, DESCRIPTION, DIVISION, IDENTIFIER, RANKEDCROSSREF, RANKEDDOCREF, RELATIONS, SEQVERSION, TAXONFields inherited from interface org.biojava.bio.seq.FeatureHolder
EMPTY_FEATURE_HOLDER, FEATURES, SCHEMAFields inherited from interface org.biojavax.bio.seq.RichSequence
CIRCULAR, SYMLISTVERSIONFields inherited from interface org.biojava.bio.symbol.SymbolList
EDIT, EMPTY_LIST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if the feature is present in this holder.intCount how many features are contained.Create a new Feature, and add it to this FeatureHolder.voidApply an edit to the SymbolList as specified by the edit object.features()Iterate over the features in no well defined order.filter(FeatureFilter filter) Query this set of features using a suppliedFeatureFilter.filter(FeatureFilter fc, boolean recurse) Return a new FeatureHolder that contains all of the children of this one that passed the filter fc.The alphabet that this SymbolList is over.protected StringbooleanIs the sequence circular?The features for this sequence.A special function that returns the SymbolList that this RichSequence is based around.Return a schema-filter for thisFeatureHolder.protected intThe version of the associated symbol list.getURN()A Uniform Resource Identifier (URI) which identifies the sequence represented by this object.iterator()An Iterator over all Symbols in this SymbolList.intlength()The number of symbols in this SymbolList.voidRemove a feature from this FeatureHolder.Stringify this symbol list.protected voidsetAlphabetName(String alphaname) voidsetCircular(boolean circular) Circularises theSequence.voidsetFeatureSet(Set<Feature> features) Sets the features of this sequence.protected voidsetSequenceLength(int length) voidsetSeqVersion(Double seqVersion) Sets the version of the associated symbol list.subList(int start, int end) Return a new SymbolList for the symbols start to end inclusive.subStr(int start, int end) Return a region of this symbol list as a String.symbolAt(int index) Return the symbol at index, counting from 1.toList()Returns a List of symbols.Methods inherited from class org.biojavax.bio.SimpleBioEntry
addComment, addRankedCrossRef, addRankedDocRef, addRelationship, compareTo, equals, getAccession, getAnnotation, getComments, getDescription, getDivision, getId, getIdentifier, getName, getNamespace, getNoteSet, getRankedCrossRefs, getRankedDocRefs, getRelationships, getRichAnnotation, getTaxon, getVersion, hashCode, removeComment, removeRankedCrossRef, removeRankedDocRef, removeRelationship, setDescription, setDivision, setId, setIdentifier, setNoteSet, setRankedCrossRefs, setTaxon, 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.bio.Annotatable
getAnnotationMethods inherited from interface org.biojavax.bio.BioEntry
addComment, addRankedDocRef, addRelationship, getAccession, getComments, getDescription, getDivision, getIdentifier, getName, getNamespace, getRankedDocRefs, getRelationships, getTaxon, getVersion, removeComment, removeRankedDocRef, removeRelationship, setDescription, setDivision, setIdentifier, setTaxonMethods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListenerMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.biojavax.RankedCrossRefable
addRankedCrossRef, getRankedCrossRefs, removeRankedCrossRef, setRankedCrossRefsMethods inherited from interface org.biojavax.RichAnnotatable
getNoteSet, getRichAnnotation, setNoteSet
-
Constructor Details
-
ThinRichSequence
public ThinRichSequence(Namespace ns, String name, String accession, int version, Alphabet alpha, Double seqversion) Creates a new instance of ThinRichSequence. Note the use of Double for seqversion, which indicates that it is nullable.- Parameters:
ns- the namespace for this sequence.name- the name of the sequence.accession- the accession of the sequence.version- the version of the sequence.seqversion- the version of the symbols for the sequence.
-
ThinRichSequence
protected ThinRichSequence()
-
-
Method Details
-
getSeqVersion
The version of the associated symbol list. Note the use of an object for the value means that it can be nulled.- Specified by:
getSeqVersionin interfaceRichSequence- Returns:
- the version
-
setSeqVersion
Sets the version of the associated symbol list. Note the use of an object for the value means that it can be nulled.- Specified by:
setSeqVersionin interfaceRichSequence- Parameters:
seqVersion- the version to set.- Throws:
ChangeVetoException- if it doesn't want to change.
-
setCircular
Circularises theSequence. The circular length can then be said to be the length of the sequence itself.- Specified by:
setCircularin interfaceRichSequence- Parameters:
circular- set to true if you want it to be circular- Throws:
ChangeVetoException- if the change is blocked. Some implementations may choose not to support circularisation and should throw an exception here. Some implementations may only support this method for certain Alphabets.
-
getCircular
Is the sequence circular? Circularity has implications for work with locations and any coordinate work eg symbolAt(int i). Classes that allow it should test this method when working with coordinates or locations / features.- Specified by:
getCircularin interfaceRichSequence- Returns:
- true if the this is circular else false.
-
edit
public void edit(Edit edit) throws IndexOutOfBoundsException, IllegalAlphabetException, ChangeVetoException Apply an edit to the SymbolList as specified by the edit object.Description
All edits can be broken down into a series of operations that change contiguous blocks of the sequence. This represent a one of those operations.
When applied, this Edit will replace 'length' number of symbols starting a position 'pos' by the SymbolList 'replacement'. This allow to do insertions (length=0), deletions (replacement=SymbolList.EMPTY_LIST) and replacements (length>=1 and replacement.length()>=1).
The pos and pos+length should always be valid positions on the SymbolList to:
- be edited (between 0 and symL.length()+1).
- To append to a sequence, pos=symL.length()+1, pos=0.
- To insert something at the beginning of the sequence, set pos=1 and length=0.
Examples
SymbolList seq = DNATools.createDNA("atcaaaaacgctagc"); System.out.println(seq.seqString()); // delete 5 bases from position 4 Edit ed = new Edit(4, 5, SymbolList.EMPTY_LIST); seq.edit(ed); System.out.println(seq.seqString()); // delete one base from the start ed = new Edit(1, 1, SymbolList.EMPTY_LIST); seq.edit(ed); // delete one base from the end ed = new Edit(seq.length(), 1, SymbolList.EMPTY_LIST); seq.edit(ed); System.out.println(seq.seqString()); // overwrite 2 bases from position 3 with "tt" ed = new Edit(3, 2, DNATools.createDNA("tt")); seq.edit(ed); System.out.println(seq.seqString()); // add 6 bases to the start ed = new Edit(1, 0, DNATools.createDNA("aattgg"); seq.edit(ed); System.out.println(seq.seqString()); // add 4 bases to the end ed = new Edit(seq.length() + 1, 0, DNATools.createDNA("tttt")); seq.edit(ed); System.out.println(seq.seqString()); // full edit ed = new Edit(3, 2, DNATools.createDNA("aatagaa"); seq.edit(ed); System.out.println(seq.seqString());- Specified by:
editin interfaceSymbolList- Parameters:
edit- the Edit to perform- Throws:
IndexOutOfBoundsException- if the edit does not lie within the SymbolListIllegalAlphabetException- if the SymbolList to insert has an incompatible alphabetChangeVetoException- if either the SymboList does not support the edit, or if the change was vetoed
-
symbolAt
Return the symbol at index, counting from 1.- Specified by:
symbolAtin interfaceSymbolList- Parameters:
index- 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
-
toList
Returns a List of symbols.This is an immutable list of symbols. Do not edit it.
- Specified by:
toListin interfaceSymbolList- Returns:
- a List of Symbols
-
subStr
Return a region of this symbol list as a String.This should use the same rules as seqString.
- Specified by:
subStrin interfaceSymbolList- Parameters:
start- the first symbol to includeend- the last symbol to include- Returns:
- the string representation
- Throws:
IndexOutOfBoundsException- if either start or end are not within the SymbolList
-
subList
Return a new SymbolList for the symbols start to end inclusive.The resulting SymbolList will count from 1 to (end-start + 1) inclusive, and refer to the symbols start to end of the original sequence.
- Specified by:
subListin interfaceSymbolList- Parameters:
start- the first symbol of the new SymbolListend- the last symbol (inclusive) of the new SymbolList- Throws:
IndexOutOfBoundsException
-
seqString
Stringify this symbol list.It is expected that this will use the symbol's token to render each symbol. It should be parsable back into a SymbolList using the default token parser for this alphabet.
- Specified by:
seqStringin interfaceSymbolList- Returns:
- a string representation of the symbol list
-
length
The number of symbols in this SymbolList.- Specified by:
lengthin interfaceSymbolList- Returns:
- the length
-
iterator
An Iterator over all Symbols in this SymbolList.This is an ordered iterator over the Symbols. It cannot be used to edit the underlying symbols.
- Specified by:
iteratorin interfaceSymbolList- Returns:
- an iterator
-
getAlphabet
The 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
-
setAlphabetName
- Throws:
IllegalSymbolExceptionBioException
-
getAlphabetName
-
setSequenceLength
-
getSequenceLength
-
getURN
A Uniform Resource Identifier (URI) which identifies the sequence represented by this object. For sequences in well-known database, this may be a URN, e.g.urn:sequence/embl:AL121903
It may also be a URL identifying a specific resource, either locally or over the networkfile:///home/thomas/myseq.fa|seq22 http://www.mysequences.net/chr22.seq
-
filter
Return a new FeatureHolder that contains all of the children of this one that passed the filter fc. This method is scheduled for deprecation. Use the 1-arg filter instead.- Specified by:
filterin interfaceFeatureHolder- Parameters:
fc- the FeatureFilter to applyrecurse- true if all features-of-features should be scanned, and a single flat collection of features returned, or false if just immediate children should be filtered.
-
createFeature
Create a new Feature, and add it to this FeatureHolder. This method will generally only work on Sequences, and on some Features which have been attached to Sequences.- Specified by:
createFeaturein interfaceFeatureHolder- Throws:
BioException- if something went wrong during creating the featureChangeVetoException- if this FeatureHolder does not support creation of new features, or if the change was vetoed
-
removeFeature
Remove a feature from this FeatureHolder.- Specified by:
removeFeaturein interfaceFeatureHolder- Throws:
ChangeVetoException- if this FeatureHolder does not support feature removal or if the change was vetoedBioException- if there was an error removing the feature
-
containsFeature
Check if the feature is present in this holder.- Specified by:
containsFeaturein interfaceFeatureHolder- Parameters:
f- the Feature to check- Returns:
- true if f is in this set
-
filter
Query this set of features using a suppliedFeatureFilter.- Specified by:
filterin interfaceFeatureHolder- Parameters:
filter- theFeatureFilterto apply.- Returns:
- all features in this container which match
filter.
-
getFeatureSet
The features for this sequence. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
getFeatureSetin interfaceRichSequence- Returns:
- a set of RichFeature objects.
-
setFeatureSet
Sets the features of this sequence. Note that it is not checked to see if the features actually belong to this sequence, you'd best check that yourself and make changes using feature.setParent() if necessary. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
setFeatureSetin interfaceRichSequence- Parameters:
features- the features to assign to this sequence, replacing all others. Must be a set of RichFeature objects.- Throws:
ChangeVetoException- if they could not be assigned.
-
getSchema
Return a schema-filter for thisFeatureHolder. This is a filter which allFeatures immediately contained by thisFeatureHolderwill match. It need not directly match their child features, but it can (and should!) provide information about them usingFeatureFilter.OnlyChildrenfilters. In cases where there is no feature hierarchy, this can be indicated by includingFeatureFilter.leafin the schema filter.For the truly non-informative case, it is possible to return
FeatureFilter.all. However, it is almost always possible to provide slightly more information that this. For example,Sequenceobjects should, at a minimum, returnFeatureFilter.top_level.Featureobjects should, as a minimum, returnFeatureFilter.ByParent(new FeatureFilter.ByFeature(this)).- Specified by:
getSchemain interfaceFeatureHolder- Returns:
- the schema filter
-
features
Iterate over the features in no well defined order. Warning this method gives access to the original Collection not a copy. This is required by Hibernate. If you modify the object directly the behaviour may be unpredictable.- Specified by:
featuresin interfaceFeatureHolder- Returns:
- an Iterator
-
countFeatures
Count how many features are contained.- Specified by:
countFeaturesin interfaceFeatureHolder- Returns:
- a positive integer or zero, equal to the number of features contained
-
getInternalSymbolList
A special function that returns the SymbolList that this RichSequence is based around. This should _not_ be the RichSequence object itself, as this function is used to perform actions on the symbol list without referring to the RichSequence object directly.- Specified by:
getInternalSymbolListin interfaceRichSequence- Returns:
- the internal SymbolList of the RichSequence, NOT the RichSequence object itself.
-