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

core/fasta.{h,cpp}: adds (verbose=true) optional argument to some Fasta methods

parent 637bae63
......@@ -39,31 +39,34 @@ Fasta::Fasta(int extract_field, string extract_separator)
}
Fasta::Fasta(const string &input,
int extract_field, string extract_separator)
int extract_field, string extract_separator,
bool verbose)
{
init(extract_field, extract_separator);
if (!input.size()) // Do not open empty filenames (D germline if not segmentD)
return ;
add(input);
add(input, verbose);
}
void Fasta::add(istream &in) {
void Fasta::add(istream &in, bool verbose) {
in >> *this;
if (verbose)
cout << "\t" << setw(6) << total_size << " bp in " << setw(3) << size() << " sequences" << endl ;
}
void Fasta::add(const string &filename) {
void Fasta::add(const string &filename, bool verbose) {
ifstream is(filename.c_str());
if (is.fail())
{
throw invalid_argument(" !! Error in opening file: "+ filename);
}
if (verbose)
cout << " <== " << filename ;
add(is);
add(is, verbose);
is.close();
}
......
......@@ -47,7 +47,8 @@ public:
* valid
*/
Fasta(const string &input,
int extract_field=0, string extract_separator="|");
int extract_field=0, string extract_separator="|",
bool verbose=true);
int size() const;
/**
......@@ -63,13 +64,13 @@ public:
/**
* Add the content of the stream to the current object
*/
void add(istream &in);
void add(istream &in, bool verbose=true);
/**
* Add the content of the file to the current object
* @throws invalid_argument if the file cannot be opened or
* if the content is not valid
*/
void add(const string &filename);
void add(const string &filename, bool verbose=true);
friend istream& operator>>(istream&, Fasta&);
};
......
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