Update mussa to build on ubuntu 10.04 with qt 4.6.2 +boost 1.40.0.1
[mussa.git] / alg / parse_options.cpp
index ce253246fb3d162b9c7d80d27c7d85ebee3fa8a9..a6126c7c0c95b9676938358f9212d8e61a0d80fc 100644 (file)
@@ -1,5 +1,7 @@
 #include <boost/program_options.hpp>
 namespace po = boost::program_options;
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
 
 #include <string>
 #include <iostream>
@@ -8,8 +10,8 @@ namespace po = boost::program_options;
 #include "alg/parse_options.hpp"
 
 MussaOptions::MussaOptions()
-  : analysis(0),
-    useGUI(true)
+  : useGUI(true),
+    runAsPythonInterpeter(false)
 {
 }
 
@@ -25,7 +27,10 @@ void initialize_mussa(MussaOptions& opts, int argc, char **argv)
      "run an analysis defined by the mussa parameter file")
     ("view-analysis", po::value<std::string>(),
      "load a previously run analysis")
+    ("motifs", po::value<std::string>(),
+     "annotate analysis with motifs from this file")
     ("no-gui", "terminate without running an analysis")
+    ("python", "launch as a python interpreter")
   ;
 
   po::variables_map vm;
@@ -36,20 +41,32 @@ void initialize_mussa(MussaOptions& opts, int argc, char **argv)
     std::cout << options << std::endl;
     return;
   }
+  
+  opts.analysis = Mussa::init();
 
-  opts.analysis = new Mussa();
   // currently we can only have one analysis loaded, so 
   // running trumps viewing.
   if (vm.count("run-analysis")) {
-    opts.analysis->load_mupa_file( vm["run-analysis"].as< std::string >() );
+    fs::path analysis_path(vm["run-analysis"].as< std::string >(), fs::native);
+    opts.analysis->load_mupa_file( analysis_path );
     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 >() );
+    fs::path analysis_path(vm["view-analysis"].as< std::string >(), fs::native);
+    opts.analysis->load( analysis_path );
+  }
+  if (vm.count("motifs") and opts.analysis) {
+    fs::path motif_path(vm["motifs"].as< std::string >(), fs::native);
+    opts.analysis->load_motifs( motif_path );
   }
   if (vm.count("no-gui")) {
     opts.useGUI=false;
   }
+  if (vm.count("python")) {
+    opts.runAsPythonInterpeter = true;
+  }
 }