Mercurial > repos > iuc > data_manager_snpeff
annotate data_manager/data_manager_snpEff_download.py @ 1:85a23e2dd92b draft
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
author | iuc |
---|---|
date | Tue, 07 Jun 2016 10:11:50 -0400 |
parents | 9ac823a8b328 |
children | 847b0f43c0e5 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
2 import gzip |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
3 import json |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
4 import optparse |
0 | 5 import os |
6 import re | |
7 import subprocess | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
8 import sys |
0 | 9 |
10 | |
11 def stop_err(msg): | |
12 sys.stderr.write(msg) | |
13 sys.exit(1) | |
14 | |
15 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
16 def fetch_databases(jar_path, genome_list=None): |
0 | 17 snpDBs = dict() |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
18 (snpEff_dir, snpEff_jar) = os.path.split(jar_path) |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
19 databases_path = 'databases.out' |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
20 databases_output = open(databases_path, 'w') |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
21 args = [ 'java', '-jar' ] |
0 | 22 args.append( snpEff_jar ) |
23 args.append( 'databases' ) | |
24 # tmp_stderr = tempfile.NamedTemporaryFile( prefix = "tmp-data-manager-snpEff-stderr" ) | |
25 # databases_output = open(databases_path) | |
26 # proc = subprocess.Popen( args=args, shell=False, cwd=snpEff_dir, stdout=databases_output.fileno(), stderr=tmp_stderr.fileno() ) | |
27 proc = subprocess.Popen( args=args, shell=False, cwd=snpEff_dir, stdout=databases_output.fileno() ) | |
28 return_code = proc.wait() | |
29 if return_code: | |
30 sys.exit( return_code ) | |
31 databases_output.close() | |
32 try: | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
33 fh = open(databases_path, 'r') |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
34 for i, line in enumerate(fh): |
0 | 35 fields = line.split('\t') |
36 if len(fields) >= 2: | |
37 genome_version = fields[0].strip() | |
38 if genome_list and genome_version not in genome_list: | |
39 continue | |
40 if genome_version.startswith("Genome") or genome_version.startswith("-"): | |
41 continue | |
42 description = fields[1].strip() | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
43 snpDBs[genome_version] = description |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
44 except Exception as e: |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
45 stop_err( 'Error parsing %s %s\n' % (databases_path, str( e )) ) |
0 | 46 else: |
47 fh.close() | |
48 return snpDBs | |
49 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
50 |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
51 def getOrganismNames(jar_path, genomes, organisms): |
0 | 52 genome_list = genomes.split(',') |
53 organism_list = organisms.split(',') if organisms else [] | |
54 if len(genome_list) != len(organism_list): | |
55 descriptions = [] | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
56 snpDBdict = fetch_databases(jar_path, genome_list=genome_list) |
0 | 57 for genome in snpDBdict: |
58 descriptions.append(snpDBdict[genome] if genome in snpDBdict else genome) | |
59 return ','.join(descriptions) | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
60 return organisms |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
61 |
0 | 62 |
63 def getSnpeffVersion(jar_path): | |
64 snpeff_version = 'SnpEff ?.?' | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
65 (snpEff_dir, snpEff_jar) = os.path.split(jar_path) |
0 | 66 stderr_path = 'snpeff.err' |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
67 stderr_fh = open(stderr_path, 'w') |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
68 args = [ 'java', '-jar' ] |
0 | 69 args.append( snpEff_jar ) |
70 args.append( '-h' ) | |
71 proc = subprocess.Popen( args=args, shell=False, cwd=snpEff_dir, stderr=stderr_fh.fileno() ) | |
72 return_code = proc.wait() | |
73 if return_code != 255: | |
74 sys.exit( return_code ) | |
75 stderr_fh.close() | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
76 fh = open(stderr_path, 'r') |
0 | 77 for line in fh: |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
78 m = re.match('^[Ss]npEff version (SnpEff)\s*(\d+\.\d+).*$', line) |
0 | 79 if m: |
80 snpeff_version = m.groups()[0] + m.groups()[1] | |
81 break | |
82 fh.close() | |
83 return snpeff_version | |
84 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
85 |
0 | 86 # Starting with SnpEff 4.1 the .bin files contain the SnpEff version: |
87 # Example - the first 3 line of GRCh37.75/snpEffectPredictor.bin (uncompressed): | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
88 # |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
89 # SnpEff 4.1 |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
90 # CHROMOSOME 2 1 0 179197 GL000219.1 false |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
91 # CHROMOSOME 3 1 0 81347269 HSCHR17_1 false |
0 | 92 def getSnpeffVersionFromFile(path): |
93 snpeff_version = None | |
94 try: | |
95 fh = gzip.open(path, 'rb') | |
96 buf = fh.read(100) | |
97 lines = buf.splitlines() | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
98 m = re.match('^(SnpEff)\s+(\d+\.\d+).*$', lines[0].strip()) |
0 | 99 if m: |
100 snpeff_version = m.groups()[0] + m.groups()[1] | |
101 fh.close() | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
102 except Exception as e: |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
103 stop_err( 'Error parsing SnpEff version from: %s %s\n' % (path, str( e )) ) |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
104 return snpeff_version |
0 | 105 |
106 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
107 # Download human database 'hg19' |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
108 # java -jar snpEff.jar download -v hg19 |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
109 # |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
110 # <command>java -jar \$SNPEFF_JAR_PATH/snpEff.jar download -c \$JAVA_JAR_PATH/snpEff.config $genomeVersion > $logfile </command> |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
111 # |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
112 # snpEffectPredictor.bin |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
113 # regulation_HeLa-S3.bin |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
114 # regulation_pattern = 'regulation_(.+).bin' |
0 | 115 def download_database(data_manager_dict, target_directory, jar_path, config, genome_version, organism): |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
116 # get data_dir from config |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
117 # --- |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
118 # Databases are stored here |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
119 # E.g.: Information for 'hg19' is stored in data_dir/hg19/ |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
120 # |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
121 # Note: Since version 2.1 you can use tilde ('~') as first character to refer to your home directory |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
122 # --- |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
123 # data_dir = ~/snpEff/data/ |
0 | 124 data_dir = target_directory |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
125 (snpEff_dir, snpEff_jar) = os.path.split(jar_path) |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
126 args = [ 'java', '-jar' ] |
0 | 127 args.append( jar_path ) |
128 args.append( 'download' ) | |
129 args.append( '-c' ) | |
130 args.append( config ) | |
131 args.append( '-dataDir' ) | |
132 args.append( data_dir ) | |
133 args.append( '-v' ) | |
134 args.append( genome_version ) | |
135 proc = subprocess.Popen( args=args, shell=False, cwd=snpEff_dir ) | |
136 return_code = proc.wait() | |
137 if return_code: | |
138 sys.exit( return_code ) | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
139 # search data_dir/genome_version for files |
0 | 140 regulation_pattern = 'regulation_(.+).bin' |
141 # annotation files that are included in snpEff by a flag | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
142 annotations_dict = {'nextProt.bin': '-nextprot', 'motif.bin': '-motif'} |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
143 genome_path = os.path.join(data_dir, genome_version) |
0 | 144 snpeff_version = getSnpeffVersion(jar_path) |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
145 key = snpeff_version + '_' + genome_version |
0 | 146 if os.path.isdir(genome_path): |
147 for root, dirs, files in os.walk(genome_path): | |
148 for fname in files: | |
149 if fname.startswith('snpEffectPredictor'): | |
150 # if snpEffectPredictor.bin download succeeded | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
151 name = genome_version + (' : ' + organism if organism else '') |
0 | 152 # version = getSnpeffVersionFromFile(os.path.join(root,fname)) |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
153 data_table_entry = dict(key=key, version=snpeff_version, value=genome_version, name=name, path=data_dir) |
0 | 154 _add_data_table_entry( data_manager_dict, 'snpeffv_genomedb', data_table_entry ) |
155 else: | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
156 m = re.match(regulation_pattern, fname) |
0 | 157 if m: |
158 name = m.groups()[0] | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
159 data_table_entry = dict(key=key, version=snpeff_version, genome=genome_version, value=name, name=name) |
0 | 160 _add_data_table_entry( data_manager_dict, 'snpeffv_regulationdb', data_table_entry ) |
161 elif fname in annotations_dict: | |
162 value = annotations_dict[fname] | |
163 name = value.lstrip('-') | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
164 data_table_entry = dict(key=key, version=snpeff_version, genome=genome_version, value=value, name=name) |
0 | 165 _add_data_table_entry( data_manager_dict, 'snpeffv_annotations', data_table_entry ) |
166 return data_manager_dict | |
167 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
168 |
0 | 169 def _add_data_table_entry( data_manager_dict, data_table, data_table_entry ): |
170 data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} ) | |
171 data_manager_dict['data_tables'][data_table] = data_manager_dict['data_tables'].get( data_table, [] ) | |
172 data_manager_dict['data_tables'][data_table].append( data_table_entry ) | |
173 return data_manager_dict | |
174 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
175 |
0 | 176 def main(): |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
177 # Parse Command Line |
0 | 178 parser = optparse.OptionParser() |
179 parser.add_option( '-j', '--jar_path', dest='jar_path', action='store', type="string", default=None, help='snpEff.jar path' ) | |
180 parser.add_option( '-c', '--config', dest='config', action='store', type="string", default=None, help='snpEff.config path' ) | |
181 parser.add_option( '-g', '--genome_version', dest='genome_version', action='store', type="string", default=None, help='genome_version' ) | |
182 parser.add_option( '-o', '--organism', dest='organism', action='store', type="string", default=None, help='organism name' ) | |
183 (options, args) = parser.parse_args() | |
184 | |
185 filename = args[0] | |
186 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
187 params = json.loads( open( filename ).read() ) |
0 | 188 target_directory = params[ 'output_data' ][0]['extra_files_path'] |
189 os.mkdir( target_directory ) | |
190 data_manager_dict = {} | |
191 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
192 # Create SnpEff Reference Data |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
193 for genome_version, organism in zip(options.genome_version.split(','), getOrganismNames(options.jar_path, options.genome_version, options.organism).split(',')): |
0 | 194 download_database( data_manager_dict, target_directory, options.jar_path, options.config, genome_version, organism ) |
195 | |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
196 # save info to json file |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
197 open( filename, 'wb' ).write( json.dumps( data_manager_dict ) ) |
0 | 198 |
1
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
199 if __name__ == "__main__": |
85a23e2dd92b
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_snpeff commit 88c982c5adcd32b11d98428fc554a4fdfcc19584
iuc
parents:
0
diff
changeset
|
200 main() |