Mercurial > repos > iuc > data_manager_funannotate
comparison data_manager/extract.py @ 5:5459ec34767a draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/data_managers/data_manager_funannotate commit 8341270dd36185ebf59d15282bc79f1215e936a4
author | iuc |
---|---|
date | Fri, 07 Mar 2025 22:33:29 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:1c81a82b5b8e | 5:5459ec34767a |
---|---|
1 import json | |
2 import os | |
3 import sys | |
4 | |
5 fun_db = sys.argv[1] | |
6 fun_db_value = sys.argv[2] | |
7 dmjson = sys.argv[3] | |
8 | |
9 content = [] | |
10 # get options for parameter --busco_db | |
11 # which are just the subfolders of the db dir (minus outgroups/ and trained_species/) | |
12 # https://github.com/nextgenusfs/funannotate/blob/8cc40728fee61566fdf736c1f2292e14cc117660/funannotate/predict.py#L319 | |
13 for d in os.scandir(fun_db): | |
14 if not d.is_dir(): | |
15 continue | |
16 if d.name in ['outgroups', 'trained_species']: | |
17 continue | |
18 if not os.path.exists(os.path.join(d, "dataset.cfg")): | |
19 continue | |
20 name = d.name.replace("_", " ").capitalize() | |
21 content.append({'value': d.name, 'name': name, 'select': 'busco_db', 'db_value': fun_db_value}) | |
22 | |
23 # --busco_seed_species | |
24 # trained_species | |
25 for d in os.scandir(os.path.join(fun_db, "trained_species")): | |
26 if not d.is_dir(): | |
27 continue | |
28 if not os.path.exists(os.path.join(d, "info.json")): | |
29 continue | |
30 name = d.name.replace("_", " ").capitalize() | |
31 content.append({'value': d.name, 'name': name, 'select': 'trained_species', 'db_value': fun_db_value}) | |
32 | |
33 # --busco_seed_species | |
34 # outgroups | |
35 for f in os.scandir(os.path.join(fun_db, "outgroups")): | |
36 if f.is_dir(): | |
37 continue | |
38 if not f.name.endswith("_buscos.fa"): | |
39 continue | |
40 value = f.name[:-10] | |
41 name = ' - '.join([x.replace("_", " ").capitalize() for x in value.split('.')]) | |
42 content.append({'value': value, 'name': name, 'select': 'outgroup', 'db_value': fun_db_value}) | |
43 | |
44 with open(dmjson, "w") as fh: | |
45 json.dump({"data_tables": {"funannotate_options": content}}, fh) | |
46 | |
47 print(f'{len([c for c in content if c["select"]=="busco_db"])} x busco_db\n') | |
48 print(f'{len([c for c in content if c["select"]=="trained_species"])} x trained_species\n') | |
49 print(f'{len([c for c in content if c["select"]=="outgroup"])} x outgroup\n') |