0
|
1 import optparse
|
|
2 import os
|
|
3 import sys
|
|
4
|
|
5 parser = optparse.OptionParser()
|
|
6 parser.add_option('--threads', dest='threads', type="string", help='The number of threads to run')
|
|
7 parser.add_option('--input_files', dest='input_file', action='append', nargs='1', type="string", help='Input datasets')
|
|
8
|
|
9 parser.add_option('--genome_info_file', dest='genome_info_file', type="string", help='Genome information file')
|
|
10 parser.add_option('--replicate_available', dest='replicate_available', type="string", help='Are the selected inputs biological replicates')
|
|
11 parser.add_option('--smoothing_factor', dest='smoothing_factor', type="int", help='Gaussian smoothing standard deviation')
|
|
12 parser.add_option('--output_report', dest='output_report', type="string", help='MultiGPS output report')
|
|
13 parser.add_option('--gff', dest='gff', type="string", help='...')
|
|
14 parser.add_option('--gz', dest='gz', type="string", help='...')
|
|
15 parser.add_option('--design_file', dest='design_file', type="string", help='...')
|
|
16
|
|
17 options, args = parser.parse_args()
|
|
18
|
|
19 dh = open('/tmp/out.log', 'wb')
|
|
20 dh.write( '\n options: \n%s\n' % str( options))
|
|
21 dh.write( '\n args: \n%s\n' % str( args))
|
|
22 dh.close()
|
|
23 sys,stderr.write('Finished...')
|
|
24 sys.exit(1)
|
|
25
|
|
26
|
|
27 genome = options.genome
|
|
28 input_format = options.input_format
|
|
29 replicate = options.replicate
|
|
30 smooth = options.smooth
|
|
31 output_file = options.report
|
|
32 output_file2 = options.gff
|
|
33 output_file3 = options.gz
|
|
34 # input_file = sys.argv[8]
|
|
35 design_file = options.design_file
|
|
36 input_file = options.input_files[0]
|
|
37 if len(options.input_files) > 1:
|
|
38 design_arg = '--design %s' % design_file
|
|
39 else:
|
|
40 design_arg = ''
|
|
41 print file(design_file, 'r').read()
|
|
42
|
|
43 tmp_name = output_file.split("/")
|
|
44 tmp_name = tmp_name[len(tmp_name)-1]
|
|
45
|
|
46 input_tmp_name = input_file.split("/")
|
|
47 input_tmp_name = input_tmp_name[len(input_tmp_name)-1]
|
|
48 tmp_name2 = input_tmp_name.split(".")
|
|
49
|
|
50 f = open("/home/galaxy/galaxy-dist/tools/pughlab/command_tmp/"+tmp_name+".pbs","w")
|
|
51 f.write("cd /home/galaxy/galaxy-dist/tools/pughlab/command_tmp/\n")
|
|
52 f.write("mkdir "+tmp_name+"_analysis_result\n")
|
|
53 f.write("cd "+tmp_name+"_analysis_result\n")
|
|
54 f.write("ln -s "+input_file+" .\n")
|
|
55
|
|
56 # cnt = 1
|
|
57 # for ele in filenames:
|
|
58 # if replicate == "Yes":
|
|
59 # f.write("echo '"+ele+"\tSignal\t"+input_format+"\tDemoExp\t"+str(cnt)+"' >> target.design\n")
|
|
60 # else:
|
|
61 # f.write("echo '"+ele+"\tSignal\t"+input_format+"\tDemoExp"+str(cnt)+"\t"+str(cnt)+"' >> target.design\n")
|
|
62 # cnt = cnt + 1
|
|
63 f.write("java -Xmx6G -jar /home/galaxy/software/multigps/multigps_v0.5.jar --geninfo /home/galaxy/software/multigps/"+genome+".info --threads 4 "+design_arg+" --verbose --gaussmodelsmoothing --gausssmoothparam "+smooth+" --out multigps_out --memepath ~/bin --mememinw 6 --mememaxw 16 --seq /home/galaxy/software/multigps/refs/"+genome+" >multiGPS.out 2>&1\n")
|
|
64 f.write("rm -rf "+output_file+"\n")
|
|
65 f.write("mv multigps_out/multigps_out.all.events.table "+output_file+"\n")
|
|
66 f.write("tar cvzf multigps_out.tar.gz multigps_out\n")
|
|
67 f.write("mv multigps_out.tar.gz "+output_file3+"\n")
|
|
68
|
|
69 f.close()
|
|
70
|
|
71 os.system("sh /home/galaxy/galaxy-dist/tools/pughlab/command_tmp/"+tmp_name+".pbs 2>&1")
|
|
72
|
|
73 f2 = open(output_file, "r")
|
|
74 f3 = open(output_file2, "w")
|
|
75 for line in f2:
|
|
76 line = line.strip()
|
|
77 data = line.split("\t")
|
|
78 if line[:1] != "#":
|
|
79 chrom = data[0].split(":")
|
|
80 f3.write(chrom[0]+"\tmultigps\t.\t"+chrom[1]+"\t"+chrom[1]+"\t"+data[1]+"\t.\t.\t.\n")
|
|
81 f3.close()
|
|
82 f2.close()
|
|
83 exit(0)
|