Mercurial > repos > devteam > data_manager_build_kraken_database
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 |
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 | 2 import json |
3 import os | |
4 import shutil | |
5 | |
6 | |
7 def main(args): | |
8 data_manager_entry = {} | |
9 data_manager_entry['value'] = args.database.lower() | |
10 data_manager_entry['name'] = args.database | |
11 data_manager_entry['path'] = '.' | |
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 | 15 target_directory = params['output_data'][0]['extra_files_path'] |
16 os.mkdir(target_directory) | |
17 output_path = os.path.join(os.getcwd(), 'kraken-database') | |
18 for filename in os.listdir(output_path): | |
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 | 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 | 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 | 29 main(args) |