org.biojava3.core.sequence.template
Class AbstractSequence<C extends Compound>

java.lang.Object
  extended by org.biojava3.core.sequence.template.AbstractSequence<C>
Type Parameters:
C -
All Implemented Interfaces:
java.lang.Iterable<C>, Accessioned, Sequence<C>
Direct Known Subclasses:
BasicSequence, DNASequence, ProteinSequence, RNASequence

public abstract class AbstractSequence<C extends Compound>
extends java.lang.Object
implements Sequence<C>

The base class for DNA, RNA and Protein sequences.


Nested Class Summary
static class AbstractSequence.AnnotationType
           
 
Constructor Summary
AbstractSequence()
           
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.
AbstractSequence(java.lang.String seqString, CompoundSet<C> compoundSet)
          Create a Sequence from a simple string where the values should be found in compoundSet
 
Method Summary
 void addFeature(FeatureInterface<AbstractSequence<C>,C> feature)
          Add a feature to this sequence.
 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
 void addNote(java.lang.String note)
          Add notes about this sequence that will get exported for GFF3
 int countCompounds(C... compounds)
          Returns the number of times we found a compound in the Sequence
 AccessionID getAccession()
          Returns the AccessionID this location is currently bound with
 AbstractSequence.AnnotationType getAnnotationType()
           
 java.util.List<C> getAsList()
          Returns the Sequence as a List of compounds
 java.lang.Integer getBioBegin()
           
 java.lang.Integer getBioEnd()
           
 C getCompoundAt(int position)
          Returns the Compound at the given biological index
 CompoundSet<C> getCompoundSet()
          Gets the compound set used to back this Sequence
 DatabaseReferenceInterface getDatabaseReferences()
           
 java.lang.String getDescription()
           
 java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeatures()
           
 java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeatures(int bioSequencePosition)
          Return features at a sequence position
 java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeatures(java.lang.String featureType, int bioSequencePosition)
          Return features at a sequence position by type
 java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeaturesByType(java.lang.String type)
           
 FeaturesKeyWordInterface getFeaturesKeyWord()
           
 int getIndexOf(C compound)
          Scans through the Sequence looking for the first occurrence of the given compound
 SequenceView<C> getInverse()
          Does the right thing to get the inverse of the current Sequence.
 int getLastIndexOf(C compound)
          Scans through the Sequence looking for the last occurrence of the given compound
 int getLength()
          Returns the length of the Sequence
 java.util.ArrayList<java.lang.String> getNotesList()
           
 java.lang.String getOriginalHeader()
           
 AbstractSequence<C> getParentSequence()
           
 SequenceReader<C> getProxySequenceReader()
           
 java.lang.String getSequenceAsString()
          Default case is to assume strand is positive because only CDSSequence can be either positive or negative Strand.
 java.lang.String getSequenceAsString(java.lang.Integer bioStart, java.lang.Integer bioEnd, Strand strand)
           
 java.lang.Double getSequenceScore()
          Provide place holder for a metric that indicate a score associated with the sequence
 java.lang.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
 SequenceView<C> getSubSequence(java.lang.Integer bioStart, java.lang.Integer bioEnd)
          Returns a portion of the sequence from the different positions.
 TaxonomyID getTaxonomy()
           
 java.util.Collection<java.lang.Object> getUserCollection()
          Provided for convince if the developer needs to associate data with a sequence
 java.util.Iterator<C> iterator()
           
 void removeFeature(FeatureInterface<AbstractSequence<C>,C> feature)
          Remove a feature from the sequence
 void removeNote(java.lang.String note)
           
 void setAccession(AccessionID accession)
           
 void setAnnotationType(AbstractSequence.AnnotationType annotationType)
           
 void setBioBegin(java.lang.Integer begin)
           
 void setBioEnd(java.lang.Integer end)
           
 void setCompoundSet(CompoundSet<C> compoundSet)
           
 void setDatabaseReferences(DatabaseReferenceInterface databaseReferences)
           
 void setDescription(java.lang.String description)
           
 void setFeaturesKeyWord(FeaturesKeyWordInterface featuresKeyWord)
           
 void setNotesList(java.util.ArrayList<java.lang.String> notesList)
           
 void setOriginalHeader(java.lang.String originalHeader)
           
 void setParentSequence(AbstractSequence<C> parentSequence)
           
 void setProxySequenceReader(SequenceReader<C> proxyLoader)
          Very important method that allows external mappings of sequence data and features.
 void setSequenceScore(java.lang.Double sequenceScore)
           
 void setSource(java.lang.String source)
          Added support for the source of this sequence for GFF3 export
 void setTaxonomy(TaxonomyID taxonomy)
           
 void setUserCollection(java.util.Collection<java.lang.Object> userCollection)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractSequence

public AbstractSequence()

AbstractSequence

public AbstractSequence(java.lang.String seqString,
                        CompoundSet<C> compoundSet)
Create a Sequence from a simple string where the values should be found in compoundSet

Parameters:
seqString -
compoundSet -

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 ProxySequecneReader 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 java.lang.Integer getBioBegin()
Returns:
the bioBegin

setBioBegin

public void setBioBegin(java.lang.Integer begin)
Parameters:
bioBegin - the bioBegin to set

getBioEnd

public java.lang.Integer getBioEnd()
Returns:
the bioEnd

setBioEnd

public void setBioEnd(java.lang.Integer end)
Parameters:
bioEnd - the bioEnd to set

getUserCollection

