+ added settings parser module
authorFabio <fabio@congo.fml.local>
Wed, 10 Sep 2008 15:09:28 +0000 (17:09 +0200)
committerFabio <fabio@congo.fml.local>
Wed, 10 Sep 2008 15:09:28 +0000 (17:09 +0200)
qpalma/gridtools.py
scripts/qpalma_pipeline.py

index 63c44f1..0e34ee2 100644 (file)
@@ -109,14 +109,16 @@ class ApproximationTask(ClusterTask):
 
    def CreateJobs(self):
       """
+      Create...
       """
+
       num_splits = self.global_settings['num_splits']
 
-      run_dir  = '/fml/ag-raetsch/home/fabio/tmp/newest_run/alignment/run_enable_quality_scores_+_enable_splice_signals_+_enable_intron_length_+'
-      param_fname    = jp(run_dir,'param_526.pickle')
-      param_fname = self.global_settings['prediction_parameter_fn']
-      run_fname      = jp(run_dir,'run_obj.pickle')
-      run_fname = self.global_settings['run_fn']
+      #run_dir  = '/fml/ag-raetsch/home/fabio/tmp/newest_run/alignment/run_enable_quality_scores_+_enable_splice_signals_+_enable_intron_length_+'
+      #param_fname    = jp(run_dir,'param_526.pickle')
+      param_fname = self.global_settings['prediction_parameter_fn']
+      #run_fname      = jp(run_dir,'run_obj.pickle')
+      run_fname = self.global_settings['run_fn']
 
       #result_dir = '/fml/ag-raetsch/home/fabio/tmp/vmatch_evaluation/main'
       result_dir = self.global_settings['approximation_dir']
index 42e8c38..a90c8ea 100644 (file)
@@ -18,100 +18,13 @@ import os.path
 import pdb
 import sys
 
-from optparse import OptionParser
-
 from qpalma.gridtools import ApproximationTask,PreprocessingTask
 from qpalma.gridtools import AlignmentTask,PostprocessingTask
 
-
-Errormsg = """Usage is: python qpalma_pipeline.py <config filename>"""
-
-
-"""
-def create_option_parser():
-   parser = OptionParser()
-
-   #  
-   parser.add_option("-ci", "--check_and_init", help="check configuration and initialize directories")
-
-   #
-   parser.add_option("-r", "--run", help="write report to FILE", metavar="FILE")
-
-   #
-   parser.add_option("-xx", "--clear", action="store_false", dest="verbose", help="cleanup directories delete all created data")
-
-   return parser
-"""
-
-jp = os.path.join
-
-def parseSettings(filename):
-   """
-   """
-
-   #global_settings = {\
-   #'result_dir':'/fml/ag-raetsch/...',\
-   #'read_ascii_data_fn':'/fml/ag-raetsch/...',\
-   #'num_splits':50
-   #'global_log_fn':'~/qpalma.log'
-   #}
-
-   global_settings = {}
-
-   for line in open(filename):
-      if not line.strip() or line.startswith('#'):
-         continue
-
-      key,val = line.strip().replace(' ','').split('=')
-      global_settings[key] = val
-
-   return global_settings
-
-
-def makeSettings(global_settings):
-   """
-   
-   """
-
-   # first check wether the top level result directory exists
-   assert os.path.exists(global_settings['result_dir']), 'Error: You have to specify a existing result directory!'
-
-   result_dir = global_settings['result_dir']
-
-   # now create some subdirectories needed for the different steps performed by QPalma 
-   global_settings['approximation_dir'] = jp(result_dir,'approximation')
-   global_settings['preproc_dir']       = jp(result_dir,'preprocessing')
-   global_settings['postproc_dir']      = jp(result_dir,'postprocessing')
-   global_settings['prediction_dir']    = jp(result_dir,'prediction')
-   global_settings['training_dir']      = jp(result_dir,'training')
-
-   for dir_name in ['approximation_dir', 'preproc_dir', 'postproc_dir', 'prediction_dir', 'training_dir']:
-      try:
-         os.mkdir(global_settings[dir_name])
-      except:
-         print 'Error: There was a problem generating the subdirectory: %s' % dir_name
-
-   try:
-      os.mkdir(global_settings['global_log_fn'])
-   except:
-      print 'Error: There was a problem generating the logfile %s' % global_settings['global_log_fn']
-
-   return global_settings
-
-
-def checkSettings(global_settings):
-   for key,val in global_settings.items():
-      if key.endswith('_fn'):
-         assert os.path.exists(val), 'Error: Path/File %s with value %s does not seem to exist!' % (key,val)
-
-
-      if key.endswith('_dir'):
-         assert os.path.exists(val), 'Error: Path/File %s with value %s does not seem to exist!' % (key,val)
-   
-
-   return True
+from qpalma.settingsParser import parseSettings
 
 
+Errormsg = """Usage is: python qpalma_pipeline.py <config filename>"""
 
 
 class System:
@@ -132,17 +45,10 @@ class System:
       all parameters.
       """
 
-      #parser = create_option_parser()
-      #(options, args) = parser.parse_args()
-
-      global_settings = parseSettings(filename)
-      global_settings = makeSettings(global_settings)
-      assert checkSettings(global_settings), 'Check your settings some entries were invalid!'
-
-      self.global_settings = global_settings
-
+      self.global_settings = parseSettings(filename)
       pdb.set_trace()
 
+
    def training(self):
       """
       This function is responsible for the whole training process. It first
@@ -175,6 +81,8 @@ class System:
       # After filtering combine the filtered matches from the first run and the
       # found matches from the second run to a full dataset
 
+      sys.exit(0)
+
       pre_task = PreprocessingTask(self.global_settings)
       pre_task.createJobs()
       pre_task.submit() 
@@ -203,5 +111,6 @@ if __name__ == '__main__':
    filename = sys.argv[1]
    assert os.path.exists(filename), Errormsg
    system_obj = System(filename)
-   #system_obj.prediction()
+   system_obj.prediction()
+
    #system_obj.training()