The bioBakery help forum

UnboundLocalError: local variable 'input_faa_clean' referenced before assignment

thanks for the great tool

I download phylophlan version 3, and learn the High-resolution phylogeny of 135 Staphylococcus aureus isolate genomes
when I run Step 3. Build the phylogeny of the 135 S. aureus isolate genomes

phylophlan \
    -i input_isolates \
    -o output_isolates \
    -d s__Staphylococcus_aureus \
    --trim greedy \
    --not_variant_threshold 0.99 \
    --remove_fragmentary_entries \
    --fragmentary_threshold 0.67 \
    --min_num_entries 135 \
    -t a \
    -f isolates_config.cfg \
    --diversity low \
    --force_nucleotides \
    --nproc 4 \
    --verbose 2>&1 | tee logs/phylophlan__output_isolates.log

I get an error

Traceback (most recent call last):
  File "/miniconda3/envs/phylophlan/bin/phylophlan", line 10, in <module>
  File "/miniconda3/envs/phylophlan/lib/python3.7/site-packages/phylophlan/", line 3229, in phylophlan_main
    standard_phylogeny_reconstruction(project_name, configs, args, db_dna, db_aa)
  File "/miniconda3/envs/phylophlan/lib/python3.7/site-packages/phylophlan/", line 3035, in standard_phylogeny_reconstruction
    all_inputs = (os.path.splitext(os.path.basename(i))[0] for i in input_faa_clean)
UnboundLocalError: local variable 'input_faa_clean' referenced before assignment

could anyone give me a hand?


There is currently a discussion about this issue on the repository’s issues on Github:
I think I’ve fixed this with this commit

Can you please update/install PhyloPhlAn from the repository instead of the Bioconda package to test if this fixes your problem?

Many thanks,

In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a value anywhere within the function’s body, it’s assumed to be a local unless explicitly declared as global. The unboundlocalerror: local variable referenced before assignment is raised when you try to use a variable before it has been assigned in the local context. All variable assignments in a function store the value in the local symbol table; whereas variable references first look in the local symbol table, then in the global symbol table, and then in the table of built-in names. Thus, global variables cannot be directly assigned a value within a function (unless named in a global statement), although they may be referenced.