Class AbstractSequence<C extends Compound>
- java.lang.Object
-
- org.biojava.nbio.core.sequence.template.AbstractSequence<C>
-
- Type Parameters:
C-
- All Implemented Interfaces:
Iterable<C>,Accessioned,Sequence<C>
- Direct Known Subclasses:
BasicSequence,DNASequence,ProteinSequence,RNASequence
public abstract class AbstractSequence<C extends Compound> extends Object implements Sequence<C>
The base class for DNA, RNA and Protein sequences.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractSequence.AnnotationType
-
Constructor Summary
Constructors Constructor Description AbstractSequence()AbstractSequence(String seqString, CompoundSet<C> compoundSet)Create a Sequence from a simple string where the values should be found in compoundSetAbstractSequence(SequenceReader<C> proxyLoader, CompoundSet<C> compoundSet)A ProxySequenceReader allows abstraction of both the storage of the sequence data and the location of the sequence data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFeature(int bioStart, int bioEnd, FeatureInterface<AbstractSequence<C>,C> feature)Method to help set the proper details for a feature as it relates to a sequence where the feature needs to have a location on the sequencevoidaddFeature(FeatureInterface<AbstractSequence<C>,C> feature)Add a feature to this sequence.voidaddNote(String note)Add notes about this sequence that will get exported for GFF3intcountCompounds(C... compounds)Returns the number of times we found a compound in the Sequencebooleanequals(Object o)AccessionIDgetAccession()Returns the AccessionID this location is currently bound withAbstractSequence.AnnotationTypegetAnnotationType()List<C>getAsList()Returns the Sequence as a List of compoundsIntegergetBioBegin()IntegergetBioEnd()List<String>getComments()CgetCompoundAt(int position)Returns the Compound at the given biological indexCompoundSet<C>getCompoundSet()Gets the compound set used to back this SequenceDatabaseReferenceInterfacegetDatabaseReferences()StringgetDescription()FeatureRetrievergetFeatureRetriever()List<FeatureInterface<AbstractSequence<C>,C>>getFeatures()List<FeatureInterface<AbstractSequence<C>,C>>getFeatures(int bioSequencePosition)Return features at a sequence positionList<FeatureInterface<AbstractSequence<C>,C>>getFeatures(String featureType, int bioSequencePosition)Return features at a sequence position by typeList<FeatureInterface<AbstractSequence<C>,C>>getFeaturesByType(String type)FeaturesKeyWordInterfacegetFeaturesKeyWord()intgetIndexOf(C compound)Scans through the Sequence looking for the first occurrence of the given compoundSequenceView<C>getInverse()Does the right thing to get the inverse of the current Sequence.intgetLastIndexOf(C compound)Scans through the Sequence looking for the last occurrence of the given compoundintgetLength()Returns the length of the SequenceArrayList<String>getNotesList()StringgetOriginalHeader()AbstractSequence<?>getParentSequence()SequenceReader<C>getProxySequenceReader()List<AbstractReference>getReferences()StringgetSequenceAsString()Default case is to assume strand is positive because only CDSSequence can be either positive or negative Strand.StringgetSequenceAsString(Integer bioStart, Integer bioEnd, Strand strand)DoublegetSequenceScore()Provide place holder for a metric that indicate a score associated with the sequenceStringgetSource()Added support for the source of this sequence for GFF3 export If a sub sequence doesn't have source then check for parent sourceSequenceView<C>getSubSequence(Integer bioStart, Integer bioEnd)Returns a portion of the sequence from the different positions.TaxonomyIDgetTaxonomy()Collection<Object>getUserCollection()Provided for convince if the developer needs to associate data with a sequenceinthashCode()Iterator<C>iterator()voidremoveFeature(FeatureInterface<AbstractSequence<C>,C> feature)Remove a feature from the sequencevoidremoveNote(String note)voidsetAccession(AccessionID accession)voidsetAnnotationType(AbstractSequence.AnnotationType annotationType)voidsetBioBegin(Integer bioBegin)voidsetBioEnd(Integer bioEnd)voidsetComments(List<String> comments)Set comments.voidsetCompoundSet(CompoundSet<C> compoundSet)voidsetDatabaseReferences(DatabaseReferenceInterface databaseReferences)voidsetDescription(String description)voidsetFeatureRetriever(FeatureRetriever featureRetriever)voidsetFeaturesKeyWord(FeaturesKeyWordInterface featuresKeyWord)voidsetNotesList(ArrayList<String> notesList)voidsetOriginalHeader(String originalHeader)voidsetParentSequence(AbstractSequence<?> parentSequence)voidsetProxySequenceReader(SequenceReader<C> proxyLoader)Very important method that allows external mappings of sequence data and features.voidsetReferences(List<AbstractReference> references)Set the list ofAbstractReferencevoidsetSequenceScore(Double sequenceScore)voidsetSource(String source)Added support for the source of this sequence for GFF3 exportvoidsetTaxonomy(TaxonomyID taxonomy)voidsetUserCollection(Collection<Object> userCollection)StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
AbstractSequence
public AbstractSequence()
-
AbstractSequence
public AbstractSequence(String seqString, CompoundSet<C> compoundSet) throws CompoundNotFoundException
Create a Sequence from a simple string where the values should be found in compoundSet- Parameters:
seqString-compoundSet-- Throws:
CompoundNotFoundException
-
AbstractSequence
public AbstractSequence(SequenceReader<C> proxyLoader, CompoundSet<C> compoundSet)
A ProxySequenceReader allows abstraction of both the storage of the sequence data and the location of the sequence data. A variety of use cases are possible. A ProxySequenceReader that knows the offset and of the sequence in a large fasta file. A ProxySequenceReader that can pull Sequence data from UniProt, NCBI or a custom database. If the ProxySequenceReader implements various interfaces then the sequence will set those interfaces so that calls to various methods will be valid.- Parameters:
proxyLoader-compoundSet-
-
-
Method Detail
-
setProxySequenceReader
public void setProxySequenceReader(SequenceReader<C> proxyLoader)
Very important method that allows external mappings of sequence data and features. This method will gain additional interface inspection that allows external data sources with knowledge of features for a sequence to be supported.- Parameters:
proxyLoader-
-
getProxySequenceReader
public SequenceReader<C> getProxySequenceReader()
-
getBioBegin
public Integer getBioBegin()
- Returns:
- the bioBegin
-
setBioBegin
public void setBioBegin(Integer bioBegin)
- Parameters:
bioBegin- the bioBegin to set
-
getUserCollection
public Collection<Object> getUserCollection()
Provided for convince if the developer needs to associate data with a sequence- Returns:
-
setUserCollection
public void setUserCollection(Collection<Object> userCollection)
- Parameters:
userCollection-
-
getAnnotationType
public AbstractSequence.AnnotationType getAnnotationType()
- Returns:
- the annotation
-
setAnnotationType
public void setAnnotationType(AbstractSequence.AnnotationType annotationType)
- Parameters:
annotationType- the annotation to set
-
getDescription
public String getDescription()
- Returns:
- the description
-
setDescription
public void setDescription(String description)
- Parameters:
description- the description to set
-
getOriginalHeader
public String getOriginalHeader()
- Returns:
- the originalHeader
-
setOriginalHeader
public void setOriginalHeader(String originalHeader)
- Parameters:
originalHeader- the originalHeader to set
-
getParentSequence
public AbstractSequence<?> getParentSequence()
- Returns:
- the parentSequence
-
setParentSequence
public void setParentSequence(AbstractSequence<?> parentSequence)
- Parameters:
parentSequence- the parentSequence to set
-
getSource
public String getSource()
Added support for the source of this sequence for GFF3 export If a sub sequence doesn't have source then check for parent source- Returns:
- the source
-
setSource
public void setSource(String source)
Added support for the source of this sequence for GFF3 export- Parameters:
source- the source to set
-
addNote
public void addNote(String note)
Add notes about this sequence that will get exported for GFF3- Parameters:
note-
-
removeNote
public void removeNote(String note)
-
getNotesList
public ArrayList<String> getNotesList()
- Returns:
- the notesList
-
setNotesList
public void setNotesList(ArrayList<String> notesList)
- Parameters:
notesList- the notesList to set
-
getSequenceScore
public Double getSequenceScore()
Provide place holder for a metric that indicate a score associated with the sequence- Returns:
- the sequenceScore
-
setSequenceScore
public void setSequenceScore(Double sequenceScore)
- Parameters:
sequenceScore- the sequenceScore to set
-
getReferences
public List<AbstractReference> getReferences()
- Returns:
- the list of
AbstractReference - Since:
- 5.0.0
-
setReferences
public void setReferences(List<AbstractReference> references)
Set the list ofAbstractReference- Parameters:
references-- Since:
- 5.0.0
-
getFeatures
public List<FeatureInterface<AbstractSequence<C>,C>> getFeatures(String featureType, int bioSequencePosition)
Return features at a sequence position by type- Parameters:
featureType-bioSequencePosition-- Returns:
-
getFeatures
public List<FeatureInterface<AbstractSequence<C>,C>> getFeatures(int bioSequencePosition)
Return features at a sequence position- Parameters:
bioSequencePosition-- Returns:
-
getFeatures
public List<FeatureInterface<AbstractSequence<C>,C>> getFeatures()
- Returns:
-
addFeature
public void addFeature(int bioStart, int bioEnd, FeatureInterface<AbstractSequence<C>,C> feature)
Method to help set the proper details for a feature as it relates to a sequence where the feature needs to have a location on the sequence- Parameters:
bioStart-bioEnd-feature-
-
addFeature
public void addFeature(FeatureInterface<AbstractSequence<C>,C> feature)
Add a feature to this sequence. The feature will be added to the collection where the order is start position and if more than one feature at the same start position then longest is added first. This helps on doing feature layout for displaying features in SequenceFeaturePanel- Parameters:
feature-
-
removeFeature
public void removeFeature(FeatureInterface<AbstractSequence<C>,C> feature)
Remove a feature from the sequence- Parameters:
feature-
-
getFeaturesByType
public List<FeatureInterface<AbstractSequence<C>,C>> getFeaturesByType(String type)
- Parameters:
type-- Returns:
-
getComments
public List<String> getComments()
- Returns:
- comments
-
setComments
public void setComments(List<String> comments)
Set comments.- Parameters:
comments-
-
getFeaturesKeyWord
public FeaturesKeyWordInterface getFeaturesKeyWord()
- Returns:
- the featuresKeyWord
-
setFeaturesKeyWord
public void setFeaturesKeyWord(FeaturesKeyWordInterface featuresKeyWord)
- Parameters:
featuresKeyWord- the featuresKeyWord to set
-
getDatabaseReferences
public DatabaseReferenceInterface getDatabaseReferences()
- Returns:
- the databaseReferences
-
setDatabaseReferences
public void setDatabaseReferences(DatabaseReferenceInterface databaseReferences)
- Parameters:
databaseReferences- the databaseReferences to set
-
getFeatureRetriever
public FeatureRetriever getFeatureRetriever()
-
setFeatureRetriever
public void setFeatureRetriever(FeatureRetriever featureRetriever)
-
getAccession
public AccessionID getAccession()
Description copied from interface:AccessionedReturns the AccessionID this location is currently bound with- Specified by:
getAccessionin interfaceAccessioned- Returns:
- the accession
-
setAccession
public void setAccession(AccessionID accession)
- Parameters:
accession- the accession to set
-
getTaxonomy
public TaxonomyID getTaxonomy()
- Returns:
- the species
-
setTaxonomy
public void setTaxonomy(TaxonomyID taxonomy)
- Parameters:
taxonomy- the species to set
-
getCompoundSet
public CompoundSet<C> getCompoundSet()
Description copied from interface:SequenceGets the compound set used to back this Sequence- Specified by:
getCompoundSetin interfaceSequence<C extends Compound>
-
setCompoundSet
public void setCompoundSet(CompoundSet<C> compoundSet)
-
getSequenceAsString
public String getSequenceAsString(Integer bioStart, Integer bioEnd, Strand strand)
- Parameters:
bioStart-bioEnd-strand-- Returns:
-
getSequenceAsString
public String getSequenceAsString()
Default case is to assume strand is positive because only CDSSequence can be either positive or negative Strand.- Specified by:
getSequenceAsStringin interfaceSequence<C extends Compound>- Returns:
-
getAsList
public List<C> getAsList()
Description copied from interface:SequenceReturns the Sequence as a List of compounds
-
getCompoundAt
public C getCompoundAt(int position)
Description copied from interface:SequenceReturns the Compound at the given biological index- Specified by:
getCompoundAtin interfaceSequence<C extends Compound>- Parameters:
position- The 1-indexed position of the amino acid- Returns:
-
getIndexOf
public int getIndexOf(C compound)
Description copied from interface:SequenceScans through the Sequence looking for the first occurrence of the given compound- Specified by:
getIndexOfin interfaceSequence<C extends Compound>- Parameters:
compound-- Returns:
- The first index of compound in this sequence (1-based)
-
getLastIndexOf
public int getLastIndexOf(C compound)
Description copied from interface:SequenceScans through the Sequence looking for the last occurrence of the given compound- Specified by:
getLastIndexOfin interfaceSequence<C extends Compound>- Parameters:
compound-- Returns:
- The last index of compound in this sequence (1-based)
-
getLength
public int getLength()
Description copied from interface:SequenceReturns the length of the Sequence
-
getSubSequence
public SequenceView<C> getSubSequence(Integer bioStart, Integer bioEnd)
Description copied from interface:SequenceReturns a portion of the sequence from the different positions. This is indexed from 1- Specified by:
getSubSequencein interfaceSequence<C extends Compound>- Parameters:
bioStart-bioEnd-- Returns:
-
countCompounds
public int countCompounds(C... compounds)
Description copied from interface:SequenceReturns the number of times we found a compound in the Sequence- Specified by:
countCompoundsin interfaceSequence<C extends Compound>- Parameters:
compounds-- Returns:
-
getInverse
public SequenceView<C> getInverse()
Description copied from interface:SequenceDoes the right thing to get the inverse of the current Sequence. This means either reversing the Sequence and optionally complementing the Sequence.- Specified by:
getInversein interfaceSequence<C extends Compound>- Returns:
-
-