FileNotFoundError: [Errno 2]: Metaphlan 3.0.7

Hi,
I’m getting the below-mentioned error when I’m trying to run Metaphlan v3 on paired-end metagenome sequencing data. I’m using the on-campus HPC that uses Slurm workload manager for job scheduling, to run metaphlan.

File “/opt/metaphlan/3.0.7/anaconda3/bin/read_fastx.py”, line 10, in
sys.exit(main())
File “/opt/metaphlan/3.0.7/anaconda3/lib/python3.8/site-packages/metaphlan/utils/read_fastx.py”, line 155, in main
f_nreads, f_avg_read_length = read_and_write_raw(f, opened=False, min_len=min_len)
File “/opt/metaphlan/3.0.7/anaconda3/lib/python3.8/site-packages/metaphlan/utils/read_fastx.py”, line 117, in read_and_write_raw
with fopen(fd) as inf:
File “/opt/metaphlan/3.0.7/anaconda3/lib/python3.8/site-packages/metaphlan/utils/read_fastx.py”, line 53, in fopen
return open(fn)
FileNotFoundError: [Errno 2] No such file or directory: ‘’

Below are the command line arguments I used to run metaphlan using the batch scheduler:

Loading modules required for script commands

module load metaphlan

Changing directories to where the fastq files are located

cd /scratch/hasitha/WaterProject/Metagenome

Running metaphlan3.0

metaphlan 68_1.fq.gz,68_2.fq.gz, --nproc 8 --input_type fastq --bowtie2out /scratch/hasitha/WaterProject/Metagenome/metaphlan_outputs/metagenome.bowtie2.bz2 --bowtie2db /scratch/hasitha/WaterProject/Metagenome/metaphlan_outputs/ -o /scratch/hasitha/WaterProject/Metagenome/metaphlan_outputs/profiled_sample68.tx

Would greatly appreciate is someone can shed some light on solving this issue.

Thank you.
Hasitha.

Hi,
You have a trailing comma in the input files that makes the command fail.
metaphlan 68_1.fq.gz,68_2.fq.gz, should be metaphlan 68_1.fq.gz,68_2.fq.gz

1 Like

That was very sloppy of me to miss that. Ran without any issues after fixing that.
Thank you very much for the help.

Hello,

I reopen this help thread because I have obtained the same error described here (but I don’t have the trailing comma in the input files, solved by MetaPhlan developer @fbeghini in this issue) although the output obtained it seems correct (see below).

The standard error file contained the following error:

Traceback (most recent call last):
  File "/opt/conda/bin/read_fastx.py", line 10, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.7/site-packages/metaphlan/utils/read_fastx.py", line 167, in main
    f_nreads, f_avg_read_length = read_and_write_raw(f, opened=False, min_len=min_len, prefix_id=prefix_id)
  File "/opt/conda/lib/python3.7/site-packages/metaphlan/utils/read_fastx.py", line 128, in read_and_write_raw
    with fopen(fd) as inf:
  File "/opt/conda/lib/python3.7/site-packages/metaphlan/utils/read_fastx.py", line 56, in fopen
    return open(fn)
FileNotFoundError: [Errno 2] No such file or directory: ''

However the ouput for one sample, as example, their head it seems ok:

#mpa_v30_CHOCOPhlAn_201901
#/opt/conda/bin/metaphlan --index mpa_v30_CHOCOPhlAn_201901 --bowtie2_exe /home/david/bin/bowtie2-2.4.5-linux-x86_64/bowtie2 --bowtie2db /root/references/metagenomics_stable/metaphlan3 /root/clean_reads/AL1500.m1.fq.gz,/root/clean_reads/AL1500.m2.fq.gz -t rel_ab_w_read_stats --input_type fastq --nproc 8 --bowtie2out AL1500.metaphlan3.bowtie2
#SampleID       Metaphlan_Analysis
#estimated_reads_mapped_to_known_clades:48621175
#clade_name     clade_taxid     relative_abundance      coverage        estimated_number_of_reads_from_the_clade
k__Bacteria     2       100.0   15.01793        43636845
k__Bacteria|p__Firmicutes       2|1239  83.18411        12.49253        35516220

As I stated above, it’s seems that works properly but I’m worried about the error obtained in the standard error file.

Thanks for your hints,

David