0
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import sys, re
|
|
4 import os
|
|
5 import tempfile
|
|
6 import shutil, subprocess, glob
|
|
7 import optparse
|
|
8 from os.path import basename
|
|
9 import zipfile, tarfile, gzip
|
|
10 from galaxy.datatypes.checkers import *
|
|
11 from stacks import *
|
|
12
|
|
13 """
|
|
14
|
|
15 Created by Cyril Monjeaud
|
|
16 Cyril.Monjeaud@irisa.fr
|
|
17
|
|
18 Last modifications : 01/10/2014
|
|
19
|
|
20 WARNING :
|
|
21
|
|
22 STACKS_denovomap.py needs:
|
|
23
|
|
24 - STACKS scripts in your $PATH
|
|
25
|
|
26 These scripts are available after compiling the sources of STACKS :
|
|
27
|
|
28 http://creskolab.uoregon.edu/stacks/
|
|
29
|
|
30 or with the galaxy_stacks package in the Genouest toolshed (http://toolshed.genouest.org)
|
|
31
|
|
32 """
|
|
33 def __main__():
|
|
34
|
|
35 # arguments recuperation
|
|
36 parser = optparse.OptionParser()
|
|
37 parser.add_option("-f")
|
|
38 parser.add_option("-s")
|
|
39 parser.add_option("-t")
|
|
40 parser.add_option("-o")
|
|
41 parser.add_option("-d")
|
|
42 (options, args) = parser.parse_args()
|
|
43
|
|
44 # create the working dir
|
|
45 tmp_dir = tempfile.mkdtemp(dir=options.d)
|
|
46
|
|
47 print tmp_dir
|
|
48 #os.chdir(tmp_dir)
|
|
49
|
|
50 # parse config files
|
|
51 tab_fq_files=galaxy_config_to_tabfiles_for_STACKS(options.f)
|
|
52
|
|
53 # check if zipped files are into the tab and change tab content
|
|
54 extract_compress_files_from_tabfiles(tab_fq_files, tmp_dir)
|
|
55
|
|
56 # generate population map for denovo map
|
|
57 if not options.s:
|
|
58 generate_popmap_for_denovo(tab_fq_files, options.t, options.o)
|
|
59 else:
|
|
60 # parse config files
|
|
61 tab_sam_files=galaxy_config_to_tabfiles_for_STACKS(options.s)
|
|
62 extract_compress_files_from_tabfiles(tab_sam_files, tmp_dir)
|
|
63 generate_popmap_for_refmap(tab_fq_files, tab_sam_files, options.t, options.o)
|
|
64
|
|
65
|
|
66 #clean up temp files
|
|
67 shutil.rmtree( tmp_dir )
|
|
68
|
|
69
|
|
70
|
|
71
|
|
72
|
|
73
|
|
74 if __name__ == "__main__": __main__()
|