0
|
1 import json
|
|
2 import argparse
|
|
3 import os
|
|
4 import shutil
|
|
5
|
|
6 parser = argparse.ArgumentParser(description='Create data manager json.')
|
|
7 parser.add_argument('--db', dest='database', action='store', help='Database name')
|
|
8 parser.add_argument('--out', dest='output', action='store', help='JSON filename')
|
|
9
|
|
10 args = parser.parse_args()
|
|
11
|
|
12 def main(args):
|
|
13 data_manager_entry = {}
|
|
14 data_manager_entry['value'] = args.database.lower()
|
|
15 data_manager_entry['name'] = args.database
|
|
16 data_manager_entry['path'] = '.'
|
|
17 data_manager_json = dict(data_tables=dict(kraken_databases=data_manager_entry))
|
|
18 params = json.loads(open(args.output).read())
|
|
19 target_directory = params['output_data'][0]['extra_files_path']
|
|
20 os.mkdir(target_directory)
|
|
21 output_path = os.path.join(os.getcwd(), 'kraken-database')
|
|
22 for filename in os.listdir(output_path):
|
|
23 shutil.move(os.path.join(output_path, filename), target_directory)
|
|
24 file(args.output, 'w').write(json.dumps(data_manager_json))
|
|
25
|
|
26 if __name__ == '__main__':
|
|
27 main(args)
|
|
28
|