Mercurial > repos > iuc > extract_metaphlan_database
diff customizemetadata.py @ 5:b4c750fe0fe3 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/metaphlan/ commit f3a89af137b13715f9fb13383577aceb2c445ce6
author | iuc |
---|---|
date | Sat, 03 Dec 2022 10:42:36 +0000 |
parents | 5b2f8b6a3609 |
children |
line wrap: on
line diff
--- a/customizemetadata.py Wed Feb 02 22:02:12 2022 +0000 +++ b/customizemetadata.py Sat Dec 03 10:42:36 2022 +0000 @@ -56,6 +56,7 @@ 'taxonomy': in_metadata['taxonomy'], 'merged_taxon': {} } + # transform merged_taxons tuple keys to string for k in in_metadata['merged_taxon']: n = ' , '.join(k) @@ -85,6 +86,13 @@ n = ' , '.split(k) out_metadata[n] = in_metadata['merged_taxon'][k] + # Ensure that there are 8 taxonomy levels (for compatibility between Metaphlan v3 and v4) + # v3 DB release encodes the taxids as: ('2|1224|1236|91347|543|547|354276', 4404432) + # v4 DB release encodes the taxids as: ('2|1224|1236|91347|543|547|354276|', 4404432) + for k in out_metadata['taxonomy']: + if out_metadata['taxonomy'][k][0].count('|') == 6: + out_metadata['taxonomy'][k] = (out_metadata['taxonomy'][k][0] + '|', out_metadata['taxonomy'][k][1]) + # dump metadata to Pickle file with bz2.BZ2File(pkl_fp, 'w') as pkl_f: pickle.dump(out_metadata, pkl_f)