Commit 2b23d6cc authored by Mathieu Giraud's avatar Mathieu Giraud

core/fasta.{h,cpp}: Fasta parser, remember a marked position from the gapped sequence

The gapped sequences should be all aligned. One may want to remember a specific position.
parent fdbbde92
......@@ -168,19 +168,26 @@ OnlineFasta::~OnlineFasta() {
}
void OnlineFasta::init() {
mark_pos = 0;
nb_sequences_parsed = 0;
nb_sequences_returned = 0;
char_nb = 0;
line_nb = 0;
line = getInterestingLine();
current.seq = NULL;
current.marked_pos = 0;
current_gaps = 0;
line = getInterestingLine();
}
unsigned long long OnlineFasta::getPos() {
return char_nb;
}
void OnlineFasta::setMarkPos(int mark_pos) {
this -> mark_pos = mark_pos;
}
size_t OnlineFasta::getLineNb() {
return line_nb;
}
......@@ -225,6 +232,11 @@ void OnlineFasta::addLineToCurrentSequence(string line)
}
current.sequence += c;
if (mark_pos) {
if (current.sequence.length() + current_gaps == mark_pos)
current.marked_pos = current.sequence.length();
}
}
}
......@@ -239,6 +251,7 @@ void OnlineFasta::next() {
if (current.seq) {
delete [] current.seq;
current.seq = NULL;
current.marked_pos = 0;
current_gaps = 0;
}
......
......@@ -17,6 +17,7 @@ typedef struct read_t
string sequence; // Sequence: original string representation
string quality;
int* seq; // Sequence: seq representation
int marked_pos; // Some marked position in the sequence
} Sequence;
typedef enum {
......@@ -35,6 +36,7 @@ class Fasta
int total_size;
int extract_field;
int mark_pos;
string extract_separator;
vector<Sequence> reads;
......@@ -103,6 +105,7 @@ class OnlineFasta {
size_t line_nb;
unsigned long long char_nb;
int mark_pos;
void addLineToCurrentSequence(string line);
int nb_sequences_parsed;
......@@ -135,6 +138,11 @@ class OnlineFasta {
~OnlineFasta();
/**
* sets a position to be followed in gapped sequences
*/
void setMarkPos(int mark_pos);
/**
* @return the position in the file
*/
......
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