annotate data_manager/make_json.py @ 10:1e701a731d48 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author iuc
date Sun, 22 Nov 2020 12:41:47 +0000
parents 1d616842e1db
children
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))
10
1e701a731d48 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 8
diff changeset
13 with open(args.output) as fh:
1e701a731d48 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 8
diff changeset
14 params = json.load(fh)
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
15 target_directory = params['output_data'][0]['extra_files_path']
d5d803e654dd Uploaded
devteam
parents:
diff changeset
16 os.mkdir(target_directory)
d5d803e654dd Uploaded
devteam
parents:
diff changeset
17 output_path = os.path.join(os.getcwd(), 'kraken-database')
d5d803e654dd Uploaded
devteam
parents:
diff changeset
18 for filename in os.listdir(output_path):
d5d803e654dd Uploaded
devteam
parents:
diff changeset
19 shutil.move(os.path.join(output_path, filename), target_directory)
10
1e701a731d48 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 8
diff changeset
20 with open(args.output, 'w') as fh:
1e701a731d48 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken_database/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents: 8
diff changeset
21 json.dump(data_manager_json, fh, sort_keys=True)
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
22
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
23
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
24 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
25 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
26 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
27 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
28 args = parser.parse_args()
0
d5d803e654dd Uploaded
devteam
parents:
diff changeset
29 main(args)