Metaphlan: sgb_to_gtdb_profile.py fails with KeyError

MetaPhlAn version 4.1.1 (11 Mar 2024)
(installed from bioconda)

I profiled my metagenome and successfully created the metaphlan profile file, but got this warning message in the process:

WARNING: The metagenome profile contains clades that represent multiple species merged into a single representant.

I then tried to convert to gtdb taxonomy (for a comparison) but received this error message:

Mon Jun 2 15:36:05 2025: Start execution
Traceback (most recent call last):
File “/home/ubuntu/miniforge3/envs/tax_class/bin/sgb_to_gtdb_profile.py”, line 10, in
sys.exit(main())
^^^^^^
File “/home/ubuntu/miniforge3/envs/tax_class/lib/python3.12/site-packages/metaphlan/utils/sgb_to_gtdb_profile.py”, line 97, in main
get_gtdb_profile(args.input, args.output, database_controller.get_database_name())
File “/home/ubuntu/miniforge3/envs/tax_class/lib/python3.12/site-packages/metaphlan/utils/sgb_to_gtdb_profile.py”, line 72, in get_gtdb_profile
gtdb_tax = sgb2gtdb[line[0].split(‘|’)[-1][3:]]
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: ‘SGB10139_group’

I tried re-installing the database and I think I have the most recent version:
mpa_vJan25_CHOCOPhlAnSGB_202503…

How can I convert the taxonomy to gtdb?
Thanks.

Hi @jtrachsel
Can you check that the database specified in the sgb_to_gtdb_profile.py corresponds to the database you used to run MetaPhlAn?
For the sgb_to_gtdb_profile.py you should find this info at the beginning of the file (defined as variable GTDB_ASSIGNMENT_FILE), while for the metaphlan profiles it’s in the header of the profile.