Commit afca1d86 authored by Mathieu Giraud's avatar Mathieu Giraud

core/fasta.{h,cpp}: getPos(), number of characters read

Note that input->tellg() was not working (not compatible with igzstream ?)
parent 44b3d712
...@@ -133,11 +133,16 @@ OnlineFasta::~OnlineFasta() { ...@@ -133,11 +133,16 @@ OnlineFasta::~OnlineFasta() {
} }
void OnlineFasta::init() { void OnlineFasta::init() {
char_nb = 0;
line_nb = 0; line_nb = 0;
line = getInterestingLine(); line = getInterestingLine();
current.seq = NULL; current.seq = NULL;
} }
unsigned long long OnlineFasta::getPos() {
return char_nb;
}
size_t OnlineFasta::getLineNb() { size_t OnlineFasta::getLineNb() {
return line_nb; return line_nb;
} }
...@@ -226,6 +231,7 @@ string OnlineFasta::getInterestingLine(int state) { ...@@ -226,6 +231,7 @@ string OnlineFasta::getInterestingLine(int state) {
string line; string line;
while (line.length() == 0 && hasNext() && getline(*input, line)) { while (line.length() == 0 && hasNext() && getline(*input, line)) {
line_nb++; line_nb++;
char_nb += line.length() + 1;
remove_trailing_whitespaces(line); remove_trailing_whitespaces(line);
if (line.length() && line[0] == '#' && state != FASTX_FASTQ_SEP) if (line.length() && line[0] == '#' && state != FASTX_FASTQ_SEP)
......
...@@ -91,6 +91,7 @@ class OnlineFasta { ...@@ -91,6 +91,7 @@ class OnlineFasta {
string line; string line;
bool input_allocated; bool input_allocated;
size_t line_nb; size_t line_nb;
unsigned long long char_nb;
public: public:
...@@ -113,7 +114,12 @@ class OnlineFasta { ...@@ -113,7 +114,12 @@ class OnlineFasta {
int extract_field=0, string extract_separator="|"); int extract_field=0, string extract_separator="|");
~OnlineFasta(); ~OnlineFasta();
/**
* @return the position in the file
*/
unsigned long long getPos();
/** /**
* @return the current line number * @return the current line number
*/ */
......
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