data.push_back(c);
}
data_stream.close();
-
- parse_annot(data, start_index, end_index);
+
+ 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());
+ }
}
/* If this works, yikes, this is some brain hurting code.
std::string seq;
std::list<annot> parsed_annots;
std::list<Sequence> query_seqs;
- int parsed=1;
+ int parsed=0;
bool ok = spirit::parse(data.begin(), data.end(),
(
"5' flank");
}
-BOOST_AUTO_TEST_CASE( sequence_load_error )
+BOOST_AUTO_TEST_CASE( sequence_load_fasta_error )
{
fs::path seq_path(fs::path(EXAMPLE_DIR, fs::native)/"seq");
seq_path /= "broken.fa";
BOOST_CHECK_EQUAL(seq_path.native_file_string(), exception_filename);
}
+BOOST_AUTO_TEST_CASE( sequence_load_annot_error )
+{
+ fs::path seq_path(fs::path(EXAMPLE_DIR, fs::native)/"seq");
+ seq_path /= "mouse_mck_pro.fa";
+ fs::path annot_path(fs::path(EXAMPLE_DIR, fs::native));
+ annot_path /= "broken.annot";
+ bool exception_thrown = false;
+ Sequence s;
+ s.load_fasta(seq_path);
+
+ std::string exception_filename;
+ try {
+ s.load_annot(annot_path, 0, 0);
+ } catch(annotation_load_error e) {
+ exception_thrown = true;
+ std:string estr(e.what());
+ size_t native_string_size = annot_path.native_file_string().size();
+ BOOST_REQUIRE(estr.size() > native_string_size);
+ std::copy(estr.begin(), estr.begin()+native_string_size,
+ std::back_inserter(exception_filename));
+ }
+ BOOST_CHECK_EQUAL(exception_thrown, true);
+ BOOST_CHECK_EQUAL(annot_path.native_file_string(), exception_filename);
+}
+
BOOST_AUTO_TEST_CASE( sequence_load_dna_reduced )
{
std::string reduced_dna_fasta_string(">foo\nAAGGCCTTNN\n");