namespace spirit = boost::spirit;
#include "alg/sequence.hpp"
+#include "io.hpp"
#include "mussa_exceptions.hpp"
#include <string>
return *this;
}
-static void multiplatform_getline(std::istream& in, std::string& line)
-{
- line.clear();
- char c;
- in.get(c);
- while(in.good() and !(c == '\012' or c == '\015') ) {
- line.push_back(c);
- in.get(c);
- }
- // if we have cr-lf eat it
- c = in.peek();
- if (c=='\012' or c == '\015') {
- in.get();
- }
-}
-
void Sequence::load_fasta(fs::path file_path, int seq_num, int start_index, int end_index)
{
load_fasta(file_path, reduced_nucleic_alphabet, seq_num, start_index, end_index);
throw mussa_load_error("Error loading annotation file " + file_path.string());
}
+ try {
+ load_annot(data_stream, start_index, end_index);
+ } catch(annotation_load_error e) {
+ std::ostringstream msg;
+ msg << file_path.native_file_string()
+ << " "
+ << e.what();
+ throw annotation_load_error(msg.str());
+ }
+ data_stream.close();
+}
+
+void
+Sequence::load_annot(std::istream& data_stream, int start_index, int end_index)
+{
// so i should probably be passing the parse function some iterators
// but the annotations files are (currently) small, so i think i can
// get away with loading the whole file into memory
data_stream.get(c);
data.push_back(c);
}
- data_stream.close();
- try {
- parse_annot(data, start_index, end_index);
- } catch(annotation_load_error e) {
- std::ostringstream msg;
- msg << file_path.native_file_string()
- << " "
- << e.what();
- throw annotation_load_error(msg.str());
- }
+ parse_annot(data, start_index, end_index);
}
/* If this works, yikes, this is some brain hurting code.