Mercurial > repos > jetbrains > span
comparison span_wrapper.py @ 0:1f0c4f0a9c3b draft
Initial version of SPAN for ToolShed
author | jetbrains |
---|---|
date | Thu, 15 Nov 2018 11:04:49 -0500 |
parents | |
children | 5b99943c4627 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f0c4f0a9c3b |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import os | |
4 import sys | |
5 import subprocess | |
6 argv = sys.argv[1:] | |
7 print 'Arguments {0}'.format(argv) | |
8 | |
9 SPAN_JAR = os.environ.get("SPAN_JAR") | |
10 # span.jar from Docker container | |
11 # SPAN_JAR = "/root/span.jar" | |
12 print 'Using SPAN Peak Analyzer distributive file {0}'.format(SPAN_JAR) | |
13 | |
14 # #if $action.action_selector | |
15 # #if str($control.control_selector) == "with_control" | |
16 # span_wrapper.py model with_control "${genome}" "${treatment_file}" "${bin}" "${action.model_file}" "${control.control_file}" | |
17 # #else | |
18 # span_wrapper.py model without_control "${genome}" "${treatment_file}" "${bin}" "${action.model_file}" | |
19 # #end if | |
20 # #else | |
21 # #if $control.control_selector | |
22 # span_wrapper.py peaks with_control "${genome}" "${treatment_file}" "${bin}" "${action.model_file}" "${control.control_file}" "${fdr}" "${gap}" "${action.peaks_file}" | |
23 # #else | |
24 # span_wrapper.py peaks without_control "${genome}" "${treatment_file}" "${bin}" "${action.model_file}" "${fdr}" "${gap}" "${action.peaks_file}" | |
25 # #end if | |
26 # #end if | |
27 | |
28 # See http://artyomovlab.wustl.edu/aging/span.html for command line options | |
29 action = argv[0] | |
30 control = argv[1] | |
31 if action == 'model': | |
32 if control == 'with_control': | |
33 (chrom_sizes, treatment_file, bin, model_file, control_file) = argv[2:] | |
34 cmd = 'java -jar {} analyze --chrom.sizes {} --treatment {} --control {} --bin {}'.format( | |
35 SPAN_JAR, chrom_sizes, treatment_file, control_file, bin | |
36 ) | |
37 print "MODEL FILE" + model_file | |
38 elif control == 'without_control': | |
39 (chrom_sizes, treatment_file, bin, model_file) = argv[2:] | |
40 cmd = 'java -jar {} analyze --chrom.sizes {} --treatment {} --bin {}'.format( | |
41 SPAN_JAR, argv[2], argv[3], argv[4] | |
42 ) | |
43 print "MODEL FILE" + model_file | |
44 else: | |
45 raise Exception("Unknown control option {}".format(control)) | |
46 | |
47 elif action == "peaks": | |
48 if control == 'with_control': | |
49 (chrom_sizes, treatment_file, bin, model_file, control_file, fdr, gap, peaks_file) = argv[2:] | |
50 cmd = 'java -jar {} analyze --chrom.sizes {} --treatment {} --control {} --bin {} --fdr {} --gap {} --peaks {}'.format( | |
51 SPAN_JAR, chrom_sizes, treatment_file, control_file, bin, fdr, gap, peaks_file | |
52 ) | |
53 print "MODEL FILE" + model_file | |
54 elif control == 'without_control': | |
55 (chrom_sizes, treatment_file, bin, model_file, fdr, gap, peaks_file) = argv[2:] | |
56 cmd = 'java -jar {} analyze --chrom.sizes {} --treatment {} --bin {} --fdr {} --gap {} --peaks {}'.format( | |
57 SPAN_JAR, chrom_sizes, treatment_file, bin, fdr, gap, peaks_file | |
58 ) | |
59 print "MODEL FILE" + model_file | |
60 else: | |
61 raise Exception("Unknown control option {}".format(control)) | |
62 else: | |
63 raise Exception("Unknown action command {}".format(action)) | |
64 | |
65 | |
66 print 'Launching SPAN: {0}'.format(cmd) | |
67 subprocess.check_call(cmd, cwd=None, shell=True) |