Samtools view trouble reading files


I am trying to run StrainPhlan but keep getting an error message: samtools view: error reading file “/workdir/mjc437/shotgun_bs3/consensus_markers/tmppg99h1r4/BS3_30_R1_kneaddata.fastq.sam”

I’m using Methphlan 3.0 (installed via Conda), and added bowtie2, muscle, and samtools (version 1.14) to PATH. I’m also using a remote server to run StrainPhlan. I’m relatively new to StrainPhlan, and any help would be appreciated. My code is below. Thanks!

(mpa) [mjc437@cbsujohnson shotgun_bs3]$ export PATH=/programs/bowtie2-2.4.3-linux-x86_64:$PATH

(mpa) [mjc437@cbsujohnson shotgun_bs3]$ export PATH=/programs/samtools-1.14/bin:$PATH

(mpa) [mjc437@cbsujohnson shotgun_bs3]$ export PATH=/programs/muscle:$PATH

(mpa) [mjc437@cbsujohnson shotgun_bs3]$ -i sams/*.sam.bz2 -o consensus_markers --nproc 4

Thu Feb 10 11:02:04 2022: Start samples to markers execution

Thu Feb 10 11:02:04 2022: Decompressing samples…

bzip2: Compressed file ends unexpectedly;

perhaps it is corrupted? Possible reason follows.

bzip2: Success

Input file = sams/BS3_30_R1_kneaddata.fastq.sam.bz2, output file = (stdout)

It is possible that the compressed file(s) have become corrupted.

You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover’ program to attempt to recover

data from undamaged sections of corrupted files.

Thu Feb 10 11:02:36 2022: Done.

Thu Feb 10 11:02:36 2022: Converting samples to BAM format…

[W::sam_read1_sam] Parse error at line 2985311

samtools view: error reading file “consensus_markers/tmpj6bvyh73/BS3_30_R1_kneaddata.fastq.sam”

Hi @M_Craig ,
Thanks for getting in touch. From the error log it seems that the problem is related to the file sams/BS3_30_R1_kneaddata.fastq.sam.bz2 as it seems to be corrupted. A potential explanation is that the MetaPhlAn execution for that file was ended unexpectly before finishing the profiling. Could you check whether the output profile from MetaPhlAn was generated?


1 Like

Hi Aitor,

Thanks for your response. I guess there was something wrong with my files. I ended up re-running Metaphlan and now everything works. Thanks for the help!