annotate data_manager/data_manager_snpEff_download.py @ 9:08d7998c3afb draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
author iuc
date Wed, 12 Feb 2020 18:33:53 -0500
parents d107d20dc6bd
children c6fbc5421697
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
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 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
3 import optparse
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
4 import os
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
5 import re
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
6 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
7 import sys
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
8
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
9
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
10 def stop_err(msg):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
11 sys.stderr.write(msg)
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
12 sys.exit(1)
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
13
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
14
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
15 def fetch_databases(genome_list=None):
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
16 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
17 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
18 databases_output = open(databases_path, 'w')
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
19 args = ['snpEff', 'databases']
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
20 return_code = subprocess.call(args=args, shell=False, stdout=databases_output.fileno())
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
21 if return_code:
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
22 sys.exit(return_code)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
23 databases_output.close()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
24 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
25 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
26 for i, line in enumerate(fh):
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
27 fields = line.split('\t')
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
28 if len(fields) >= 2:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
29 genome_version = fields[0].strip()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
30 if genome_list and genome_version not in genome_list:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
31 continue
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
32 if genome_version.startswith("Genome") or genome_version.startswith("-"):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
33 continue
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
34 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
35 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
36 except Exception as e:
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
37 stop_err('Error parsing %s %s\n' % (databases_path, str(e)))
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
38 else:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
39 fh.close()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
40 return snpDBs
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
41
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
42
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
43 def getOrganismNames(genomes, organisms):
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
44 genome_list = genomes.split(',')
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
45 organism_list = organisms.split(',') if organisms else []
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
46 if len(genome_list) != len(organism_list):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
47 descriptions = []
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
48 snpDBdict = fetch_databases(genome_list=genome_list)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
49 for genome in snpDBdict:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
50 descriptions.append(snpDBdict[genome] if genome in snpDBdict else genome)
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
51 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
52 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
53
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
54
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
55 def getSnpeffVersion():
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
56 snpeff_version = 'SnpEff ?.?'
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
57 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
58 stderr_fh = open(stderr_path, 'w')
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
59 args = ['snpEff', '-h']
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
60 return_code = subprocess.call(args=args, shell=False, stderr=stderr_fh.fileno())
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
61 if return_code != 255:
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
62 sys.exit(return_code)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
63 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
64 fh = open(stderr_path, 'r')
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
65 for line in fh:
8
d107d20dc6bd planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
iuc
parents: 7
diff changeset
66 m = re.match(r'^[Ss]npEff version (SnpEff)\s*(\d+\.\d+).*$', line)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
67 if m:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
68 snpeff_version = m.groups()[0] + m.groups()[1]
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
69 break
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
70 fh.close()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
71 return snpeff_version
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
72
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
73
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
74 # 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
75 # 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
76 #
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
77 # <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
78 #
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
79 # 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
80 # 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
81 # regulation_pattern = 'regulation_(.+).bin'
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
82 def download_database(data_manager_dict, target_directory, 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
83 # 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
84 # ---
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 # 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
86 # 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
87 #
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 # Note: Since version 2.1 you can use tilde ('~') as first character to refer to your home directory
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
89 data_dir = target_directory
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
90 args = ['snpEff', 'download', '-dataDir', data_dir, '-v', genome_version]
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
91 return_code = subprocess.call(args=args, shell=False)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
92 if return_code:
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
93 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
94 # search data_dir/genome_version for files
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
95 regulation_pattern = 'regulation_(.+).bin'
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
96 genome_path = os.path.join(data_dir, genome_version)
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
97 snpeff_version = getSnpeffVersion()
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 key = snpeff_version + '_' + genome_version
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
99 if os.path.isdir(genome_path):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
100 for root, dirs, files in os.walk(genome_path):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
101 for fname in files:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
102 if fname.startswith('snpEffectPredictor'):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
103 # 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
104 name = genome_version + (' : ' + organism if organism else '')
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
105 data_table_entry = dict(key=key, version=snpeff_version, value=genome_version, name=name, path=data_dir)
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
106 _add_data_table_entry(data_manager_dict, 'snpeffv_genomedb', data_table_entry)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
107 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
108 m = re.match(regulation_pattern, fname)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
109 if m:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
110 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
111 data_table_entry = dict(key=key, version=snpeff_version, genome=genome_version, value=name, name=name)
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
112 _add_data_table_entry(data_manager_dict, 'snpeffv_regulationdb', data_table_entry)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
113 return data_manager_dict
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
114
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
115
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
116 def _add_data_table_entry(data_manager_dict, data_table, data_table_entry):
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
117 data_manager_dict['data_tables'] = data_manager_dict.get('data_tables', {})
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
118 data_manager_dict['data_tables'][data_table] = data_manager_dict['data_tables'].get(data_table, [])
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
119 data_manager_dict['data_tables'][data_table].append(data_table_entry)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
120 return data_manager_dict
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
121
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
122
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
123 def main():
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
124 parser = optparse.OptionParser()
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
125 parser.add_option('-g', '--genome_version', dest='genome_version', action='store', type="string", default=None, help='genome_version')
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
126 parser.add_option('-o', '--organism', dest='organism', action='store', type="string", default=None, help='organism name')
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
127 (options, args) = parser.parse_args()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
128
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
129 filename = args[0]
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
130
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
131 params = json.loads(open(filename).read())
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
132 target_directory = params['output_data'][0]['extra_files_path']
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
133 os.mkdir(target_directory)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
134 data_manager_dict = {}
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
135
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
136 # Create SnpEff Reference Data
5
3d9dd4b9fb09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
iuc
parents: 4
diff changeset
137 for genome_version, organism in zip(options.genome_version.split(','), getOrganismNames(options.genome_version, options.organism).split(',')):
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
138 download_database(data_manager_dict, target_directory, genome_version, organism)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
139
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
140 # save info to json file
9
08d7998c3afb "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 036feef4f46b5aedabc5080c8fa4bc00d9c30d95"
iuc
parents: 8
diff changeset
141 open(filename, 'w').write(json.dumps(data_manager_dict, sort_keys=True))
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
142
4
847b0f43c0e5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 1
diff changeset
143
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
144 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
145 main()