This patch changes Mussa::save() to take a boost::filesystem::path
so we have some hope of saving to a specified location.
However so the application will continue to work while I go try
the boost::serialize path, I left the save() call in analyze(), so
it will continue to auto-save.
For this to work I'll need to add a save option to the gui and
remove the save call in analyze.
(Though I did leave the save() call in parse_option that will
force saving a run when launched from the command line.
- time_t t1, t2, begin, end;
- double seqloadtime, seqcomptime, nwaytime, savetime, totaltime;
-
- begin = time(NULL);
-
- t1 = time(NULL);
-
if (the_seqs.size() < 2) {
throw mussa_analysis_error("you need to have at least 2 sequences to "
"do an analysis.");
}
//cout << "nway ana: seq_num = " << the_seqs.size() << endl;
if (the_seqs.size() < 2) {
throw mussa_analysis_error("you need to have at least 2 sequences to "
"do an analysis.");
}
//cout << "nway ana: seq_num = " << the_seqs.size() << endl;
- t2 = time(NULL);
- seqloadtime = difftime(t2, t1);
-
- t1 = time(NULL);
- t2 = time(NULL);
- seqcomptime = difftime(t2, t1);
-
- t1 = time(NULL);
the_paths.setup(window, threshold);
nway();
the_paths.setup(window, threshold);
nway();
- t2 = time(NULL);
- nwaytime = difftime(t2, t1);
-
- t1 = time(NULL);
- save();
- t2 = time(NULL);
- savetime = difftime(t2, t1);
-
- end = time(NULL);
- totaltime = difftime(end, begin);
-
- //cout << "seqload\tseqcomp\tnway\tsave\ttotal\n";
- //cout << seqloadtime << "\t";
- //cout << seqcomptime << "\t";
- //cout << nwaytime << "\t";
- //cout << savetime << "\t";
- //cout << totaltime << "\n";
+ // FIXME: once we implement a save feature we should remove this
+ if (not analysis_name.empty()) {
+ save();
+ }
+Mussa::save(fs::path save_path)
fs::path flp_filepath;
fs::fstream save_file;
ostringstream append_info;
int dir_create_status;
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;
-
- // 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 (save_path.empty()) {
+ if (not analysis_name.empty()) {
+ std::string 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();
+ if (thres_append) {
+ append_info.str("");
+ append_info << "_t" << threshold;
+ save_name += append_info.str();
+ }
+ save_path = save_name;
+ } else {
+ throw mussa_save_error("Need filename or analysis name to save");
- fs::path save_path( save_name);
- 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;
+ 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_path.leaf()+".museq"), ios::out);
+ save_file << "<Mussa_Sequence>" << endl;
- 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++)
+ {
+ the_seqs[i]->save(save_file);
+ }
- save_file << "</Mussa_Sequence>" << endl;
- save_file.close();
+ save_file << "</Mussa_Sequence>" << endl;
+ save_file.close();
- // save nway paths to its mussa save file
- the_paths.save(save_path / (save_name + ".muway"));
+ // save nway paths to its mussa save file
+ the_paths.save(save_path / (save_path.leaf()+ ".muway"));
- 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"));
- }
- } else {
- throw mussa_error("Can't save analysis without an analysis name");
+ 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_path.leaf()+append_info.str()+".flp"));
+ }
Mussa();
Mussa(const Mussa &);
Mussa();
Mussa(const Mussa &);
+ //! save all of mussa
+ void save(boost::filesystem::path save_path="");
//! save the nway comparison
void save_muway(boost::filesystem::path save_path);
//! load a saved analysis directory
//! save the nway comparison
void save_muway(boost::filesystem::path save_path);
//! load a saved analysis directory
std::cout << "I apologize for blocking the gui while running the analysis"
<< std::endl;
opts.analysis->analyze();
std::cout << "I apologize for blocking the gui while running the analysis"
<< std::endl;
opts.analysis->analyze();
+ if (opts.analysis->is_dirty())
+ opts.analysis->save();
}
else if (vm.count("view-analysis")) {
opts.analysis->load( vm["view-analysis"].as< std::string >() );
}
else if (vm.count("view-analysis")) {
opts.analysis->load( vm["view-analysis"].as< std::string >() );
BOOST_AUTO_TEST_CASE( mussa_load_mupa )
{
fs::path mupa_path(EXAMPLE_DIR);
BOOST_AUTO_TEST_CASE( mussa_load_mupa )
{
fs::path mupa_path(EXAMPLE_DIR);
+ fs::path result_path = fs::initial_path() / "mck3test_w30_t20";
mupa_path /= "mck3test.mupa";
Mussa m1;
m1.load_mupa_file( mupa_path );
m1.analyze();
mupa_path /= "mck3test.mupa";
Mussa m1;
m1.load_mupa_file( mupa_path );
m1.analyze();
+ m1.save( result_path );
BOOST_CHECK_EQUAL( m1.get_name(), std::string("mck3test") );
BOOST_CHECK( m1.size() > 0 );
Mussa m2;
BOOST_CHECK_EQUAL( m1.get_name(), std::string("mck3test") );
BOOST_CHECK( m1.size() > 0 );
Mussa m2;
- 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() );
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 )
}
BOOST_AUTO_TEST_CASE( mussa_load_full_path )
public:
explicit cmdline_error(const std::string& msg): mussa_error(msg) {};
};
public:
explicit cmdline_error(const std::string& msg): mussa_error(msg) {};
};
+//! Error trying to save
+class mussa_save_error : public mussa_error
+{
+public:
+ explicit mussa_save_error(const std::string& msg) :
+ mussa_error(msg) {};
+};
//! Error loading information
class mussa_load_error : public mussa_error
{
//! Error loading information
class mussa_load_error : public mussa_error
{