comparison data_manager/hisat2_index_builder.py @ 6:a04cebcd77f4 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_hisat2_index_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author iuc
date Sun, 22 Nov 2020 12:49:53 +0000
parents 8eac26f44d29
children
comparison
equal deleted inserted replaced
5:8eac26f44d29 6:a04cebcd77f4
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Based heavily on the Bowtie 2 data manager wrapper script by Dan Blankenberg 2 # Based heavily on the Bowtie 2 data manager wrapper script by Dan Blankenberg
3 from __future__ import print_function 3 from __future__ import print_function
4 4
5 import argparse 5 import argparse
6 import json
6 import os 7 import os
7 import shlex 8 import shlex
8 import subprocess 9 import subprocess
9 import sys 10 import sys
10 from json import dumps, loads
11 11
12 DEFAULT_DATA_TABLE_NAME = "hisat2_indexes" 12 DEFAULT_DATA_TABLE_NAME = "hisat2_indexes"
13 13
14 14
15 def get_id_name(params, dbkey, fasta_description=None): 15 def get_id_name(params, dbkey, fasta_description=None):
64 parser.add_argument('--indexer_options', dest='indexer_options', action='store', type=str, default='') 64 parser.add_argument('--indexer_options', dest='indexer_options', action='store', type=str, default='')
65 options = parser.parse_args() 65 options = parser.parse_args()
66 66
67 filename = options.output 67 filename = options.output
68 68
69 params = loads(open(filename).read()) 69 with open(filename) as fh:
70 params = json.load(fh)
70 data_manager_dict = {} 71 data_manager_dict = {}
71 72
72 if options.fasta_dbkey in [None, '', '?']: 73 if options.fasta_dbkey in [None, '', '?']:
73 raise Exception('"%s" is not a valid dbkey. You must specify a valid dbkey.' % (options.fasta_dbkey)) 74 raise Exception('"%s" is not a valid dbkey. You must specify a valid dbkey.' % (options.fasta_dbkey))
74 75
76 77
77 # build the index 78 # build the index
78 build_hisat_index(data_manager_dict, options, params, sequence_id, sequence_name) 79 build_hisat_index(data_manager_dict, options, params, sequence_id, sequence_name)
79 80
80 # save info to json file 81 # save info to json file
81 open(filename, 'w').write(dumps(data_manager_dict, sort_keys=True)) 82 with open(filename, 'w') as fh:
83 json.dump(data_manager_dict, fh, sort_keys=True)
82 84
83 85
84 if __name__ == "__main__": 86 if __name__ == "__main__":
85 main() 87 main()