annotate mapsembler2.py @ 3:c62c5fd56ebf default tip

fix missing option
author cmonjeau
date Fri, 11 Sep 2015 10:11:09 +0000
parents 5aea5b993ae8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
1 #!/usr/bin/env python
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
2 import sys, subprocess, glob
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
3 import os, re, shutil, optparse
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
4 from os.path import basename
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
5
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
6 """
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
7 WARNING :
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
8
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
9 Mapsembler2.py needs mapsembler2_exe binaries in your $PATH
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
10
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
11 Mapsember2 is available after compiling sources :
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
12
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
13 http://www.irisa.fr/symbiose/people/ppeterlongo/mapsembler2_2.2.3.zip
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
14
2
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
15 or with the package_mapsembler2_2_2_3 package in the GUGGO toolshed and main toolshed
0
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
16
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
17
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
18 """
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
19
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
20 def __main__():
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
21
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
22 # arguments recuperation
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
23 parser = optparse.OptionParser()
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
24 parser.add_option("-s", dest="input_starters")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
25 parser.add_option("-r", dest="input_files")
3
c62c5fd56ebf fix missing option
cmonjeau
parents: 2
diff changeset
26 parser.add_option("-e", dest="extension_format")
0
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
27 parser.add_option("-t", dest="output_extension")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
28 parser.add_option("-k", dest="kmer")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
29 parser.add_option("-c", dest="coverage")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
30 parser.add_option("-d", dest="substitutions")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
31 parser.add_option("-g", dest="genome_size")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
32 parser.add_option("-f", dest="process_search")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
33 parser.add_option("-x", dest="max_length")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
34 parser.add_option("-y", dest="max_depth")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
35 parser.add_option("--output")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
36 parser.add_option("-i", dest="index_files")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
37
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
38 (options, args) = parser.parse_args()
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
39
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
40 # import tools
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
41 os.symlink(os.environ['TOOLS'], os.getcwd()+'/tools')
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
42
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
43 # execute mapsembler
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
44 cmd_line=[]
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
45 cmd_line.append("run_mapsembler2_pipeline.sh")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
46
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
47 # change starter extension
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
48 cmd_line.extend(["-s", options.input_starters])
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
49
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
50 #inputs
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
51 cmd_line.append("-r")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
52
2
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
53 inputs_tab = []
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
54
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
55 for input in options.input_files.split(","):
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
56 os.symlink(input, os.path.basename(input)+'.'+options.extension_format)
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
57 inputs_tab.append(os.path.basename(input)+'.'+options.extension_format)
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
58
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
59 cmd_line.append(' '.join(inputs_tab))
0
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
60
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
61 # add parameters into the command line
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
62 cmd_line.extend(["-t", options.output_extension, "-k", options.kmer, "-c", options.coverage, "-d", options.substitutions, "-g", options.genome_size, "-f", options.process_search, "-x", options.max_length, "-y", options.max_depth])
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
63
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
64 # open the output log file
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
65 log = open(options.output, "w")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
66 log.write("[COMMAND LINE] "+' '.join(cmd_line))
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
67
2
5aea5b993ae8 fix .dat unknown extension for kissreads
cmonjeau
parents: 0
diff changeset
68 process=subprocess.call(cmd_line)
0
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
69
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
70 # close log file
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
71 log.close()
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
72
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
73 # move results files inside the job_outputs dir
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
74 os.mkdir("job_outputs")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
75 result_files = glob.glob("res_*")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
76 for file in result_files:
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
77 shutil.move(file, "job_outputs/")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
78
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
79
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
80 # move index files
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
81 if options.index_files == "true":
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
82 index_files = glob.glob("index_*")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
83 for index in index_files:
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
84 shutil.move(index, "job_outputs/")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
85
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
86 # move json result into gjson
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
87 json_files = glob.glob("job_outputs/*.json")
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
88 for json in json_files:
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
89 shutil.move(json, json.replace(".json", ".gjson"))
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
90
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
91
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
92 if __name__ == "__main__": __main__()
f905f982ee3d Imported from capsule None
cmonjeau
parents:
diff changeset
93