comparison customizemetadata.py @ 5:892a0629e2ed 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:43:00 +0000
parents a6c3f4f439f7
children
comparison
equal deleted inserted replaced
4:150ebe4d0fd9 5:892a0629e2ed
54 out_metadata = { 54 out_metadata = {
55 'markers': in_metadata['markers'], 55 'markers': in_metadata['markers'],
56 'taxonomy': in_metadata['taxonomy'], 56 'taxonomy': in_metadata['taxonomy'],
57 'merged_taxon': {} 57 'merged_taxon': {}
58 } 58 }
59
59 # transform merged_taxons tuple keys to string 60 # transform merged_taxons tuple keys to string
60 for k in in_metadata['merged_taxon']: 61 for k in in_metadata['merged_taxon']:
61 n = ' , '.join(k) 62 n = ' , '.join(k)
62 out_metadata[n] = in_metadata['merged_taxon'][k] 63 out_metadata[n] = in_metadata['merged_taxon'][k]
63 64
82 } 83 }
83 # transform merged_taxons keys to tuple 84 # transform merged_taxons keys to tuple
84 for k in in_metadata['merged_taxon']: 85 for k in in_metadata['merged_taxon']:
85 n = ' , '.split(k) 86 n = ' , '.split(k)
86 out_metadata[n] = in_metadata['merged_taxon'][k] 87 out_metadata[n] = in_metadata['merged_taxon'][k]
88
89 # Ensure that there are 8 taxonomy levels (for compatibility between Metaphlan v3 and v4)
90 # v3 DB release encodes the taxids as: ('2|1224|1236|91347|543|547|354276', 4404432)
91 # v4 DB release encodes the taxids as: ('2|1224|1236|91347|543|547|354276|', 4404432)
92 for k in out_metadata['taxonomy']:
93 if out_metadata['taxonomy'][k][0].count('|') == 6:
94 out_metadata['taxonomy'][k] = (out_metadata['taxonomy'][k][0] + '|', out_metadata['taxonomy'][k][1])
87 95
88 # dump metadata to Pickle file 96 # dump metadata to Pickle file
89 with bz2.BZ2File(pkl_fp, 'w') as pkl_f: 97 with bz2.BZ2File(pkl_fp, 'w') as pkl_f:
90 pickle.dump(out_metadata, pkl_f) 98 pickle.dump(out_metadata, pkl_f)
91 99