public java.util.Collection<java.lang.Object> getUserCollection()
Provided for convince if the developer needs to associate data with a sequence

Returns:

setUserCollection

public void setUserCollection(java.util.Collection<java.lang.Object> userCollection)
Parameters:
userCollection -

getAnnotationType

public AbstractSequence.AnnotationType getAnnotationType()
Returns:
the annotation

setAnnotationType

public void setAnnotationType(AbstractSequence.AnnotationType annotationType)
Parameters:
annotation - the annotation to set

getDescription

public java.lang.String getDescription()
Returns:
the description

setDescription

public void setDescription(java.lang.String description)
Parameters:
description - the description to set

getOriginalHeader

public java.lang.String getOriginalHeader()
Returns:
the originalHeader

setOriginalHeader

public void setOriginalHeader(java.lang.String originalHeader)
Parameters:
originalHeader - the originalHeader to set

getParentSequence

public AbstractSequence<C> getParentSequence()
Returns:
the parentSequence

setParentSequence

public void setParentSequence(AbstractSequence<C> parentSequence)
Parameters:
parentSequence - the parentSequence to set

getSource

public java.lang.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(java.lang.String source)
Added support for the source of this sequence for GFF3 export

Parameters:
source - the source to set

addNote

public void addNote(java.lang.String note)
Add notes about this sequence that will get exported for GFF3

Parameters:
note -

removeNote

public void removeNote(java.lang.String note)

getNotesList

public java.util.ArrayList<java.lang.String> getNotesList()
Returns:
the notesList

setNotesList

public void setNotesList(java.util.ArrayList<java.lang.String> notesList)
Parameters:
notesList - the notesList to set

getSequenceScore

public java.lang.Double getSequenceScore()
Provide place holder for a metric that indicate a score associated with the sequence

Returns:
the sequenceScore

setSequenceScore

public void setSequenceScore(java.lang.Double sequenceScore)
Parameters:
sequenceScore - the sequenceScore to set

getFeatures

public java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeatures(java.lang.String featureType,
                                                                           int bioSequencePosition)
Return features at a sequence position by type

Parameters:
featureType -
bioSequencePosition -
Returns:

getFeatures

public java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeatures(int bioSequencePosition)
Return features at a sequence position

Parameters:
featureType -
bioSequencePosition -
Returns:

getFeatures

public java.util.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 java.util.List<FeatureInterface<AbstractSequence<C>,C>> getFeaturesByType(java.lang.String type)
Parameters:
type -
Returns:

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

getAccession

public AccessionID getAccession()
Description copied from interface: Accessioned
Returns the AccessionID this location is currently bound with

Specified by:
getAccession in interface Accessioned
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:
species - the species to set

getCompoundSet

public CompoundSet<C> getCompoundSet()
Description copied from interface: Sequence
Gets the compound set used to back this Sequence

Specified by:
getCompoundSet in interface Sequence<C extends Compound>

setCompoundSet

public void setCompoundSet(CompoundSet<C> compoundSet)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSequenceAsString

public java.lang.String getSequenceAsString(java.lang.Integer bioStart,
                                            java.lang.Integer bioEnd,
                                            Strand strand)
Parameters:
begin -
end -
strand -
Returns:

getSequenceAsString

public java.lang.String getSequenceAsString()
Default case is to assume strand is positive because only CDSSequence can be either positive or negative Strand.

Specified by:
getSequenceAsString in interface Sequence<C extends Compound>
Returns:

getAsList

public java.util.List<C> getAsList()
Description copied from interface: Sequence
Returns the Sequence as a List of compounds

Specified by:
getAsList in interface Sequence<C extends Compound>
Returns:

getCompoundAt

public C getCompoundAt(int position)
Description copied from interface: Sequence
Returns the Compound at the given biological index

Specified by:
getCompoundAt in interface Sequence<C extends Compound>
Parameters:
position - The 1-indexed position of the amino acid
Returns:

getIndexOf

public int getIndexOf(C compound)
Description copied from interface: Sequence
Scans through the Sequence looking for the first occurrence of the given compound

Specified by:
getIndexOf in interface Sequence<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: Sequence
Scans through the Sequence looking for the last occurrence of the given compound

Specified by:
getLastIndexOf in interface Sequence<C extends Compound>
Parameters:
compound -
Returns:
The last index of compound in this sequence (1-based)

getLength

public int getLength()
Description copied from interface: Sequence
Returns the length of the Sequence

Specified by:
getLength in interface Sequence<C extends Compound>
Returns:

getSubSequence

public SequenceView<C> getSubSequence(java.lang.Integer bioStart,
                                      java.lang.Integer bioEnd)
Description copied from interface: Sequence
Returns a portion of the sequence from the different positions. This is indexed from 1

Specified by:
getSubSequence in interface Sequence<C extends Compound>
Parameters:
bioStart -
bioEnd -
Returns:

iterator

public java.util.Iterator<C> iterator()
Specified by:
iterator in interface java.lang.Iterable<C extends Compound>
Returns:

countCompounds

public int countCompounds(C... compounds)
Description copied from interface: Sequence
Returns the number of times we found a compound in the Sequence

Specified by:
countCompounds in interface Sequence<C extends Compound>
Parameters:
compounds -
Returns:

getInverse

public SequenceView<C> getInverse()
Description copied from interface: Sequence
Does the right thing to get the inverse of the current Sequence. This means either reversing the Sequence and optionally complementing the Sequence.

Specified by:
getInverse in interface Sequence<C extends Compound>
Returns: