Mercurial > repos > devteam > data_manager_picard_index_builder
comparison data_manager/picard_index_builder.py @ 6:fa8c605bf385 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_picard_index_builder commit 096286097ed5cdf189a1b68c3fc34d10f4142e54
author | iuc |
---|---|
date | Sun, 16 Apr 2023 08:28:16 +0000 |
parents | acaa6719a478 |
children |
comparison
equal
deleted
inserted
replaced
5:acaa6719a478 | 6:fa8c605bf385 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Dan Blankenberg | 2 # Dan Blankenberg |
3 from __future__ import print_function | 3 from __future__ import print_function |
4 | 4 |
5 import json | |
5 import optparse | 6 import optparse |
6 import os | 7 import os |
7 import subprocess | 8 import subprocess |
8 import sys | 9 import sys |
9 from json import dumps, loads | |
10 | 10 |
11 DEFAULT_DATA_TABLE_NAME = "picard_indexes" | 11 DEFAULT_DATA_TABLE_NAME = "picard_indexes" |
12 | 12 |
13 | 13 |
14 def get_id_name(params, dbkey, fasta_description=None): | 14 def get_id_name(params, dbkey, fasta_description=None): |
56 parser.add_option('-n', '--data_table_name', dest='data_table_name', action='store', type="string", default=None, help='data_table_name') | 56 parser.add_option('-n', '--data_table_name', dest='data_table_name', action='store', type="string", default=None, help='data_table_name') |
57 (options, args) = parser.parse_args() | 57 (options, args) = parser.parse_args() |
58 | 58 |
59 filename = args[0] | 59 filename = args[0] |
60 | 60 |
61 params = loads(open(filename).read()) | 61 with open(filename) as fh: |
62 params = json.load(fh) | |
62 target_directory = params['output_data'][0]['extra_files_path'] | 63 target_directory = params['output_data'][0]['extra_files_path'] |
63 os.mkdir(target_directory) | 64 os.mkdir(target_directory) |
64 data_manager_dict = {} | 65 data_manager_dict = {} |
65 | 66 |
66 dbkey = options.fasta_dbkey | 67 dbkey = options.fasta_dbkey |
73 # build the index | 74 # build the index |
74 build_picard_index(data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, | 75 build_picard_index(data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, |
75 sequence_name, data_table_name=options.data_table_name or DEFAULT_DATA_TABLE_NAME) | 76 sequence_name, data_table_name=options.data_table_name or DEFAULT_DATA_TABLE_NAME) |
76 | 77 |
77 # save info to json file | 78 # save info to json file |
78 open(filename, 'w').write(dumps(data_manager_dict, sort_keys=True)) | 79 with open(filename, 'w') as fh: |
80 json.dump(data_manager_dict, fh, sort_keys=True) | |
79 | 81 |
80 | 82 |
81 if __name__ == "__main__": | 83 if __name__ == "__main__": |
82 main() | 84 main() |