Commit fdbbde92 authored by Mathieu Giraud's avatar Mathieu Giraud

core/fasta.{h,cpp}: Fasta parser, ignore the gaps ('.') and store their number

parent a914a57e
...@@ -174,6 +174,7 @@ void OnlineFasta::init() { ...@@ -174,6 +174,7 @@ void OnlineFasta::init() {
line_nb = 0; line_nb = 0;
line = getInterestingLine(); line = getInterestingLine();
current.seq = NULL; current.seq = NULL;
current_gaps = 0;
} }
unsigned long long OnlineFasta::getPos() { unsigned long long OnlineFasta::getPos() {
...@@ -213,7 +214,18 @@ void OnlineFasta::skipToNthSequence() { ...@@ -213,7 +214,18 @@ void OnlineFasta::skipToNthSequence() {
void OnlineFasta::addLineToCurrentSequence(string line) void OnlineFasta::addLineToCurrentSequence(string line)
{ {
current.sequence += line; for (char& c : line)
{
if (c == ' ')
continue ;
if (c == '.') {
current_gaps++;
continue ;
}
current.sequence += c;
}
} }
void OnlineFasta::next() { void OnlineFasta::next() {
...@@ -227,6 +239,7 @@ void OnlineFasta::next() { ...@@ -227,6 +239,7 @@ void OnlineFasta::next() {
if (current.seq) { if (current.seq) {
delete [] current.seq; delete [] current.seq;
current.seq = NULL; current.seq = NULL;
current_gaps = 0;
} }
if (hasNextData()) { if (hasNextData()) {
......
...@@ -93,6 +93,8 @@ public: ...@@ -93,6 +93,8 @@ public:
class OnlineFasta { class OnlineFasta {
private: private:
Sequence current; Sequence current;
int current_gaps;
istream *input; istream *input;
int extract_field; int extract_field;
string extract_separator; string extract_separator;
......
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