// ---------- flp.cc -----------
// ----------------------------------------
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/fstream.hpp>
+namespace fs = boost::filesystem;
+
#include "alg/flp.hpp"
-#include <fstream>
#include <iostream>
#include <string>
#include <stdexcept>
#include <cassert>
+#include "mussa_exceptions.hpp"
using namespace std;
bool operator==(const FLPs::match& a, const FLPs::match& b)
}
void
-FLPs::save(string save_file_path)
+FLPs::save(fs::path save_file_path)
{
if (all_matches == 0)
throw runtime_error("please call FLPs.seqcomp first");
- fstream save_file;
- save_file.open(save_file_path.c_str(), ios::out);
+ fs::fstream save_file;
+ save_file.open(save_file_path, ios::out);
save_file << "<Seqcomp win=" << window_size
<< " thres=" << hard_threshold << endl;
}
void
-FLPs::load(string file_path)
+FLPs::load(fs::path file_path)
{
- fstream data_file;
+ fs::fstream data_file;
string file_data, file_data_line, pair_data, index_data, score_data;
match a_match;
string::size_type split_index, comma_index;
// initialize our all_matches pointer
alloc_matches();
-
- data_file.open(file_path.c_str(), ios::in);
-
- getline(data_file,file_data_line);
- // parse seqcomp open tag and parameters
- // eg <Seqcomp type=mussa win=30 thres=21>
- // if parse successful...
- tag_open = true;
-
- while ((!data_file.eof()) && tag_open)
- {
- // intialize list to empty
- a_match_list.clear();
+ if (fs::exists(file_path)) {
+ data_file.open(file_path, ios::in);
getline(data_file,file_data_line);
- if (file_data_line == "</Seqcomp>")
- {
- tag_open = false;
- }
- // parse line of matches
- else if (file_data_line == "")
- {
- //cout << "empty line\n";
- all_matches->push_back(a_match_list);
- }
- else
+ // parse seqcomp open tag and parameters
+ // eg <Seqcomp type=mussa win=30 thres=21>
+ // if parse successful...
+ tag_open = true;
+
+ while ((data_file.good()) && tag_open)
{
- split_index = file_data_line.find(" ");
-
- while (split_index != string::npos)
- {
- pair_data = file_data_line.substr(0,split_index);
- file_data_line = file_data_line.substr(split_index+1);
- //cout << "pair_data = " << pair_data << "...";
- // parse out the 2 pieces of data, index and score of pair match
- comma_index = pair_data.find(",");
- index_data = pair_data.substr(0, comma_index);
- a_match.index = atoi(index_data.c_str() );
- score_data = pair_data.substr(comma_index+1);
- a_match.score = atoi(score_data.c_str() );
- //cout << a_match.index << "," << a_match.score << " ";
-
- a_match_list.push_back(a_match);
+ // intialize list to empty
+ a_match_list.clear();
+ getline(data_file,file_data_line);
+ if (file_data_line == "</Seqcomp>")
+ {
+ tag_open = false;
+ }
+ // parse line of matches
+ else if (file_data_line == "")
+ {
+ //cout << "empty line\n";
+ all_matches->push_back(a_match_list);
+ }
+ else
+ {
split_index = file_data_line.find(" ");
+
+ while (split_index != string::npos)
+ {
+ pair_data = file_data_line.substr(0,split_index);
+ file_data_line = file_data_line.substr(split_index+1);
+ //cout << "pair_data = " << pair_data << "...";
+ // parse out the 2 pieces of data, index and score of pair match
+ comma_index = pair_data.find(",");
+ index_data = pair_data.substr(0, comma_index);
+ a_match.index = atoi(index_data.c_str() );
+ score_data = pair_data.substr(comma_index+1);
+ a_match.score = atoi(score_data.c_str() );
+ //cout << a_match.index << "," << a_match.score << " ";
+
+ a_match_list.push_back(a_match);
+
+ split_index = file_data_line.find(" ");
+ }
+ all_matches->push_back(a_match_list);
+ //cout << all_matches->size() << "\n";
}
- all_matches->push_back(a_match_list);
- //cout << all_matches->size() << "\n";
}
+ //cout << "windows in flp = " << all_matches->size() << endl;
+ data_file.close();
+ } else {
+ throw mussa_load_error(file_path.string() + "was not found");
}
- //cout << "windows in flp = " << all_matches->size() << endl;
- data_file.close();
+
}
// ---------- flp.hh -----------
// ----------------------------------------
+#include <boost/filesystem/path.hpp>
+
#include <list>
#include <string>
#include <vector>
*/
int size() const;
//! Save all the FLPs to save_file_path
- void save(std::string save_file_path);
+ void save(boost::filesystem::path save_file_path);
//! Load a vector of a lists of FLPs
- void load(std::string file_path);
+ void load(boost::filesystem::path file_path);
private:
//! the number of base pairs in the sliding window
int window_size;
// ----------------------------------------
// ---------- mussa_class.cc -----------
// ----------------------------------------
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/fstream.hpp>
+namespace fs = boost::filesystem;
-#include <fstream>
#include <iostream>
#include <sstream>
return the_seqs;
}
-void Mussa::load_sequence(string seq_file, string annot_file, int fasta_index,
- int sub_seq_start, int sub_seq_end)
+void Mussa::load_sequence(fs::path seq_file, fs::path annot_file,
+ int fasta_index, int sub_seq_start, int sub_seq_end)
{
Sequence aseq;
aseq.load_fasta(seq_file, fasta_index, sub_seq_start, sub_seq_end);
- if (annot_file.size() > 0) {
+ if ( not annot_file.empty() ) {
aseq.load_annot(annot_file, sub_seq_start, sub_seq_end);
}
the_seqs.push_back(aseq);
}
void
-Mussa::load_mupa_file(string para_file_path)
+Mussa::load_mupa_file(fs::path para_file_path)
{
- string file_path_base;
- ifstream para_file;
+ fs::ifstream para_file;
string file_data_line;
- string param, value, annot_file;
+ string param, value;
+ fs::path annot_file;
int split_index, fasta_index;
int sub_seq_start, sub_seq_end;
bool seq_params, did_seq;
// initialize values
clear();
- para_file.open(para_file_path.c_str(), ios::in);
-
// if file was opened, read the parameter values
- if (para_file)
+ if (fs::exists(para_file_path))
{
- // need to find the path to the .mupa file
- parsing_path = true;
- dir_index = 0;
- while (parsing_path)
- {
- new_index = (para_file_path.substr(dir_index)).find("/");
- if (new_index != string::npos)
- dir_index += new_index + 1;
- else
- parsing_path = false;
- }
+ para_file.open(para_file_path, ios::in);
- file_path_base = para_file_path.substr(0,dir_index);
+ // what directory is the mupa file in?
+ fs::path file_path_base = para_file_path.branch_path();
// setup loop by getting file's first line
getline(para_file,file_data_line);
threshold = atoi(value.c_str());
else if (param == "SEQUENCE")
{
- string seq_file = file_path_base + value;
+ fs::path seq_file = file_path_base / value;
//cout << "seq_file_name " << seq_files.back() << endl;
fasta_index = 1;
annot_file = "";
if (param == "FASTA_INDEX")
fasta_index = atoi(value.c_str());
else if (param == "ANNOTATION")
- annot_file = file_path_base + value;
+ annot_file = file_path_base / value;
else if (param == "SEQ_START")
sub_seq_start = atoi(value.c_str());
else if (param == "SEQ_END")
// no file was loaded, signal error
else
{
- throw mussa_load_error("Config File: " + para_file_path + " not found");
+ throw mussa_load_error("Config File: " + para_file_path.string() + " not found");
}
}
void
Mussa::save()
{
- string save_name, save_path, create_dir_cmd, flp_filepath;
- fstream save_file;
+ string save_name;
+ fs::path flp_filepath;
+ fs::fstream save_file;
ostringstream append_info;
int dir_create_status;
+ if (not analysis_name.empty()) {
+ // not sure why, but gotta close file each time since can't pass
+ // file streams
+ save_name = analysis_name;
- // not sure why, but gotta close file each time since can't pass file streams
-
- save_name = analysis_name;
-
- // gotta do bit with adding win & thres if to be appended
- if (win_append)
- {
- append_info.str("");
- append_info << "_w" << window;
- save_name += append_info.str();
- }
-
- if (thres_append)
- {
- append_info.str("");
- append_info << "_t" << threshold;
- save_name += append_info.str();
- }
+ // gotta do bit with adding win & thres if to be appended
+ if (win_append)
+ {
+ append_info.str("");
+ append_info << "_w" << window;
+ save_name += append_info.str();
+ }
-//#include <stdlib.h>
- // ******* use appropriate for os ------- 1 of 4
- // the additions for osX make it more sane where it saves the analysis
- // will come up with a cleaner sol'n later...
- create_dir_cmd = "mkdir " + save_name; //linux
- //create_dir_cmd = "mkdir " + file_path_base + save_name; //osX
+ if (thres_append)
+ {
+ append_info.str("");
+ append_info << "_t" << threshold;
+ save_name += append_info.str();
+ }
+ fs::path save_path( save_name);
- dir_create_status = system( (const char*) create_dir_cmd.c_str());
- //cout << "action: " << dir_create_status << endl;
+ if (not fs::exists(save_path)) {
+ fs::create_directory(save_path);
+ }
+ // save sequence and annots to a special mussa file
+ save_file.open(save_path / (save_name+".museq"), ios::out);
+ save_file << "<Mussa_Sequence>" << endl;
- // save sequence and annots to a special mussa file
+ for(vector<Sequence>::size_type i = 0; i < the_seqs.size(); i++)
+ {
+ the_seqs[i].save(save_file);
+ }
- // ******** use appropriate for OS ---------- 2 of 4
- save_path = save_name + "/" + save_name + ".museq"; //linux
- //save_path = file_path_base + save_name + "/" + save_name + ".museq"; //osX
+ save_file << "</Mussa_Sequence>" << endl;
+ save_file.close();
- save_file.open(save_path.c_str(), ios::out);
- save_file << "<Mussa_Sequence>" << endl;
- //save_file.close();
+ // save nway paths to its mussa save file
+ the_paths.save(save_path / (save_name + ".muway"));
- for(vector<Sequence>::size_type i = 0; i < the_seqs.size(); i++)
- {
- the_seqs[i].save(save_file);
+ for(vector<Sequence>::size_type i = 0; i < the_seqs.size(); i++)
+ for(vector<Sequence>::size_type i2 = i+1; i2 < the_seqs.size(); i2++)
+ {
+ append_info.str("");
+ append_info << "_sp_" << i << "v" << i2;
+ all_comps[i][i2].save(save_path/(save_name+append_info.str()+".flp"));
+ }
}
-
- //save_file.open(save_path.c_str(), ios::app);
- save_file << "</Mussa_Sequence>" << endl;
- save_file.close();
-
- // save nway paths to its mussa save file
-
- // ******** use appropriate for OS -------- 3 of 4
- save_path = save_name + "/" + save_name + ".muway"; //linux
- //save_path = file_path_base + save_name + "/" + save_name + ".muway"; //os X
- the_paths.save(save_path);
-
- for(vector<Sequence>::size_type i = 0; i < the_seqs.size(); i++)
- for(vector<Sequence>::size_type i2 = i+1; i2 < the_seqs.size(); i2++)
- {
- append_info.str("");
- append_info << "_sp_" << i << "v" << i2;
- // ******** use appropriate for OS --------- 4 of 4
- //linux
- save_path = save_name + "/" + save_name + append_info.str() + ".flp";
- //osX
- //save_path = file_path_base + save_name + "/" + save_name + append_info.str() + ".flp";
- all_comps[i][i2].save(save_path);
- }
}
void
-Mussa::save_muway(string save_path)
+Mussa::save_muway(fs::path save_path)
{
the_paths.save(save_path);
}
void
-Mussa::load(string ana_file)
+Mussa::load(fs::path ana_file)
{
int i, i2;
- string::size_type start_index, end_index;
- string file_path_base, a_file_path, ana_path;
+ fs::path file_path_base;
+ fs::path a_file_path;
+ fs::path ana_path(ana_file);
bool parsing_path;
Sequence tmp_seq;
string err_msg;
vector<FLPs> empty_FLP_vector;
FLPs dummy_comp;
- //cout << "ana_file name " << ana_file << endl;
- ana_path = ana_file;
- parsing_path = true;
- end_index = ana_path.size()-1;
- if (ana_path[end_index] == '/') {
- --end_index;
- }
- start_index = ana_path.rfind('/', end_index);
- if (start_index == string::npos) {
- // no / to be found
- start_index = 0;
- } else {
- // skip the / we found
- ++start_index;
- }
- analysis_name = ana_path.substr(start_index, end_index-start_index+1);
+ //cout << "ana_file name " << ana_file.string() << endl;
+ analysis_name = ana_path.leaf();
//cout << " ana_name " << analysis_name << endl;
- file_path_base = ana_path.substr(0, start_index) + analysis_name
- + "/" + analysis_name;
- a_file_path = file_path_base + ".muway";
- //cout << " loading museq: " << a_file_path << endl;
+ file_path_base = ana_path.branch_path() / analysis_name;
+ a_file_path = file_path_base / (analysis_name + ".muway");
+ //cout << " loading museq: " << a_file_path.string() << endl;
the_paths.load(a_file_path);
// perhaps this could be more elegent, but at least this'll let
// us know what our threshold and window sizes were when we load a muway
int seq_num = the_paths.sequence_count();
- a_file_path = file_path_base + ".museq";
+ a_file_path = file_path_base / (analysis_name + ".museq");
// this is a bit of a hack due to C++ not acting like it should with files
for (i = 1; i <= seq_num; i++)
{
tmp_seq.clear();
- //cout << "mussa_class: loading museq frag... " << a_file_path << endl;
+ //cout << "mussa_class: loading museq frag... " << a_file_path.string() << endl;
tmp_seq.load_museq(a_file_path, i);
the_seqs.push_back(tmp_seq);
}
for(i2 = i+1; i2 < seq_num; i2++)
{
append_info.str("");
- append_info << "_sp_" << i << "v" << i2;
+ append_info << analysis_name << "_sp_" << i << "v" << i2 << ".flp";
//cout << append_info.str() << endl;
- a_file_path = file_path_base + append_info.str() + ".flp";
+ a_file_path = file_path_base / append_info.str();
+ //cout << "path " << a_file_path.string() << endl;
all_comps[i][i2].load(a_file_path);
//cout << "real size = " << all_comps[i][i2].size() << endl;
}
void
Mussa::save_old()
{
- fstream save_file;
+ fs::fstream save_file;
- save_file.open(analysis_name.c_str(), ios::out);
+ save_file.open(analysis_name, ios::out);
for(vector<Sequence>::size_type i = 0; i < the_seqs.size(); i++)
save_file << the_seqs[i].get_seq() << endl;
update_sequences_motifs();
}
-void Mussa::load_motifs(string filename)
+void Mussa::load_motifs(fs::path filename)
{
- ifstream f;
- f.open(filename.c_str(), ifstream::in);
+ fs::ifstream f;
+ f.open(filename, ifstream::in);
load_motifs(f);
}
// ----------------------------------------
// ---------- mussa_class.hh -----------
// ----------------------------------------
+#include <boost/filesystem/path.hpp>
#include <list>
#include <string>
Mussa(const Mussa &);
void save();
- void save_muway(std::string save_path);
+ //! save the nway comparison
+ void save_muway(boost::filesystem::path save_path);
//! load a saved analysis directory
- void load(std::string ana_path);
+ void load(boost::filesystem::path ana_path);
//! clear parameters and initialize data lists
void clear();
- // set parameters from a file - 'mupa' ~ mussa parameters
- void load_mupa_file(std::string para_file_path);
+ //! set parameters from a file - 'mupa' ~ mussa parameters
+ void load_mupa_file(boost::filesystem::path para_file_path);
// set parameters individually (eg from user input into gui classes)
//! set analysis name
* \param[in] sub_seq_end ending slice index to select a subsequence
* use 0 to go to the end.
*/
- void load_sequence(std::string seq_file, std::string annot_file,
+ void load_sequence(boost::filesystem::path seq_file,
+ boost::filesystem::path annot_file,
int fasta_index, int sub_seq_start=0, int sub_seq_end=0);
//! allow examining the sequences we have loaded
const std::vector<Sequence>& sequences() const;
*/
void load_motifs(std::istream &);
//! load a list of motifs from a file named filename
- void load_motifs(std::string filename);
+ void load_motifs(boost::filesystem::path filename);
//! return our motifs;
const std::set<std::string>& motifs() const;
// ---------- mussa_nway.cc -----------
// ----------------------------------------
+#include <boost/filesystem/fstream.hpp>
+namespace fs = boost::filesystem;
+
#include "alg/nway_paths.hpp"
#include "alg/conserved_path.hpp"
#include "mussa_exceptions.hpp"
-#include <fstream>
#include <iostream>
#include <stdexcept>
void
-NwayPaths::save(string save_file_path)
+NwayPaths::save(fs::path save_file_path)
{
- fstream save_file;
+ fs::fstream save_file;
list<ExtendedConservedPath >::iterator path_i, paths_end;
- save_file.open(save_file_path.c_str(), ios::out);
+ save_file.open(save_file_path, ios::out);
save_file << "<Mussa type=flp seq_count=" << sequence_count();
save_file << " win=" << win_size;
void
-NwayPaths::load(string load_file_path)
+NwayPaths::load(fs::path load_file_path)
{
- fstream load_file;
+ fs::fstream load_file;
string file_data_line, header_data, data, path_node, path_width;
int space_split_i, equal_split_i, comma_split_i, colon_split_i;
vector<int> loaded_path;
- load_file.open(load_file_path.c_str(), ios::in);
+ load_file.open(load_file_path, ios::in);
if (!load_file)
{
- throw mussa_load_error("Sequence File: " + load_file_path + " not found");
+ throw mussa_load_error("Sequence File: " + load_file_path.string() + " not found");
}
else
{
void
-NwayPaths::save_old(string save_file_path)
+NwayPaths::save_old(fs::path save_file_path)
{
- fstream save_file;
+ fs::fstream save_file;
list<ConservedPath >::iterator path_i, paths_end;
size_t i;
- save_file.open(save_file_path.c_str(), ios::app);
+ save_file.open(save_file_path, ios::app);
path_i = pathz.begin();
paths_end = pathz.end();
// ----------------------------------------
// ---------- mussa_nway.hh -----------
// ----------------------------------------
+#include <boost/filesystem/path.hpp>
#include <list>
#include <string>
void path_search(std::vector<std::vector<FLPs> > all_comparisons, ConservedPath path, size_t depth);
void simple_refine();
- void save(std::string save_file_path);
+ void save(boost::filesystem::path save_file_path);
//! load a muway file, \throws mussa_load_error
- void load(std::string load_file_path);
+ void load(boost::filesystem::path load_file_path);
void add_path(int threshold, std::vector<int>& loaded_path);
void add_path(ConservedPath loaded_path);
//! how many sequences are in our comparison
void find_paths(std::vector<std::vector<FLPs> > all_comparisons);
void refine();
- void save_old(std::string save_file_path);
+ void save_old(boost::filesystem::path save_file_path);
void print(std::list<std::vector<int> >&);
std::list<ConservedPath>::iterator pbegin() { return pathz.begin() ; }
// ----------------------------------------
// ---------- 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
// ---------- sequence.hh -----------
// ----------------------------------------
-
-#include <fstream>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/fstream.hpp>
#include <list>
#include <string>
#include <vector>
//! load sequence AGCT from fasta file
/*! \throws mussa_load_error
*/
- void load_fasta(const std::string file_path, int seq_num=1,
+ void load_fasta(const boost::filesystem::path file_path, int seq_num=1,
int start_index=0, int end_index=0);
//! load sequence annotations
/*! \throws mussa_load_error
*/
- void load_annot(const std::string file_path, int start_index, int end_index);
+ void load_annot(const boost::filesystem::path file_path, int start_index, int end_index);
const std::list<annot>& annotations() const;
const std::list<motif>& motifs() const;
const std::string& get_species() const;
/*! \throws motif_normalize_error if there is an invalid symbol
*/
static std::string motif_normalize(std::string a_motif);
- void save(std::fstream &save_file);
- void load_museq(std::string load_file_path, int seq_num);
+ void save(boost::filesystem::fstream &save_file);
+ void load_museq(boost::filesystem::path load_file_path, int seq_num);
};
#endif
test_flp.cpp test_glseqbrowser.cpp test_glsequence.cpp
test_main.cpp test_mussa.cpp test_nway.cpp test_sequence.cpp)
+# dont you love the number of \ you need to make sure the " shows up in
+# the C compiler?
+SET(EXAMPLE_DIR ${CMAKE_SOURCE_DIR}/examples)
+SET_SOURCE_FILES_PROPERTIES(${SOURCES}
+ COMPILE_FLAGS "-DEXAMPLE_DIR=\\\"${EXAMPLE_DIR}\\\""
+ )
+
FIND_PACKAGE(OpenGL)
INCLUDE(FindBoost)
ADD_EXECUTABLE(unittest ${SOURCES})
-ADD_TEST(core_test ${EXECUTABLE_OUTPUT_PATH}/alg/test/unittest)
+ADD_TEST(core_test ${CMAKE_BINARY_DIR}/alg/test/unittest)
LINK_DIRECTORIES(${MUSSA_BINARY_DIR}/alg})
TARGET_LINK_LIBRARIES(unittest
${BOOST_UNIT_TEST_LIB}
#include <boost/test/auto_unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
#include "alg/flp.hpp"
#include "alg/sequence.hpp"
#include <iostream>
#include <list>
+#include "mussa_exceptions.hpp"
+
BOOST_AUTO_TEST_CASE( flp_simple )
{
FLPs f;
// FIXME: should we test the individual lists?
}
}
+
+BOOST_AUTO_TEST_CASE( flp_file_check )
+{
+ fs::path filename = "Thy_micturations_are_to_me_as_plurdled_gabbleblotchits";
+ FLPs f1;
+ BOOST_CHECK_THROW( f1.load(filename), mussa_load_error);
+}
#include <boost/test/auto_unit_test.hpp>
+#include <boost/filesystem/operations.hpp>
+namespace fs = boost::filesystem;
#include <string>
#include <sstream>
m.nway();
}
-#include <unistd.h>
BOOST_AUTO_TEST_CASE( mussa_load_mupa )
{
+ fs::path mupa_path(EXAMPLE_DIR);
+ mupa_path /= "mck3test.mupa";
+
Mussa m1;
- chdir( "examples" );
- m1.load_mupa_file( "mck3test.mupa" );
+ m1.load_mupa_file( mupa_path );
m1.analyze(0, 0);
BOOST_CHECK_EQUAL( m1.get_name(), std::string("mck3test") );
BOOST_CHECK( m1.size() > 0 );
Mussa m2;
- std::string saved_analysis_path("mck3test_w30_t20");
- m2.load( saved_analysis_path );
- chdir( ".." );
-
- BOOST_CHECK_EQUAL( m2.get_name(), saved_analysis_path );
+ fs::path result_path = fs::initial_path() / "mck3test_w30_t20";
+ m2.load( result_path );
+ BOOST_CHECK_EQUAL( m2.get_name(), result_path.leaf() );
BOOST_CHECK_EQUAL( m1.size(), m2.size() );
}
BOOST_AUTO_TEST_CASE( mussa_load_full_path )
{
Mussa m1;
- chdir( "examples" );
- const int bufsize = 1024;
- char path_buf[bufsize];
- getcwd(path_buf, bufsize);
- std::string path(path_buf);
- chdir( ".." );
- path += "/mck3test.mupa";
- m1.load_mupa_file( path );
+ fs::path full_path(fs::path(EXAMPLE_DIR) / "mck3test.mupa");
+ m1.load_mupa_file( full_path );
m1.analyze(0, 0);
BOOST_CHECK( m1.size() > 0);
BOOST_AUTO_TEST_CASE( mussa_load_analysis )
{
+ fs::path example_dir(EXAMPLE_DIR);
Mussa m1;
- chdir( "examples" );
- const int bufsize = 1024;
- char path_buf[bufsize];
- getcwd(path_buf, bufsize);
- std::string base_path(path_buf);
- chdir( ".." );
- m1.load_mupa_file( base_path + "/mck3test.mupa" );
+ m1.load_mupa_file( example_dir / "mck3test.mupa" );
m1.analyze(0, 0);
Mussa m2;
- m2.load(base_path + "/mck3test_w30_t20");
+ m2.load( example_dir / "mck3test_w30_t20");
BOOST_CHECK_EQUAL( m1.size(), m2.size() );
BOOST_CHECK_EQUAL( m1.get_window(), m2.get_window() );
#include <boost/test/auto_unit_test.hpp>
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
#include <string>
#include <iostream>
}
}
-#include <unistd.h>
BOOST_AUTO_TEST_CASE( nway_refine )
{
+ fs::path mupa_path( EXAMPLE_DIR );
+ mupa_path /= "mck3test.mupa";
Mussa m1;
- m1.load_mupa_file( "examples/mck3test.mupa" );
+ m1.load_mupa_file( mupa_path );
m1.analyze(0, 0);
const NwayPaths& npath = m1.paths();
BOOST_CHECK_EQUAL (npath.path_size(), npath.refined_path_size());
#include <boost/test/auto_unit_test.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+namespace fs=boost::filesystem;
+
#include <list>
#include <iostream>
//! Can we load data from a file
BOOST_AUTO_TEST_CASE( sequence_load )
{
+ fs::path seq_path(fs::path(EXAMPLE_DIR)/ "seq" );
+ seq_path /= "human_mck_pro.fa";
Sequence s;
- s.load_fasta("examples/seq/human_mck_pro.fa");
+ s.load_fasta(seq_path);
BOOST_CHECK_EQUAL(s.subseq(0, 5), "GGATC"); // first few chars of fasta file
BOOST_CHECK_EQUAL(s.get_header(), "gi|180579|gb|M21487.1|HUMCKMM1 Human "
"muscle creatine kinase gene (CKMM), "
${QT_QTOPENGL_LIBRARY}
${OPENGL_gl_LIBRARY}
${BOOST_PROGRAM_OPTIONS_LIB}
+ ${BOOST_FILESYSTEM_LIB}
)
+#include <boost/filesystem/operations.hpp>
+using namespace boost::filesystem;
+
#include <QApplication>
#include "qui/MussaWindow.hpp"
int main(int argc, char **argv)
{
+ // let boost::filesystem store the path we were initially launched in
+ initial_path();
+
QApplication app(argc, argv);
Q_INIT_RESOURCE(icons);
Mussa *analysis = initialize_mussa(argc, argv);