annotate data_manager/make_json.py @ 8:1d616842e1db draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8b77954efb8d46dfb3bec5421819076f3757ad06"
author iuc
date Sun, 26 Jan 2020 14:34:23 +0000 (2020-01-26)
parents 6f0294046f41
children 1e701a731d48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
6f0294046f41 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 0
diff changeset
1 import argparse
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
2 import json
d5d803e654dd Uploaded
devteam
parents:
diff changeset
3 import os
d5d803e654dd Uploaded
devteam
parents:
diff changeset
4 import shutil
d5d803e654dd Uploaded
devteam
parents:
diff changeset
5
d5d803e654dd Uploaded
devteam
parents:
diff changeset
6
d5d803e654dd Uploaded
devteam
parents:
diff changeset
7 def main(args):
d5d803e654dd Uploaded
devteam
parents:
diff changeset
8 data_manager_entry = {}
d5d803e654dd Uploaded
devteam
parents:
diff changeset
9 data_manager_entry['value'] = args.database.lower()
d5d803e654dd Uploaded
devteam
parents:
diff changeset
10 data_manager_entry['name'] = args.database
d5d803e654dd Uploaded
devteam
parents:
diff changeset
11 data_manager_entry['path'] = '.'
d5d803e654dd Uploaded
devteam
parents:
diff changeset
12 data_manager_json = dict(data_tables=dict(kraken_databases=data_manager_entry))
d5d803e654dd Uploaded
devteam
parents:
diff changeset
13 params = json.loads(open(args.output).read())
d5d803e654dd Uploaded
devteam
parents:
diff changeset
14 target_directory = params['output_data'][0]['extra_files_path']
d5d803e654dd Uploaded
devteam
parents:
diff changeset
15 os.mkdir(target_directory)
d5d803e654dd Uploaded
devteam
parents:
diff changeset
16 output_path = os.path.join(os.getcwd(), 'kraken-database')
d5d803e654dd Uploaded
devteam
parents:
diff changeset
17 for filename in os.listdir(output_path):
d5d803e654dd Uploaded
devteam
parents:
diff changeset
18 shutil.move(os.path.join(output_path, filename), target_directory)
8
1d616842e1db "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8b77954efb8d46dfb3bec5421819076f3757ad06"
iuc
parents: 5
diff changeset
19 with open(args.output, 'w') as out:
1d616842e1db "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8b77954efb8d46dfb3bec5421819076f3757ad06"
iuc
parents: 5
diff changeset
20 out.write(json.dumps(data_manager_json, sort_keys=True))
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
21
5
6f0294046f41 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 0
diff changeset
22
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
23 if __name__ == '__main__':
5
6f0294046f41 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 0
diff changeset
24 parser = argparse.ArgumentParser(description='Create data manager json.')
6f0294046f41 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 0
diff changeset
25 parser.add_argument('--db', dest='database', action='store', help='Database name')
6f0294046f41 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 0
diff changeset
26 parser.add_argument('--out', dest='output', action='store', help='JSON filename')
6f0294046f41 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents: 0
diff changeset
27 args = parser.parse_args()
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
28 main(args)