comparison data_manager/data_manager_metaphlan2_download.py @ 1:83f07f40b200 draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_metaphlan2_database_downloader commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author iuc
date Sun, 22 Nov 2020 12:51:11 +0000
parents 9c4ad82be5bd
children
comparison
equal deleted inserted replaced
0:9c4ad82be5bd 1:83f07f40b200
22 NB the directory pointed to by 'extra_files_path' 22 NB the directory pointed to by 'extra_files_path'
23 doesn't exist initially, it is the job of the script 23 doesn't exist initially, it is the job of the script
24 to create it if necessary. 24 to create it if necessary.
25 25
26 """ 26 """
27 params = json.loads(open(jsonfile).read()) 27 with open(jsonfile) as fh:
28 params = json.load(fh)
28 return (params['param_dict'], 29 return (params['param_dict'],
29 params['output_data'][0]['extra_files_path']) 30 params['output_data'][0]['extra_files_path'])
30 31
31 32
32 # Utility functions for creating data table dictionaries 33 # Utility functions for creating data table dictionaries
34 # Example usage: 35 # Example usage:
35 # >>> d = create_data_tables_dict() 36 # >>> d = create_data_tables_dict()
36 # >>> add_data_table(d,'my_data') 37 # >>> add_data_table(d,'my_data')
37 # >>> add_data_table_entry(dict(dbkey='hg19',value='human')) 38 # >>> add_data_table_entry(dict(dbkey='hg19',value='human'))
38 # >>> add_data_table_entry(dict(dbkey='mm9',value='mouse')) 39 # >>> add_data_table_entry(dict(dbkey='mm9',value='mouse'))
39 # >>> print str(json.dumps(d)) 40 # >>> print(json.dumps(d))
40 def create_data_tables_dict(): 41 def create_data_tables_dict():
41 """Return a dictionary for storing data table information 42 """Return a dictionary for storing data table information
42 43
43 Returns a dictionary that can be used with 'add_data_table' 44 Returns a dictionary that can be used with 'add_data_table'
44 and 'add_data_table_entry' to store information about a 45 and 'add_data_table_entry' to store information about a
142 "metaphlan2_database", 143 "metaphlan2_database",
143 target_dir) 144 target_dir)
144 145
145 # Write output JSON 146 # Write output JSON
146 print("Outputting JSON") 147 print("Outputting JSON")
147 print(str(json.dumps(data_tables))) 148 with open(jsonfile, 'w') as fh:
148 with open(jsonfile, 'wb') as out: 149 json.dump(data_tables, fh, sort_keys=True)
149 out.write(json.dumps(data_tables))
150 print("Done.") 150 print("Done.")