10 #include "utils/scaffolding_typedefs.hpp"
16 void read_fasta_file(std::istream& input, SequenceMap& name_to_seq,
const std::string& acceptable_bases = BASES)
18 SequenceMap::iterator current_entry;
24 while(std::getline(input, line).good()){
30 std::string trimmed_line(
trim(line.erase(0, 1)));
33 boost::tie(current_entry, success) = name_to_seq.DEEP_EMPLACE(
trim(line),
"");
34 if(!success)
throw except::bad_syntax(line_no, (std::string)
"repeated contig name: " + line);
37 if(current_entry == name_to_seq.end())
throw except::bad_syntax(line_no,
"missing contig name");
39 if(line.find_first_not_of(acceptable_bases) != std::string::npos)
40 throw except::bad_syntax(line_no, (std::string)
"contains a base that's not in " + acceptable_bases);
42 current_entry->second.sequence += line;
an exception for the case that a given file does not conform to expected syntax
Definition: exceptions.hpp:56
Definition: read_adj_list.hpp:22
Definition: read_phytree.hpp:10
std::string trim(const std::string &str, const std::string &to_remove=WHITESPACES)
remove leading & trailing chars (whitespaces by default) from str
Definition: string_utils.hpp:41