fix segfault when changing soft threshold when no analysis is loaded
authorDiane Trout <diane@caltech.edu>
Wed, 8 Mar 2006 06:57:29 +0000 (06:57 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 8 Mar 2006 06:57:29 +0000 (06:57 +0000)
somehow the trans_path_search tweaked things so that it when it was
called again it'd seg fault.

alg/nway_other.cxx
alg/test/test_mussa.cxx
py/getm.py

index 94df136e5a5d1195296b02d4f5775f6ba2d3fb64..b788d6e9ffbd03dba334e66a6ec30a7828395b4b 100644 (file)
@@ -210,6 +210,8 @@ bool is_transitive_path(const vector<int>& path,
 void
 NwayPaths::trans_path_search(vector<vector<FLPs> > all_comparisons)
 {
+  if (all_comparisons.size() == 0 or all_comparisons[0].size() == 0)
+    return;
   vector<int> path;
   int win_i, window_num;
   bool still_paths;
@@ -227,7 +229,7 @@ NwayPaths::trans_path_search(vector<vector<FLPs> > all_comparisons)
   cout << "window number = " << window_num << endl;   // just a sanity check
   cout << "trans: comparison size= " << all_comparisons.size() << endl;
   // loop thru all windows in first species
-  for (win_i = 0; win_i < window_num; win_i++)
+  for (win_i = 0; win_i != window_num; win_i++)
   {
     // if 1st seq has a match to all the others for this window,
     // then make all possible paths out of all these matches (in all_matches)
index a55b8b53624edc69351f67186f249504cfe8f82d..00cae241fd334af071a39f318ec9a5c4cb09dee2 100644 (file)
@@ -58,6 +58,19 @@ BOOST_AUTO_TEST_CASE( mussa_sequences )
   BOOST_CHECK_EQUAL( analysis.sequences()[2].get_seq(), s2);
 }
 
+// for some reason we can call nway once safely but it
+// somehow changed things and caused a segfault
+// fixed by adding a return statement in trans_path_search 
+BOOST_AUTO_TEST_CASE ( empty_mussa_set_threshold )
+{
+  Mussa m;
+  m.set_soft_thres(15);
+  m.nway();
+
+  m.set_soft_thres(25);
+  m.nway();
+}
+
 #include <unistd.h>
 BOOST_AUTO_TEST_CASE( mussa_load_mupa )
 {
index be5be657b2d124cecd4b09cd6b6d12de1484753f..e11d0c3cfc61b73d84ff402151354a8cf13e3925 100644 (file)
@@ -4,7 +4,7 @@ import mussa
 m = mussa.Mussa()
 #m.load_mupa("examples/mck3test.mupa")
 #m.analyze(0, 0, mussa.analysis_modes.TransitiveNway, 0)
-m.load("../mussa_analyses/land/myogenin_w30_t21")
+m.load("../../mussa_analyses/land/myogenin_w30_t21")
 path = m.paths()
 
 count = 0