execution.add_task(tools.filter_bed_by_contig, tags=dict(in_bam=bam_path, in_bed=target_bed_path, contig=contig), out_dir='work/{contig}') for contig in contigs ] freebayes_tasks = one2one(tools.freebayes, bed_tasks, dict(max_complex_gap=max_complex_gap)) merge_vcf_tasks = many2one(tools.vcf_concat_parts, freebayes_tasks) execution.run() if __name__ == '__main__': p = argparse.ArgumentParser() p.add_argument('bam_path') p.add_argument('target_bed_path') p.add_argument('--max_complex_gap', type=int, default=2) add_execution_args(p) start_kwargs, variant_call_args = pop_execution_args(vars(p.parse_args())) cosmos = Cosmos('sqlite:///%s/sqlite.db' % os.path.dirname(os.path.abspath(__file__))) cosmos.initdb() execution = cosmos.start(output_dir='../analysis_output/variant_calling', **start_kwargs) variant_call(execution, **variant_call_args)
sp.set_defaults(func=cosmos.shell) sp = sps.add_parser('runweb', help=cosmos.runweb.__doc__) sp.add_argument('-p', '--port', type=int, help='port to bind the server to') sp.add_argument('-H', '--host', default='localhost', help='host to bind the server to') sp.set_defaults(func=cosmos.runweb) sp = sps.add_parser('ex1', help='Example1') sp.set_defaults(func=ex1.run_ex1) add_execution_args(sp) sp = sps.add_parser('ex2', help='Example2: A failed task') sp.set_defaults(func=ex_fail.run_ex2) add_execution_args(sp) sp = sps.add_parser('ex3', help='Example3: Twitter (note you must edit the file)') sp.set_defaults(func=ex_email.run_ex3) add_execution_args(sp) args = parser.parse_args() kwargs = dict(args._get_kwargs()) func = kwargs.pop('func') growl = kwargs.pop('growl') debug = kwargs.pop('debug')
sp.set_defaults(func=cosmos.resetdb) sp = sps.add_parser('initdb', help=cosmos.initdb.__doc__) sp.set_defaults(func=cosmos.initdb) sp = sps.add_parser('shell', help=cosmos.shell.__doc__) sp.set_defaults(func=cosmos.shell) sp = sps.add_parser('runweb', help=cosmos.runweb.__doc__) sp.add_argument('-p', '--port', type=int, help='port to bind the server to') sp.add_argument('-H', '--host', default='localhost', help='host to bind the server to') sp.set_defaults(func=cosmos.runweb) sp = sps.add_parser('ex1', help='Example1') sp.set_defaults(func=ex1.run_ex1) add_execution_args(sp) sp = sps.add_parser('ex2', help='Example2: A failed task') sp.set_defaults(func=ex_fail.run_ex2) add_execution_args(sp) sp = sps.add_parser('ex3', help='Example3: Twitter (note you must edit the file)') sp.set_defaults(func=ex_email.run_ex3) add_execution_args(sp) args = parser.parse_args() kwargs = dict(args._get_kwargs()) func = kwargs.pop('func') growl = kwargs.pop('growl') debug = kwargs.pop('debug') if growl:
def variant_call(execution, bam_path, target_bed_path, max_complex_gap): """ Bioinformatics variant calling workflow """ contigs = sp.check_output("cat %s |cut -f1|uniq" % target_bed_path, shell=True).strip().split("\n") bed_tasks = [execution.add_task(tools.filter_bed_by_contig, tags=dict(in_bam=bam_path, in_bed=target_bed_path, contig=contig), out_dir='work/{contig}') for contig in contigs ] freebayes_tasks = one2one(tools.freebayes, bed_tasks, dict(max_complex_gap=max_complex_gap)) merge_vcf_tasks = many2one(tools.vcf_concat_parts, freebayes_tasks) execution.run() if __name__ == '__main__': p = argparse.ArgumentParser() p.add_argument('bam_path') p.add_argument('target_bed_path') p.add_argument('--max_complex_gap', type=int, default=2) add_execution_args(p) start_kwargs, variant_call_args = pop_execution_args(vars(p.parse_args())) cosmos = Cosmos('sqlite:///%s/sqlite.db' % os.path.dirname(os.path.abspath(__file__))) cosmos.initdb() execution = cosmos.start(output_dir='../analysis_output/variant_calling', **start_kwargs) variant_call(execution, **variant_call_args)