Mercurial > repos > iuc > checkm_taxon_set
annotate format_taxon_list.py @ 2:407e50329077 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 3ae2bd72f789518e95ef65b97e0e5ac90165e113
author | iuc |
---|---|
date | Mon, 02 Sep 2024 13:50:55 +0000 |
parents | e3f1c47246fd |
children |
rev | line source |
---|---|
0
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
1 from pathlib import Path |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
2 |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
3 from checkm.taxonParser import TaxonParser |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
4 from checkm.util.taxonomyUtils import taxonomicRanks |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
5 |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
6 if __name__ == '__main__': |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
7 tool_data_dp = Path('tool-data') |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
8 |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
9 # get all available marker sets |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
10 taxonParser = TaxonParser() |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
11 taxonMarkerSets = taxonParser.readMarkerSets() |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
12 |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
13 # create a table per rank |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
14 for rank in taxonomicRanks: |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
15 rank_fp = tool_data_dp / Path("%s.loc.sample" % rank) |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
16 with rank_fp.open('w') as rank_f: |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
17 rank_f.write('# File generated by format_taxon_list.py script\n') |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
18 rank_f.write('# taxon\tdescription\n') |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
19 for taxon in sorted(taxonMarkerSets[rank]): |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
20 markerSet = taxonMarkerSets[rank][taxon] |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
21 numMarkers, numMarkerSets = markerSet.size() |
e3f1c47246fd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff
changeset
|
22 rank_f.write('{taxon}\t{taxon} ({markerSet.numGenomes} genomes, {numMarkers} marker genes, {numMarkerSets} marker sets)\n') |