comparison data_manager/ariba_database_builder.py @ 0:a8bb47cc7625 draft

planemo upload for repository tbd commit 0af229dbbda0496819ca95938c2e0628db689134
author thanhlv
date Tue, 08 Jan 2019 11:04:25 -0500
parents
children b13f7ba85697
comparison
equal deleted inserted replaced
-1:000000000000 0:a8bb47cc7625
1 # Thanh Le Viet
2 # 7-Jan-2019
3
4 import argparse
5 import json
6 import os
7 import shutil
8
9
10 def main(args):
11 output_path = os.getcwd()
12 db_folder = [d for d in os.listdir(output_path) if os.path.isdir(d)]
13 params = json.loads(open(args.output).read())
14 target_directory = params['output_data'][0]['extra_files_path']
15 os.mkdir(target_directory)
16 data_manager_entry = []
17 for db in db_folder:
18 # print("Current: ".format(os.path.join(output_path, d)))
19 # print("Target: {}".format(target_directory))
20 shutil.move(os.path.join(output_path, d), os.path.join(target_directory, d))
21 data_manager_entry.append(dict(value=db.lower(),
22 name=db,
23 path=target_directory)
24 )
25 data_manager_json = dict(data_tables=dict(ariba_databases=data_manager_entry))
26 file(args.output, 'w').write(json.dumps(data_manager_json))
27
28
29 if __name__ == '__main__':
30 parser = argparse.ArgumentParser(description='Create data manager json.')
31 parser.add_argument('--out', dest='output', action='store', help='JSON filename')
32 args = parser.parse_args()
33 main(args)