MetaPhlAn 2 UnboundLocalError

Hello,
Excuse me, I got an issue when using MetaPhlAn 2.0:

step1
I’ve followed the instruction to install( [metaphlan2 · biobakery/biobakery Wiki · GitHub] ), though when I ran:
$ metaphlan2.py <input_fasta> --input_type fasta > <output_name>
the partial error message came like that:

  File "/newdisk1/ijenn/BadouziProject/Preparation/MIMOSA/proceMetagenomic/download/MetaPhlAn-2.8/metaphlan2.py", line 836, in check_and_install_database
    download_unpack_tar(FILE_LIST, index, bowtie2_db, bowtie2_build, nproc)
  File "/newdisk1/ijenn/BadouziProject/Preparation/MIMOSA/proceMetagenomic/download/MetaPhlAn-2.8/metaphlan2.py", line 745, in download_unpack_tar
    url_tar_file = ls_f["mpa_" + download_file_name + ".tar"]
UnboundLocalError: local variable 'ls_f' referenced before assignment

My assumption is that “metaphlan2.py” couldn’t find my “mpa_…”file.

Step2.
So I’ve searched for the files (
[MetaPhlAn 3 | Zenodo] or [Index of /databases/MetaPhlAn/metaphlan_databases ])and placed into the “metaphlan_databases folder”
, then I ran:
$ metaphlan2.py <input_fasta> --input_type fasta -x MetaPhlAn-2.8/metaphlan_databases/mpa_v30_CHOCOPhlAn_201901 --bowtie2db MetaPhlAn-2.8/metaphlan_databases/ > <output_name>
Though the same error came:

"/newdisk1/ijenn/BadouziProject/Preparation/MIMOSA/proceMetagenomic/download/MetaPhlAn-2.8/metaphlan2.py", line 745, in download_unpack_tar
    url_tar_file = ls_f["mpa_" + download_file_name + ".tar"]
UnboundLocalError: local variable 'ls_f' referenced before assignment

I have no idea left to solve this, hoping someone could help me with that.
Thank you so much.
Regards,
Ijenn

Hi @Ijenn
The MetaPhlAn 3.0 marker database is not compatible using metaphlan2. Please, upgrate the metaphlan version to 3 (or even to version 4) or instead use the old mpa_v20 database (Index of /biobakery3/metaphlan_databases)

1 Like

Hi,
Thanks for your reply!
Eventually I found out that it’s the coding of the database download site in metaphlan.py have to be changed, because the original file is empty[Dropbox - File Deleted]. In that case, I will try your way to upgrade to version4.

Regards,