Commit c5c3405e authored by Mikaël Salson's avatar Mikaël Salson
Browse files

Fasta: add() method for Sequence.

Just consists of what was previously done in operator>>
parent dd0a58d4
...@@ -75,6 +75,11 @@ void Fasta::add(const string &filename, bool verbose) { ...@@ -75,6 +75,11 @@ void Fasta::add(const string &filename, bool verbose) {
is.close(); is.close();
} }
void Fasta::add(Sequence seq) {
reads.push_back(seq);
total_size += seq.sequence.size();
}
int Fasta::size() const{ return (int)reads.size(); } int Fasta::size() const{ return (int)reads.size(); }
list<Sequence> Fasta::getAll() const { list<Sequence> Fasta::getAll() const {
list<Sequence> reads; list<Sequence> reads;
...@@ -242,8 +247,7 @@ istream& operator>>(istream& in, Fasta& fasta){ ...@@ -242,8 +247,7 @@ istream& operator>>(istream& in, Fasta& fasta){
while (of.hasNext()) { while (of.hasNext()) {
of.next(); of.next();
fasta.reads.push_back(of.getSequence()); fasta.add(of.getSequence());
fasta.total_size += of.getSequence().sequence.size();
} }
return in; return in;
} }
......
...@@ -71,6 +71,8 @@ public: ...@@ -71,6 +71,8 @@ public:
* if the content is not valid * if the content is not valid
*/ */
void add(const string &filename, bool verbose=true); void add(const string &filename, bool verbose=true);
void add(const Sequence sequence);
friend istream& operator>>(istream&, Fasta&); friend istream& operator>>(istream&, Fasta&);
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment