From: Brandon King Date: Wed, 14 Nov 2007 03:33:04 +0000 (+0000) Subject: [project @ First attempt at script for configuring pipeline automatically.] X-Git-Tag: 0.1.0~72 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=3708c0a4a5037527553de3090535a541740315d0 [project @ First attempt at script for configuring pipeline automatically.] * More of prof of concept. * FIXME: hardcoded config script path. * Uses logging module * Info for everything going fine. * Error when it breaks in a bad way. --- diff --git a/bin/config_pipeline.py b/bin/config_pipeline.py new file mode 100644 index 0000000..c559ebe --- /dev/null +++ b/bin/config_pipeline.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +import subprocess +import re +import logging + +logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s %(levelname)-8s %(message)s', + datefmt='%a, %d %b %Y %H:%M:%S', + filename='config_pipeline.log', + filemode='w') + +#Info +s_start = re.compile('Starting Genome Analyzer Pipeline') +s_gerald = re.compile("[\S\s]+--GERALD[\S\s]+--make[\S\s]+") +s_generating = re.compile('Generating journals, Makefiles and parameter files') + +#Errors +s_invalid_cmdline = re.compile('Usage:[\S\s]*goat_pipeline.py') + +#Ignore +s_skip = re.compile('s_[0-8]_[0-9]+') + +def handler(line): + + # Irrelevant line + if s_skip.search(line): + pass + elif s_invalid_cmdline.search(line): + logging.error("Invalid commandline options!") + elif s_start.search(line): + logging.info('START: Configuring pipeline') + elif s_gerald.search(line): + logging.info('Running make now') + elif s_generating.search(line): + logging.info('Make files generted') + else: + logging.warning('How to handle: %s' % (line)) + + +def configure(): + #ERROR Test: + #pipe = subprocess.Popen(['goat_pipeline.py', + # '--GERALD=config32bk.txt', + # '--make .',], + # #'.'], + # stdout=subprocess.PIPE, + # stderr=subprocess.PIPE) + + #Not a test; actual run attempt. + pipe = subprocess.Popen(['goat_pipeline.py', + '--GERALD=config32bk.txt', + '--make', + '.'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + line = pipe.stdout.readline() + + while line != '': + handler(line) + line = pipe.stdout.readline() + + #print pipe.poll() + + +if __name__ == '__main__': + configure()