annotate format_taxon_list.py @ 1:5ee29434330f draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit a96defec82bfa9628fa821ffa6df5c68314a41d8
author iuc
date Mon, 08 Aug 2022 20:00:57 +0000
parents 7ccea589e8b7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7ccea589e8b7 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
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
2
7ccea589e8b7 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
7ccea589e8b7 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
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
5
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
6 if __name__ == '__main__':
7ccea589e8b7 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')
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
8
7ccea589e8b7 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
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
10 taxonParser = TaxonParser()
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
11 taxonMarkerSets = taxonParser.readMarkerSets()
7ccea589e8b7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/checkm commit 2a3b068a98bf0e913dc03e0d5c2182cfd102cf27
iuc
parents:
diff changeset
12
7ccea589e8b7 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
7ccea589e8b7 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:
7ccea589e8b7 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)
7ccea589e8b7 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:
7ccea589e8b7 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')
7ccea589e8b7 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')
7ccea589e8b7 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]):
7ccea589e8b7 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]
7ccea589e8b7 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()
7ccea589e8b7 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')