Mercurial > repos > sblanck > mpagenomics_wrappers
comparison mpagenomics_normalize-7dc6ce39fb89/segmentation.py @ 0:84b13b0e2b85
Uploaded
author | sblanck |
---|---|
date | Thu, 07 May 2015 08:22:36 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:84b13b0e2b85 |
---|---|
1 import os | |
2 import sys | |
3 import subprocess | |
4 import shutil | |
5 import getopt | |
6 | |
7 | |
8 def main(argv): | |
9 | |
10 #default values | |
11 cellularity="1" | |
12 nbcall="3" | |
13 | |
14 try: | |
15 opts, args = getopt.getopt(argv,"h:i:f:p:o:l:og:g:m:st:u:",["input=","new_file_path=","outputlog=","output=","log=","outputgraph=", "graph=", "method=", "signalType=", "user_id=", "nbcall=", "cellularity="]) | |
16 except getopt.GetoptError as err: | |
17 print str(err) | |
18 sys.exit(2) | |
19 for opt, arg in opts: | |
20 if opt == '-h': | |
21 print 'segmentation.py' | |
22 sys.exit() | |
23 elif opt in ("-i", "--input"): | |
24 inputdata = arg | |
25 elif opt in ("-f", "--new_file_path"): | |
26 tmp_dir = arg | |
27 elif opt in ("-p", "--outputlog"): | |
28 outputlog = arg | |
29 elif opt in ("-o", "--output"): | |
30 output = arg | |
31 elif opt in ("-l", "--log"): | |
32 log = arg | |
33 elif opt in ("-og", "--outputgraph"): | |
34 plot = arg | |
35 elif opt in ("-g", "--graph"): | |
36 pdffigures = arg | |
37 elif opt in ("-m", "--method"): | |
38 method = arg | |
39 elif opt in ("-st", "--signalType"): | |
40 signalType = arg | |
41 elif opt in ("-u", "--user_id"): | |
42 userId = arg | |
43 elif opt in ("-c", "--nbcall"): | |
44 nbcall = arg | |
45 elif opt in ("-e", "--cellularity"): | |
46 cellularity = arg | |
47 | |
48 #=========================================================================== | |
49 # inputdata=sys.argv[1] | |
50 # tmp_dir=sys.argv[2] | |
51 # nbcall=sys.argv[3] | |
52 # cellularity=sys.argv[4] | |
53 # outputlog=sys.argv[5] | |
54 # output=sys.argv[6] | |
55 # log=sys.argv[7] | |
56 # plot=sys.argv[8] | |
57 # pdffigures=sys.argv[9] | |
58 # method=sys.argv[10] | |
59 #=========================================================================== | |
60 | |
61 script_dir=os.path.dirname(os.path.abspath(__file__)) | |
62 | |
63 if (outputlog=="TRUE"): | |
64 errfile=open(log,'w') | |
65 else: | |
66 errfile=open(os.path.join(tmp_dir,"errfile.log"),'w') | |
67 | |
68 retcode=subprocess.call(["Rscript", os.path.join(script_dir,"segmentation.R"), inputdata, tmp_dir, nbcall, cellularity, output, method, userId, signalType], stdout = errfile, stderr = errfile) | |
69 | |
70 if (plot=="TRUE"): | |
71 shutil.copy(os.path.join(tmp_dir,"mpagenomics",userId,"Rplots.pdf"), pdffigures) | |
72 | |
73 errfile.close() | |
74 | |
75 sys.exit(retcode) | |
76 | |
77 if __name__ == "__main__": | |
78 main(main(sys.argv[1:])) |