diff --git a/algo/core/fasta.cpp b/algo/core/fasta.cpp index b4e0b439012daa2c6696bc76f49ba41a9b42bac0..d81fdea5f173ae214cf26bf4c9575532988d0866 100644 --- a/algo/core/fasta.cpp +++ b/algo/core/fasta.cpp @@ -269,3 +269,18 @@ ostream &operator<<(ostream &out, const Sequence &seq) { } return out; } + +int nb_sequences_in_fasta(string f) +{ + OnlineFasta *sequences = new OnlineFasta(f, 1, " "); + int nb_sequences = 0 ; + + while (sequences->hasNext()) + { + sequences->next(); + nb_sequences++ ; + } + + cout << " ==> " << nb_sequences << " sequences" << endl; + return nb_sequences ; +} diff --git a/algo/core/fasta.h b/algo/core/fasta.h index 34d6a607c440d2dac26b61f85dd97cb094a2cb29..5eda877bd98a4a69f2c62d9b0bbea17da6cd8f93 100644 --- a/algo/core/fasta.h +++ b/algo/core/fasta.h @@ -160,4 +160,10 @@ istream& operator>>(istream& in, Fasta& fasta); ostream& operator<<(ostream& out, Fasta& fasta); ostream &operator<<(ostream &out, const Sequence &seq); +/** + * Count the number of sequences in a Fasta file + * @return the number of sequences + */ +int nb_sequences_in_fasta(string f); + #endif