UnboundLocalError: local variable 'qmax' referenced before assignment


Does anyone know how to solve this problem?

kennyyeo@Kennys-Mac-mini biobakery_workflows_databases % biobakery_workflows 16s --method usearch --usearch-db /Users/kennyyeo/biobakery_workflows_databases/green_genes_fasta_db/97_otus.fasta,/Users/kennyyeo/biobakery_workflows_databases/green_genes_taxonomy_db/97_otu_taxonomy.txt --input-extension fastq.gz --input /Volumes/Expansion/hnsc_microbiome_online/16S_analysis/PRJNA352375/fastq_16s --fwd-primer AGAGTTTGATYMTGGCTCAG --rev-primer GWATTACCGCGGCKGCTG --output /Volumes/Expansion/hnsc_microbiome_online/16S_analysis/PRJNA352375/output --threads 6
Traceback (most recent call last):
File “/Users/kennyyeo/miniconda3/envs/picrust1/bin/16s.py”, line 165, in
workflow, args.method, all_samples_fastq, args.output, args.threads, args.maxee, args.trunc_len_max, args.fastq_ascii)
File “/Users/kennyyeo/miniconda3/envs/picrust1/lib/python2.7/site-packages/biobakery_workflows/tasks/sixteen_s.py”, line 58, in quality_control
qc_report = quality_report(workflow, method, fastq_file, output_folder, threads, qmax)
UnboundLocalError: local variable ‘qmax’ referenced before assignment

Hello, If you would update to the latest version of the workflows it should resolve the qmax reference issue.

Thank you,

An UnboundLocalError is raised when a local variable is referenced before it has been assigned. In most cases this will occur when trying to modify a local variable before it is actually assigned within the local scope. Python doesn’t have variable declarations, so it has to figure out the scope of variables itself. It does so by a simple rule: If there is an assignment to a variable inside a function, that variable is considered local.

Python has lexical scoping by default, which means that although an enclosed scope can access values in its enclosing scope, it cannot modify them (unless they’re declared global with the global keyword). A closure binds values in the enclosing environment to names in the local environment. The local environment can then use the bound value, and even reassign that name to something else, but it can’t modify the binding in the enclosing environment. UnboundLocalError happend because when python sees an assignment inside a function then it considers that variable as local variable and will not fetch its value from enclosing or global scope when we execute the function. However, to modify a global variable inside a function, you must use the global keyword.