comparison data_manager/twobit_builder.py @ 5:625fd9476402 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author iuc
date Sun, 22 Nov 2020 12:54:42 +0000
parents 5c77d4091880
children 62359a151521
comparison
equal deleted inserted replaced
4:16c0c73b28ad 5:625fd9476402
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 import tempfile 10 import tempfile
10 from json import dumps, loads
11 11
12 CHUNK_SIZE = 2**20 # 1mb 12 CHUNK_SIZE = 2**20 # 1mb
13 13
14 14
15 def get_id_name(params, dbkey, fasta_description=None): 15 def get_id_name(params, dbkey, fasta_description=None):
73 parser.add_option('-t', '--fasta_description', dest='fasta_description', action='store', type="string", default=None, help='fasta_description') 73 parser.add_option('-t', '--fasta_description', dest='fasta_description', action='store', type="string", default=None, help='fasta_description')
74 (options, args) = parser.parse_args() 74 (options, args) = parser.parse_args()
75 75
76 filename = args[0] 76 filename = args[0]
77 77
78 params = loads(open(filename).read()) 78 with open(filename) as fh:
79 params = json.load(fh)
79 80
80 target_directory = params['output_data'][0]['extra_files_path'] 81 target_directory = params['output_data'][0]['extra_files_path']
81 os.mkdir(target_directory) 82 os.mkdir(target_directory)
82 data_manager_dict = {} 83 data_manager_dict = {}
83 84
90 91
91 # build the index 92 # build the index
92 build_twobit(data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name) 93 build_twobit(data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name)
93 94
94 # save info to json file 95 # save info to json file
95 open(filename, 'w').write(dumps(data_manager_dict, sort_keys=True)) 96 with open(filename, 'w') as fh:
97 json.dump(data_manager_dict, fh, sort_keys=True)
96 98
97 99
98 if __name__ == "__main__": 100 if __name__ == "__main__":
99 main() 101 main()