Load saved muway and set to muways soft threshold.
authorBrandon King <kingb@caltech.edu>
Fri, 20 Apr 2007 00:29:17 +0000 (00:29 +0000)
committerBrandon King <kingb@caltech.edu>
Fri, 20 Apr 2007 00:29:17 +0000 (00:29 +0000)
 * Fix for ticket:257
 * Updated nway code to save the soft threshold when saving.
 * Updated nway code to load the soft threshold when saving.
 * Updated MussaWindow.load code to use soft threshold loaded from muway file.
 * Upadted MussaWindow.load code to load properly when the window
   is empty to start with.
   * Added a reset() function to the ThresholdWidget to avoid emits
     * This actually didn't fix the problem (see ticket:262)
   * Broke the SIGNAL/SLOT loop causing multiple nways to be run, by
     breaking the connection from MussaWindow to ThresholdWidget while
     the ThresholdWidget.reset() function is called.

alg/mussa.cpp
alg/nway_paths.cpp
qui/MussaWindow.cpp
qui/ThresholdWidget.cpp
qui/ThresholdWidget.hpp

index 2fb639bef34b0d1571d7234dccba008ad84469f3..1911c5de7b187e11924f44417faf36ec35c8c29d 100644 (file)
@@ -668,7 +668,7 @@ Mussa::load(fs::path ana_file)
   // us know what our threshold and window sizes were when we load a muway
   window = the_paths.get_window();
   threshold = the_paths.get_threshold();
-  soft_thres = threshold;
+  soft_thres = the_paths.get_soft_threshold();
 
 
   //--------------------------------------------------------
index e7a8474b9ce062d7cafd47cdbe88855d81f3405b..85ae0071fec44caf2396a80b82c93c16b9f43207 100644 (file)
@@ -173,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();
@@ -258,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;
     
index 242781606d1daf5ca55884b81ee0e9f2f51ac223..80d855d438089c4ead1c6ccf595190c9e801c79f 100644 (file)
@@ -115,7 +115,18 @@ void MussaWindow::setAnalysis(MussaRef new_analysis)
   if (new_analysis != 0) {
     // only switch mussas if we loaded without error
     clear();
+    //std::cout << "analysis soft: " << analysis->get_soft_threshold()
+    //          << " new analysis soft: " << new_analysis->get_soft_threshold()
+    //          << "\n";
     analysis.swap(new_analysis);
+    //std::cout << "after swap soft thres: " << analysis->get_soft_threshold()
+    //          << "\n";
+    threshold->disconnect(this);
+    threshold->reset(analysis->get_threshold(),
+                     analysis->get_window(),
+                     analysis->get_soft_threshold());
+    connect(threshold, SIGNAL(thresholdChanged(int)),
+          this, SLOT(setSoftThreshold(int)));
     updateTitle();
     updateAnalysis();
   }
@@ -631,14 +642,21 @@ void MussaWindow::newMussaWindow()
 
 void MussaWindow::setSoftThreshold(int value)
 {
+  //std::cout << "Soft: " << analysis->get_soft_threshold()
+  //          << " Value: " << value << "\n";
   if (analysis->get_soft_threshold() != value) {
     threshold->setEnabled( false );
+    //std::cout << "Updating!!!!\n";
     analysis->set_soft_threshold(value);
     analysis->nway();
     updateLinks();
     update();
     threshold->setEnabled( true );
   }
+  //else
+  //{
+  //  std::cout << "NOT Updating!!!!\n";
+  //}
 }
 
 void MussaWindow::showMussaToolbar()
@@ -733,6 +751,7 @@ void MussaWindow::updateAnalysis()
   // but it's possible for us to not have had a chance to set out sequences
   // yet.
   threshold->setRange(analysis->get_threshold(),analysis->get_window());
+  threshold->setBasepairThreshold(analysis->get_soft_threshold());
   updateLinks();
   browser->zoomOut();
   zoom->setValue(browser->zoom());
index 5c856968139fca01ded6f1d6dbf2985c3bc03c1e..20fdbebaac9bf02bfc9fced140b1b87002b852d7 100644 (file)
@@ -10,6 +10,7 @@
 ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max) 
   : QWidget(parent),
     layout(0),
+    cur_bp_threshold(0),
     basepair_spinner(0),
     window_size_label(0),
     percent_label(0)
@@ -43,8 +44,11 @@ void ThresholdWidget::setupWidgets()
 void ThresholdWidget::setRange(int min, int max)
 {
   basepair_spinner->setRange(min, max);
-  cur_bp_threshold = min;
-  basepair_spinner->setValue(min);
+  if (cur_bp_threshold < min || cur_bp_threshold > max)
+  {
+    cur_bp_threshold = min;
+    basepair_spinner->setValue(min);
+  }
 
   QString num;
   num.setNum(max);
@@ -100,3 +104,14 @@ int ThresholdWidget::threshold() const
 {
   return cur_bp_threshold;
 }
+
+void ThresholdWidget::reset(int min, int max, int threshold)
+{
+  
+  cur_bp_threshold = threshold;
+  cur_percent_threshold = (int)(roundl(ratio() * 100));
+  setRange(min, max);
+  basepair_spinner->setValue(threshold);
+  updatePercentThreshold();
+  
+}
index 47a7778f4accb6d272435a7d6a79232c84ba66ab..42d4e3b4f9f41ecb3e4a76048b0bab9663e1420a 100644 (file)
@@ -26,6 +26,8 @@ public:
   int threshold() const;
   //! update percent threshold
   void updatePercentThreshold();
+  
+  void reset(int min, int max, int threshold);
 
 public slots:
   void setBasepairThreshold(int threshold);