const std::string Sequence::protein_alphabet("AaCcDdEeFfGgHhIiKkLlMmNnPpQqRrSsTtVvWwYy\012\015");
Sequence::Sequence()
- : seq_start(0),
+ : parent(0),
+ seq_start(0),
seq_count(0),
strand(UnknownStrand)
{
}
Sequence::Sequence(const char *seq)
- : seq_start(0),
+ : parent(0),
+ seq_start(0),
seq_count(0),
strand(UnknownStrand),
header(""),
}
Sequence::Sequence(const std::string& seq)
- : seq_start(0),
+ : parent(0),
+ seq_start(0),
seq_count(0),
strand(UnknownStrand),
header(""),
}
Sequence::Sequence(const Sequence& o)
- : seq(o.seq),
+ : parent(o.parent),
+ seq(o.seq),
seq_start(o.seq_start),
seq_count(o.seq_count),
strand(o.strand),
Sequence &Sequence::operator=(const Sequence& s)
{
if (this != &s) {
+ parent = s.parent;
seq = s.seq;
seq_start = s.seq_start;
seq_count = s.seq_count;
{
new_seq->append(1, conversionTable[ (int)old_seq[seq_index+start]]);
}
+ parent = 0;
seq = new_seq;
seq_start = 0;
seq_count = count;
}
Sequence
-Sequence::subseq(int start, int count) const
+Sequence::subseq(int start, int count)
{
if (!seq) {
Sequence new_seq;
count = size()-start;
}
Sequence new_seq(*this);
- new_seq.seq_start = start;
+ new_seq.parent = this;
+ new_seq.seq_start = seq_start+start;
new_seq.seq_count = count;
new_seq.motif_list = motif_list;
void
Sequence::clear()
{
+ parent = 0;
seq.reset();
seq_start = 0;
seq_count = 0;
Sequence::size_type Sequence::start() const
{
- return seq_start;
+ if (parent)
+ return seq_start - parent->start();
+ else
+ return seq_start;
}
Sequence::size_type Sequence::stop() const
{
- return seq_start + seq_count;
+ return start() + seq_count;
}
Sequence::size_type Sequence::size() const
size_type stop() const;
//! return a subsequence, copying over any appropriate annotation
- Sequence subseq(int start=0, int count = std::string::npos) const;
+ Sequence subseq(int start=0, int count = std::string::npos);
//! return a reverse compliment (this needs to be improved?)
std::string rev_comp() const;
void load_museq(boost::filesystem::path load_file_path, int seq_num);
private:
+ //! parent sequence
+ Sequence *parent;
//! hold a shared pointer to our sequence string
boost::shared_ptr<seq_string> seq;
//! start offset into the sequence
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /*version*/) {
+ ar & BOOST_SERIALIZATION_NVP(parent);
ar & BOOST_SERIALIZATION_NVP(seq);
ar & BOOST_SERIALIZATION_NVP(seq_start);
ar & BOOST_SERIALIZATION_NVP(seq_count);
BOOST_CHECK_EQUAL( s3.size(), 3);
BOOST_CHECK_EQUAL( s3, s3seq_string);
- // FIXME: updated for ticket:129
- // once I have a solution for ticket:129 the commented
- // out version should work.
- //std::string s4seq_string = s3seq_string.substr(1,1);
- std::string s4seq_string = seq_string.substr(1,1);
- Sequence s4 = s2.subseq(1,1);
+ std::string s4seq_string = s3seq_string.substr(1,1);
+ Sequence s4 = s3.subseq(1,1);
BOOST_CHECK_EQUAL( s4.start(), 1 );
BOOST_CHECK_EQUAL( s4.stop(), 1+1);
BOOST_CHECK_EQUAL( s4.size(), 1);