// ----------------------------------------
// ---------- sequence.cc -----------
// ----------------------------------------
+#include <boost/filesystem/fstream.hpp>
#include "alg/sequence.hpp"
#include "mussa_exceptions.hpp"
#include <string>
#include <iostream>
+namespace fs = boost::filesystem;
using namespace std;
annot::annot()
* \return error message, empty string if no error. (gag!)
*/
void
-Sequence::load_fasta(string file_path, int seq_num,
+Sequence::load_fasta(fs::path file_path, int seq_num,
int start_index, int end_index)
{
- fstream data_file;
+ fs::fstream data_file;
string file_data_line;
int header_counter = 0;
bool read_seq = true;
string sequence_raw;
string seq_tmp; // holds sequence during basic filtering
- data_file.open(file_path.c_str(), ios::in);
+ data_file.open(file_path, ios::in);
if (seq_num == 0) {
throw mussa_load_error("fasta sequence number is 1 based (can't be 0)");
}
if (!data_file)
{
- throw mussa_load_error("Sequence File: " + file_path + " not found");
+ throw mussa_load_error("Sequence File: " + file_path.string() + " not found");
}
// if file opened okay, read it
else
void
-Sequence::load_annot(string file_path, int start_index, int end_index)
+Sequence::load_annot(fs::path file_path, int start_index, int end_index)
{
- fstream data_file;
+ fs::fstream data_file;
string file_data_line;
annot an_annot;
string::size_type space_split_i;
annots.clear();
- data_file.open(file_path.c_str(), ios::in);
+ data_file.open(file_path, ios::in);
if (!data_file)
{
- throw mussa_load_error("Sequence File: " + file_path + " not found");
+ throw mussa_load_error("Sequence File: " + file_path.string() + " not found");
}
// if file opened okay, read it
else
an_annot.end -= start_index;
annots.push_back(an_annot);
}
- else
- cout << "FAILED!!!!!!\n";
+ // else no (or bogus) annotations
}
}
}
void
-Sequence::save(fstream &save_file)
+Sequence::save(fs::fstream &save_file)
//string save_file_path)
{
//fstream save_file;
}
void
-Sequence::load_museq(string load_file_path, int seq_num)
+Sequence::load_museq(fs::path load_file_path, int seq_num)
{
- fstream load_file;
+ fs::fstream load_file;
string file_data_line;
int seq_counter;
annot an_annot;
string annot_value;
annots.clear();
- load_file.open(load_file_path.c_str(), ios::in);
+ load_file.open(load_file_path, ios::in);
seq_counter = 0;
// search for the seq_num-th sequence