Load saved muway and set to muways soft threshold.
[mussa.git] / alg / nway_paths.cpp
index 7b085a0844860164b78ca8520b4294b5ffe14f63..85ae0071fec44caf2396a80b82c93c16b9f43207 100644 (file)
@@ -65,6 +65,11 @@ NwayPaths::set_soft_threshold(int sft_thres)
   soft_thres = sft_thres;
 }
 
+int NwayPaths::get_soft_threshold() const
+{
+  return soft_thres;
+}
+
 int NwayPaths::get_threshold() const
 {
   return threshold;
@@ -168,7 +173,7 @@ NwayPaths::save(fs::path save_file_path)
   // add a function para new_thres defaults to -1 to later deal with
   // reanalysis with higher thres - if statement whether to record base thres
   // or new thres (ie if -1, then base)
-  save_file << " thres=" << threshold << " >\n";
+  save_file << " thres=" << threshold << " soft_thres=" << soft_thres << " >\n";
 
   path_i = refined_pathz.begin();
   paths_end = refined_pathz.end();
@@ -180,7 +185,7 @@ NwayPaths::save(fs::path save_file_path)
     //cout << a_path.size() << endl;
     //first entry is the window length of the windows in the path
     save_file << a_path.window_size << ":";
-    for(size_t i = 0; i != sequence_count(); ++i)
+    for(size_type i = 0; i != sequence_count(); ++i)
     {
       save_file << a_path[i];
       if (i != sequence_count())
@@ -195,8 +200,7 @@ NwayPaths::save(fs::path save_file_path)
 }
 
 
-size_t
-NwayPaths::sequence_count()
+NwayPaths::size_type NwayPaths::sequence_count() const
 {
   if (refined_pathz.begin() == refined_pathz.end() )
     return 0;
@@ -204,6 +208,10 @@ NwayPaths::sequence_count()
     return refined_pathz.begin()->size();
 }
 
+NwayPaths::size_type NwayPaths::size() const
+{
+  return pathz.size();
+}  
 
 void
 NwayPaths::load(fs::path load_file_path)
@@ -250,7 +258,23 @@ NwayPaths::load(fs::path load_file_path)
     data = file_data_line.substr(equal_split_i+1); 
     threshold = atoi (data.c_str());
     file_data_line = file_data_line.substr(space_split_i+1);
-    
+    // get cur_threshold
+    //std::cout << "file_data_line: " << file_data_line << "\n";
+    //std::cout << "find(\">\"): " << file_data_line.find(">") << "\n";
+    if (file_data_line.find(">") != 0)
+    {
+      space_split_i = file_data_line.find(" ");
+      header_data = file_data_line.substr(0,space_split_i);
+      equal_split_i =  header_data.find("=");
+      data = file_data_line.substr(equal_split_i+1);
+      soft_thres = atoi (data.c_str());
+      file_data_line = file_data_line.substr(space_split_i+1);
+    }
+    else
+    {
+      soft_thres = threshold;
+    }
+    //std::cout << "nway_soft_thres: " << soft_thres << "\n";
     //cout << "seq_num=" << species_num << " win=" << win_size;
     //cout << " thres=" << threshold << endl;
     
@@ -269,7 +293,7 @@ NwayPaths::load(fs::path load_file_path)
         // whats our window size?
         path_width = file_data_line.substr(0,colon_split_i); 
         file_data_line = file_data_line.substr(colon_split_i+1);
-        for(size_t i = 0; i < species_num; i++)
+        for(size_type i = 0; i < species_num; i++)
         {
           comma_split_i = file_data_line.find(",");
           path_node = file_data_line.substr(0, comma_split_i); 
@@ -290,7 +314,7 @@ NwayPaths::load(fs::path load_file_path)
 
 
 void
-NwayPaths::path_search(vector<vector<FLPs> > all_comparisons, ConservedPath path, size_t depth)
+NwayPaths::path_search(vector<vector<FLPs> > all_comparisons, ConservedPath path, size_type depth)
 {
   list<int> new_nodes, trans_check_nodes;
   list<int>::iterator new_nodes_i, new_nodes_end;
@@ -304,7 +328,7 @@ NwayPaths::path_search(vector<vector<FLPs> > all_comparisons, ConservedPath path
     //cout << "    * species " << depth << " node: " << *new_nodes_i << endl;
     // check transitivity with previous nodes in path
     trans_check_good = true;
-    for(size_t i = 0; i < depth - 1; i++)
+    for(size_type i = 0; i < depth - 1; i++)
     {
       trans_check_nodes = all_comparisons[i][depth].match_locations(path[i]);
       if ( (trans_check_nodes.end() == find(trans_check_nodes.begin(),
@@ -376,7 +400,7 @@ NwayPaths::save_old(fs::path save_file_path)
 {
   fs::fstream save_file;
   list<ConservedPath >::iterator path_i, paths_end;
-  size_t i;
+  size_type i;
 
   save_file.open(save_file_path, ios::app);