diff --git a/algo/core/fasta.cpp b/algo/core/fasta.cpp index 1a1c8b2637fea10202010ee945f92e86dbc0e9d3..1ad146ac445316a971ad1bc9be3d9192937d3606 100644 --- a/algo/core/fasta.cpp +++ b/algo/core/fasta.cpp @@ -133,11 +133,16 @@ OnlineFasta::~OnlineFasta() { } void OnlineFasta::init() { + char_nb = 0; line_nb = 0; line = getInterestingLine(); current.seq = NULL; } +unsigned long long OnlineFasta::getPos() { + return char_nb; +} + size_t OnlineFasta::getLineNb() { return line_nb; } @@ -226,6 +231,7 @@ string OnlineFasta::getInterestingLine(int state) { string line; while (line.length() == 0 && hasNext() && getline(*input, line)) { line_nb++; + char_nb += line.length() + 1; remove_trailing_whitespaces(line); if (line.length() && line[0] == '#' && state != FASTX_FASTQ_SEP) diff --git a/algo/core/fasta.h b/algo/core/fasta.h index ae39519b4cc858829fb7e6d075ca0d4cc190a7b2..d63815257fbd7d484517753c3b35efb2dd3be0ea 100644 --- a/algo/core/fasta.h +++ b/algo/core/fasta.h @@ -91,6 +91,7 @@ class OnlineFasta { string line; bool input_allocated; size_t line_nb; + unsigned long long char_nb; public: @@ -113,7 +114,12 @@ class OnlineFasta { int extract_field=0, string extract_separator="|"); ~OnlineFasta(); - + + /** + * @return the position in the file + */ + unsigned long long getPos(); + /** * @return the current line number */