--- /dev/null
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Written (W) 2008 Fabio De Bona
+# Copyright (C) 2008 Max-Planck-Society
+
+#
+# This file contains the main interface to the QPalma pipeline.
+#
+
+import os
+import os.path
+import sys
+
+jp = os.path.join
+
+
+def parseSettingsFile(filename):
+ """
+ This function parse all key value pairs from the given filename
+ """
+ settings = {}
+ for line in open(filename):
+ if (not line.strip()) or line.startswith('#'):
+ pass
+ else:
+ key, val = line.strip().replace(' ', '').split('=')
+ settings[key] = val
+
+ return settings
+
+
+def makeSettings(settings):
+ """
+
+ """
+ assert os.path.exists(settings['result_dir']),'Error: You have to specify a existing result directory!'
+ result_dir = settings['result_dir']
+ settings['approximation_dir'] = jp(result_dir, 'approximation')
+ settings['dataset_dir'] = jp(result_dir, 'dataset')
+ settings['preproc_dir'] = jp(result_dir, 'preprocessing')
+ settings['postproc_dir'] = jp(result_dir, 'postprocessing')
+ settings['prediction_dir'] = jp(result_dir, 'prediction')
+ settings['training_dir'] = jp(result_dir, 'training')
+
+ for dir_name in ['approximation_dir','dataset_dir', 'preproc_dir', 'postproc_dir',\
+ 'prediction_dir', 'training_dir']:
+ try:
+ os.mkdir(settings[dir_name])
+ continue
+ except:
+ print ('Error: There was a problem generating the subdirectory: %s' % dir_name)
+
+ ddir = settings['dataset_dir']
+ settings['prediction_dataset_fn'] = jp(ddir,'prediction_data.pickle')
+ settings['prediction_dataset_keys_fn'] = jp(ddir,'prediction_data.keys.pickle')
+ settings['training_dataset_fn'] = jp(ddir,'training_data.pickle')
+ settings['training_dataset_keys_fn'] = jp(ddir,'training_data.keys.pickle')
+
+
+ try:
+ os.mkdir(settings['global_log_fn'])
+ except:
+ print 'Error: There was a problem generating the logfile %s' % settings['global_log_fn']
+
+ try:
+ settings['num_splits'] = int(settings['num_splits'])
+ except:
+ print 'Error: num_splits has to be a positive integer'
+
+ settings['allowed_fragments'] = eval(settings['allowed_fragments'])
+ settings['half_window_size'] = int(settings['half_window_size'])
+
+ return settings
+
+
+def checkSettings(settings):
+ for (key, val,) in 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
+
+
+def parseSettings(filename):
+ settings = parseSettingsFile(filename)
+ settings = makeSettings(settings)
+ assert checkSettings(settings),'Check your settings some entries were invalid!'
+
+ return settings
+++ /dev/null
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Written (W) 2008 Fabio De Bona
-# Copyright (C) 2008 Max-Planck-Society
-
-#
-# This file contains the main interface to the QPalma pipeline.
-#
-
-import os
-import os.path
-import sys
-
-jp = os.path.join
-
-
-def parseSettingsFile(filename):
- """
- This function parse all key value pairs from the given filename
- """
- settings = {}
- for line in open(filename):
- if (not line.strip()) or line.startswith('#'):
- pass
- else:
- key, val = line.strip().replace(' ', '').split('=')
- settings[key] = val
-
- return settings
-
-
-def makeSettings(settings):
- """
-
- """
- assert os.path.exists(settings['result_dir']),'Error: You have to specify a existing result directory!'
- result_dir = settings['result_dir']
- settings['approximation_dir'] = jp(result_dir, 'approximation')
- settings['dataset_dir'] = jp(result_dir, 'dataset')
- settings['preproc_dir'] = jp(result_dir, 'preprocessing')
- settings['postproc_dir'] = jp(result_dir, 'postprocessing')
- settings['prediction_dir'] = jp(result_dir, 'prediction')
- settings['training_dir'] = jp(result_dir, 'training')
-
- for dir_name in ['approximation_dir','dataset_dir', 'preproc_dir', 'postproc_dir',\
- 'prediction_dir', 'training_dir']:
- try:
- os.mkdir(settings[dir_name])
- continue
- except:
- print ('Error: There was a problem generating the subdirectory: %s' % dir_name)
-
- ddir = settings['dataset_dir']
- settings['prediction_dataset_fn'] = jp(ddir,'prediction_data.pickle')
- settings['prediction_dataset_keys_fn'] = jp(ddir,'prediction_data.keys.pickle')
- settings['training_dataset_fn'] = jp(ddir,'training_data.pickle')
- settings['training_dataset_keys_fn'] = jp(ddir,'training_data.keys.pickle')
-
-
- try:
- os.mkdir(settings['global_log_fn'])
- except:
- print 'Error: There was a problem generating the logfile %s' % settings['global_log_fn']
-
- try:
- settings['num_splits'] = int(settings['num_splits'])
- except:
- print 'Error: num_splits has to be a positive integer'
-
- settings['allowed_fragments'] = eval(settings['allowed_fragments'])
- settings['half_window_size'] = int(settings['half_window_size'])
-
- return settings
-
-
-def checkSettings(settings):
- for (key, val,) in 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
-
-
-def parseSettings(filename):
- settings = parseSettingsFile(filename)
- settings = makeSettings(settings)
- assert checkSettings(settings),'Check your settings some entries were invalid!'
-
- return settings