+ update makefiles to fetch automatically valid Python includes and libs
[qpalma.git] / scripts / qpalma_pipeline.py
index 8c9e501..d0efc0c 100644 (file)
@@ -20,6 +20,7 @@ import sys
 
 from qpalma.gridtools import ApproximationTask,PreprocessingTask
 from qpalma.gridtools import AlignmentTask,PostprocessingTask
+from qpalma.gridtools import TrainingTask
 
 from qpalma.DatasetUtils import generatePredictionDataset,generateTrainingDataset
 
@@ -27,7 +28,6 @@ from qpalma.SettingsParser import parseSettings
 
 from qpalma.utils import logwrite
 
-
 Errormsg = """Usage is:  
                   
                   python qpalma_pipeline.py train <config filename> <training data filename>
@@ -37,6 +37,12 @@ Errormsg = """Usage is:
            """
 
 
+def printMessage(mes):
+   print '#'*80
+   print '\t\t\t%s...\n'%mes
+   print '#'*80
+
+
 class System:
    """
    This class wraps the outer loop of the qpalma project
@@ -67,15 +73,15 @@ class System:
       """
       logwrite('Begin of training.\n',self.settings)
 
-      print '#'*80
-      print '\t\t\tStarting approximation...\n'
-      print '#'*80
+      printMessage('Starting dataset generation')
 
-      self.settings['training_data_fn'] = training_data_fn
+      self.settings['training_reads_fn'] = training_data_fn
 
       # Collect the data and create a pickled training set
       generateTrainingDataset(self.settings)
 
+      printMessage('Starting training')
+
       # Now that we have a dataset we can perform training
       train_task = TrainingTask(self.settings)
       train_task.CreateJobs()
@@ -94,9 +100,7 @@ class System:
 
       logwrite('Begin of prediction.\n',self.settings)
 
-      print '#'*80
-      print '\t\t\tStarting approximation...\n'
-      print '#'*80
+      printMessage('Starting approximation')
 
       self.settings['prediction_param_fn'] = param_fn
       self.settings['unspliced_reads_fn']  = unspliced_reads_fn
@@ -113,15 +117,11 @@ class System:
       # After filtering combine the filtered matches from the first run and the
       # found matches from the second run to a full dataset
 
-      print '#'*80
-      print '\t\t\tStarting dataset generation...\n'
-      print '#'*80
+      printMessage('Starting dataset generation')
 
       generatePredictionDataset(self.settings)
 
-      print '#'*80
-      print '\t\t\tStarting alignments...\n'
-      print '#'*80
+      printMessage('Starting alignments')
 
       # Now that we have a dataset we can perform accurate alignments
       align_task = AlignmentTask(self.settings)
@@ -129,9 +129,7 @@ class System:
       align_task.Submit()
       align_task.CheckIfTaskFinished()
 
-      print '#'*80
-      print '\t\t\tPostprocessing...\n'
-      print '#'*80
+      printMessage('Postprocessing')
 
       # The results of the above alignment step can be converted to a data format
       # needed for further postprocessing.
@@ -144,7 +142,9 @@ class System:
    
 
 if __name__ == '__main__':
-   if len(sys.argv) != 4 or len(sys.argv) != 6:
+   if len(sys.argv) != 4 and len(sys.argv) != 6:
+      print 'Invalid number of arguments!'
+      print len(sys.argv)
       print Errormsg
       sys.exit(1)
 
@@ -165,7 +165,7 @@ if __name__ == '__main__':
       param_fn           = sys.argv[3]
       unspliced_reads_fn = sys.argv[4]
       spliced_reads_fn   = sys.argv[5]
-      system_obj.prediction(unspliced_reads_fn, spliced_reads_fn)
+      system_obj.prediction(param_fn,unspliced_reads_fn, spliced_reads_fn)
    elif mode == 'train':
       training_data_fn   = sys.argv[3]
       system_obj.training(training_data_fn)