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 116a16dcaa5d881dcf39e47c559c6d2df48c06df..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>
@@ -7,7 +9,13 @@ namespace po = boost::program_options;
 #include "alg/mussa.hpp"
 #include "alg/parse_options.hpp"
 
-Mussa *initialize_mussa(int argc, char **argv)
+MussaOptions::MussaOptions()
+  : useGUI(true),
+    runAsPythonInterpeter(false)
+{
+}
+
+void initialize_mussa(MussaOptions& opts, int argc, char **argv)
 {
   po::options_description options("Mussa options");
   po::positional_options_description pos_options;
@@ -19,7 +27,10 @@ Mussa *initialize_mussa(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;
@@ -28,25 +39,34 @@ Mussa *initialize_mussa(int argc, char **argv)
 
   if (vm.count("help")) {
     std::cout << options << std::endl;
-    return 0;
+    return;
   }
+  
+  opts.analysis = Mussa::init();
 
-  Mussa *m = new Mussa();
   // currently we can only have one analysis loaded, so 
   // running trumps viewing.
   if (vm.count("run-analysis")) {
-    m->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;
-    m->analyze();
+    opts.analysis->analyze();
+    if (opts.analysis->is_dirty())
+      opts.analysis->save();
   }
   else if (vm.count("view-analysis")) {
-    m->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")) {
-    return 0;
-  } else {
-    return m;
+    opts.useGUI=false;
+  }
+  if (vm.count("python")) {
+    opts.runAsPythonInterpeter = true;
   }
 }
-