annotate data_manager/data_manager_snpEff_download.py @ 5:3d9dd4b9fb09 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_snpeff commit 5c6d595ecbf2e4e39c25662a165c9e475e01ecd1-dirty
author iuc
date Tue, 18 Apr 2017 09:40:03 -0400
parents 847b0f43c0e5
children a6400027d849
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:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
22 sys.exit( return_code )
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:
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
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:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
62 sys.exit( return_code )
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:
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
66 m = re.match('^[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:
9ac823a8b328 Uploaded
iuc
parents:
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'
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
96 # annotation files that are included in SnpEff by a flag
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 annotations_dict = {'nextProt.bin': '-nextprot', 'motif.bin': '-motif', 'interactions.bin': '-interaction'}
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 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
99 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
100 key = snpeff_version + '_' + genome_version
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
101 if os.path.isdir(genome_path):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
102 for root, dirs, files in os.walk(genome_path):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
103 for fname in files:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
104 if fname.startswith('snpEffectPredictor'):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
105 # 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
106 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
107 data_table_entry = dict(key=key, version=snpeff_version, value=genome_version, name=name, path=data_dir)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
108 _add_data_table_entry( data_manager_dict, 'snpeffv_genomedb', data_table_entry )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
109 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
110 m = re.match(regulation_pattern, fname)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
111 if m:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
112 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
113 data_table_entry = dict(key=key, version=snpeff_version, genome=genome_version, value=name, name=name)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
114 _add_data_table_entry( data_manager_dict, 'snpeffv_regulationdb', data_table_entry )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
115 elif fname in annotations_dict:
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
116 value = annotations_dict[fname]
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
117 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
118 data_table_entry = dict(key=key, version=snpeff_version, genome=genome_version, value=value, name=name)
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
119 _add_data_table_entry( data_manager_dict, 'snpeffv_annotations', data_table_entry )
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 _add_data_table_entry( data_manager_dict, data_table, data_table_entry ):
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
124 data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
125 data_manager_dict['data_tables'][data_table] = data_manager_dict['data_tables'].get( data_table, [] )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
126 data_manager_dict['data_tables'][data_table].append( data_table_entry )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
127 return data_manager_dict
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
128
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
129
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
130 def main():
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
131 parser = optparse.OptionParser()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
132 parser.add_option( '-g', '--genome_version', dest='genome_version', action='store', type="string", default=None, help='genome_version' )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
133 parser.add_option( '-o', '--organism', dest='organism', action='store', type="string", default=None, help='organism name' )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
134 (options, args) = parser.parse_args()
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
135
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
136 filename = args[0]
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
137
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
138 params = json.loads( open( filename ).read() )
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
139 target_directory = params[ 'output_data' ][0]['extra_files_path']
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
140 os.mkdir( target_directory )
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
141 data_manager_dict = {}
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
142
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
143 # 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
144 for genome_version, organism in zip(options.genome_version.split(','), getOrganismNames(options.genome_version, options.organism).split(',')):
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
145 download_database( data_manager_dict, target_directory, genome_version, organism )
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
146
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
147 # 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
148 open( filename, 'wb' ).write( json.dumps( data_manager_dict ) )
0
9ac823a8b328 Uploaded
iuc
parents:
diff changeset
149
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
150
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 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
152 main()