40 #ifndef _SEQUENCEFEATURE_H_
41 #define _SEQUENCEFEATURE_H_
87 SeqRange(
size_t a,
size_t b,
char strand =
'.'):
89 if (strand !=
'+' && strand !=
'-' && strand !=
'?' && strand !=
'.')
99 if (strand !=
'+' && strand !=
'-' && strand !=
'?' && strand !=
'.')
149 virtual const std::string&
getId()
const = 0;
153 virtual void setId(
const std::string&
id) = 0;
176 virtual const std::string&
getType()
const = 0;
180 virtual void setType(
const std::string& type) = 0;
195 virtual const size_t size()
const {
262 virtual const std::string&
getAttribute(
const std::string& attribute)
const = 0;
281 virtual void setAttribute(
const std::string& attribute,
const std::string& value) = 0;
312 const std::string&
id,
313 const std::string& seqId,
314 const std::string& source,
315 const std::string& type,
348 std::map<std::string, std::string>::iterator it =
attributes_.find(attribute);
359 void setAttribute(
const std::string& attribute,
const std::string& value) {
364 std::set< std::string > d;
365 for (std::map<std::string, std::string>::iterator it =
attributes_.begin() ; it !=
attributes_.end() ; it++) {
372 std::map<std::string, std::string>::iterator it =
attributes_.find(attribute);
430 for (std::vector<SequenceFeature*>::const_iterator it = sfs.
features_.begin();
439 for (std::vector<SequenceFeature*>::const_iterator it = sfs.
features_.begin();
453 for (std::vector<SequenceFeature*>::iterator it =
features_.begin();
501 std::set<std::string> seqIds;
502 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
505 seqIds.insert((**it).getSequenceId());
514 std::set<std::string> types;
515 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
518 types.insert((**it).getType());
529 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
543 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
546 if ((**it).getSequenceId() == seqId) {
558 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
561 if ((**it).getType() == type) {
574 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
577 if (std::find(types.begin(), types.end(), (**it).getType()) != types.end()) {
590 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
593 if ((**it).getSequenceId() ==
id) {
606 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
609 if (std::find(ids.begin(), ids.end(), (**it).getSequenceId()) != ids.end()) {
624 for (std::vector<SequenceFeature*>::const_iterator it =
features_.begin();
628 if ((**it).isIncludedIn(range))
631 if ((**it).overlap(range))
A very simple implementation of the SequenceFeature class.
const std::string & getSource() const
void setAttribute(const std::string &attribute, const std::string &value)
Set the value of an attribute.
const std::string & getSequenceId() const
const std::string & getAttribute(const std::string &attribute) const
const std::string & getId() const
void removeAttribute(const std::string &attribute)
virtual BasicSequenceFeature * clone() const
bool isNegativeStrand() const
const size_t getStart() const
std::string & getAttribute(const std::string &attribute)
SeqRange getRange() const
std::map< std::string, std::string > attributes_
std::set< std::string > getAttributeList() const
virtual bool isIncludedIn(const SeqRange &range) const
const double & getScore() const
bool overlap(const SeqRange &range) const
void setId(const std::string &id)
void setSequenceId(const std::string &sid)
const std::string & getType() const
BasicSequenceFeature(const std::string &id, const std::string &seqId, const std::string &source, const std::string &type, size_t start, size_t end, char strand, double score=-1)
const size_t getEnd() const
void setSource(const std::string &source)
void setType(const std::string &type)
void setScore(double score)
virtual bool includes(const SeqRange &range) const
bool overlap(const SequenceFeature &feat) const
virtual void addRange(const Range< T > &r)=0
bool contains(const Range &r) const
bool overlap(const Range &r) const
a coordinate range on a sequence. Stores coordinates as a Range<size_t> object, but also keep the str...
SeqRange(size_t a, size_t b, char strand='.')
virtual bool isStranded() const
SeqRange(const Range< size_t > range, char strand='.')
virtual char getStrand() const
virtual bool isNegativeStrand() const
A simple ensemble of sequence features.
virtual ~SequenceFeatureSet()
void fillRangeCollectionForSequence(const std::string &seqId, RangeCollection< size_t > &coords) const
Get all coordinates of features for a given source. All ranges are added to a RangeCollection contain...
SequenceFeatureSet * getSubsetForRange(const SeqRange &range, bool complete) const
void addFeature(const SequenceFeature &feature)
Add a feature to the container. The feature will be copied and the copy owned by the container.
void fillRangeCollection(RangeCollection< size_t > &coords) const
Get all coordinates of features. All ranges are added to a RangeCollection container,...
std::vector< SequenceFeature * > features_
SequenceFeatureSet * getSubsetForType(const std::string &type) const
SequenceFeatureSet & operator=(const SequenceFeatureSet &sfs)
SequenceFeatureSet * getSubsetForSequences(const std::vector< std::string > &ids) const
std::set< std::string > getTypes() const
void clear()
Delete all features in this set.
const SequenceFeature & operator[](size_t i) const
SequenceFeatureSet(const SequenceFeatureSet &sfs)
SequenceFeatureSet * getSubsetForTypes(const std::vector< std::string > &types) const
SequenceFeatureSet * getSubsetForSequence(const std::string &id) const
size_t getNumberOfFeatures() const
const SequenceFeature & getFeature(size_t i) const
std::set< std::string > getSequences() const
The base interface for sequence features.
virtual std::set< std::string > getAttributeList() const =0
virtual void setId(const std::string &id)=0
virtual SeqRange getRange() const =0
virtual const std::string & getType() const =0
virtual bool isPoint() const
virtual bool includes(const SeqRange &range) const =0
virtual SequenceFeature * clone() const =0
virtual void removeAttribute(const std::string &attribute)=0
virtual const std::string & getSource() const =0
virtual const size_t getEnd() const =0
virtual void setSequenceId(const std::string &id)=0
virtual bool isStranded() const =0
virtual bool overlap(const SequenceFeature &feat) const =0
virtual const std::string & getAttribute(const std::string &attribute) const =0
virtual bool isEmpty() const
static const std::string NO_ATTRIBUTE_SET
virtual void setAttribute(const std::string &attribute, const std::string &value)=0
Set the value of an attribute.
virtual void setScore(double score)=0
virtual const std::string & getId() const =0
virtual bool isIncludedIn(const SeqRange &range) const =0
virtual const size_t getStart() const =0
virtual const std::string & getSequenceId() const =0
virtual const double & getScore() const =0
virtual void setSource(const std::string &source)=0
virtual void setType(const std::string &type)=0
virtual const size_t size() const
virtual std::string & getAttribute(const std::string &attribute)=0
virtual bool isNegativeStrand() const =0
virtual bool overlap(const SeqRange &range) const =0