+ sanity checks for the global config file
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Tue, 13 May 2008 13:31:20 +0000 (13:31 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Tue, 13 May 2008 13:31:20 +0000 (13:31 +0000)
git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@8992 e1793c9e-67f9-0310-80fc-b846ff1f7b36

scripts/check_and_init.py [new file with mode: 0644]

diff --git a/scripts/check_and_init.py b/scripts/check_and_init.py
new file mode 100644 (file)
index 0000000..393eb22
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os.path
+import cPickle
+
+import qpalma.Configuration as Conf
+
+def check_and_init():
+   """
+   The purpose of this script is to take all the global variables from the
+   Configuration file and store them into a dictionary for the pipeline.
+
+   Additionally sanity checks are performed for the parameters to be sure they
+   are within a certain interval or the file they point to exists etc.
+   """
+
+   jp = os.path.join
+
+   # create a python dictionary to store all configuration parameters
+   Config = {}
+   
+   result_dir = Conf.result_dir
+   assert os.path.exists(result_dir), 'Error you have to specify an existing result_dir.'
+
+   # assing main result dir in Config dictionary
+   Config['result_dir'] = result_dir
+
+   Config['reads_location'] = Conf.reads_location
+   assert os.path.exists(Config['reads_location'])
+
+   #
+   # Check and set parameter for the first VMatch step 
+   #
+
+   Config['mismatches_1']     = Conf.mismatches_1
+   Config['end_gap_1']        = Conf.end_gap_1
+   Config['read_length_1']    = Conf.read_length_1
+   Config['repeat_mapping_1'] = Conf.repeat_mapping_1
+   Config['seedlength_1']     = Conf.seedlength_1
+   Config['suffixtree_1']     = Conf.suffixtree_1
+
+   #
+   # Check and set parameter for the second VMatch step 
+   #
+
+   Config['mismatches_2']     = Conf.mismatches_2
+   Config['sub_mismatches_2'] = Conf.sub_mismatches_2
+   Config['read_length_2']    = Conf.read_length_2
+   Config['min_short_end_2']  = Conf.min_short_end_2
+   Config['repeat_mapping_2'] = Conf.repeat_mapping_2
+   Config['seedlength_2']     = Conf.seedlength_2
+   Config['suffixtree_2']     = Conf.suffixtree_2
+
+   subdirs = []
+
+   # create subdirs needed for mapping / alignment / remapping
+   mapping_dir = jp(result_dir,'mapping')
+   Config['mapping_dir'] = mapping_dir
+   Config['mapping_main_dir']    = jp(mapping_dir,'main')
+   Config['mapping_spliced_dir'] = jp(mapping_dir,'spliced')
+
+   subdirs.extend([Config['mapping_dir'], Config['mapping_main_dir'],\
+   Config['mapping_spliced_dir']])
+
+   Config['alignment_dir']             = jp(result_dir,'alignment')
+
+   subdirs.extend([Config['alignment_dir']])
+
+   Config['remapping_dir'] = jp(result_dir,'remapping')
+
+   subdirs.extend([Config['remapping_dir']])
+   
+   try:
+      for current_dir in subdirs:
+         os.mkdir(current_dir)
+   except:
+      print 'Error during initialization of project directories'
+
+   # store the configuration in a pickled python dictionary
+   cPickle.dump(Config,open(Conf.conf_object_path,'w+'))
+
+if __name__ == '__main__':
+   check_and_init()