15 #include "Nucleotide.h" 27 typedef std::vector<Nucleotide> NucleotideChain;
29 typedef NucleotideChain::iterator NucleotideIter;
31 typedef NucleotideChain::const_iterator ConstNucleotideIter;
39 iterator(
Chain& ch, NucleotideIter it) : NucleotideIter(it), chain_(ch) {}
40 Chain& getChain() {
return chain_; }
44 if(&chain_ != &it.chain_)
46 return static_cast<NucleotideIter
>(*this) ==
static_cast<NucleotideIter
>(it);
56 const_iterator(
const Chain& ch, ConstNucleotideIter it) : ConstNucleotideIter(it), chain_(ch) {}
58 const Chain& getChain()
const {
return chain_; }
62 if(&chain_ != &it.chain_)
64 return static_cast<ConstNucleotideIter
>(*this) ==
static_cast<ConstNucleotideIter
>(it);
73 Chain(
const Chain& ch) : nucleos_(ch.nucleos_) {}
74 Chain(
const std::string& seq) {
75 for(std::string::const_iterator it = seq.begin(); it != seq.end(); ++it)
80 std::copy( begin, end, std::back_inserter(nucleos_) );
91 nucleos_.push_back(val);
96 std::copy(ch.nucleos_.begin(), ch.nucleos_.end(), std::back_insert_iterator<NucleotideChain>(nucleos_) );
110 return const_cast<Nucleotide&
>(
static_cast<const Chain*
>(
this)->
operator[](index) );
114 int getLength()
const {
return static_cast<int>(nucleos_.size() ); }
127 for(NucleotideChain::const_iterator it = nucleos_.begin(); it != nucleos_.end(); ++it) {
128 str +=
static_cast<char>(it->get() );
135 for(NucleotideChain::const_reverse_iterator it = nucleos_.rbegin(); it != nucleos_.rend(); ++it)
140 NucleotideChain nucleos_;
149 int finish = start + length;
150 if( start + length >= chain.
getLength() )
157 return Chain(beg, end);
const_iterator begin() const
Definition: Chain.h:119
Chain createSubChain(const Chain &chain, int start, int length)
Definition: Chain.h:145
the DNA nucleotide
Definition: Nucleotide.h:21
bool operator==(const const_iterator &it) const
Definition: Chain.h:61
Nucleotide & operator[](int index)
Definition: Chain.h:109
int getLength() const
Definition: Chain.h:114
iterator begin()
Definition: Chain.h:117
iterator end()
Definition: Chain.h:121
bool operator!=(const Chain &ch) const
Definition: Chain.h:103
The DNA strand (single).
Definition: Chain.h:25
Chain & operator+=(const Nucleotide &val)
Definition: Chain.h:90
std::string getString() const
Definition: Chain.h:125
Chain complementary() const
Definition: Chain.h:133
bool operator==(const iterator &it) const
Definition: Chain.h:43
bool operator==(const Chain &ch) const
Definition: Chain.h:101
Chain(const const_iterator &begin, const const_iterator &end)
Definition: Chain.h:79
std::ostream & operator<<(std::ostream &os, const Chain &chain)
Definition: Chain.h:162
const_iterator end() const
Definition: Chain.h:123
const Nucleotide & operator[](int index) const
Definition: Chain.h:106
Nucleotide create(const char &n)
Definition: Nucleotide.h:60