Dear Anvi'o masters,
I am using the following mapping loop to map the reads on the contigs, as suggested on Anvi'o website.
for sample in `awk '{print $1}' samples_all.txt`
do
echo "###Mapping Sample" $sample "Start###"
ls $READS_DNA/$sample*QUALITY_PASSED_R1* $READS_DNA/$sample*QUALITY_PASSED_R2*
bowtie2 --threads $NUM_THREADS \
-x 04_MAPPING/contigs \
-1 $READS_DNA/$sample*QUALITY_PASSED_R1* -2 $READS_DNA/$sample*QUALITY_PASSED_R2* \
-S 04_MAPPING/$sample.sam >04_MAPPING/$sample"_bowtie_report.txt" 2>&1
samtools view -F 4 -bS 04_MAPPING/$sample.sam -@ $NUM_THREADS -o 04_MAPPING/$sample-RAW.bam
anvi-init-bam 04_MAPPING/$sample-RAW.bam \
-o 04_MAPPING/$sample.bam
rm 04_MAPPING/$sample.sam 04_MAPPING/$sample-RAW.bam
echo "###Mapping Sample" $sample "done###"
done
Sometimes, for no obvious reason, I got the following error related to my bam file,
[E::sam_parse1] SEQ and QUAL are of different length
[W::sam_read1] parse error at line 1190397
[main_samview] truncated file.and the bam file is tiny.
and when I try again with the same fastq files and same bowtie index, it works perfectly fine.
I was a bit exited to get my profiles and was planning to use the following code to check my bam before running anvi profile in order to redo the files with error but I do not really like that and will like to understand where the issue is coming from.
samtools quickcheck -v 04_MAPPING/*.bam > 04_MAPPING/bad_bams.fofn && echo 'all ok' || echo 'some files failed check, see bad_bams.fofn'
Bug:
(anvio3) const@S620100019620:/media/DataDrive05/Flo/EZ/all_combined$ sh mapping-loop.sh ###Mapping Sample mFMbES001 Start###
[E::sam_parse1] SEQ and QUAL are of different length
[W::sam_read1] parse error at line 1190397
[main_samview] truncated file.
Sorted BAM File ..............................: /media/DataDrive05/Flo/EZ/all_combined/04_MAPPING/mFMbES001.bam BAM File Index ...............................: /media/DataDrive05/Flo/EZ/all_combined/04_MAPPING/mFMbES001.bam.bai rm: cannot remove ‘04_MAPPING/mFMbES001.sam’: No such file or directory
rm: cannot remove ‘04_MAPPING/mFMbES001-RAW.bam’: No such file or directory
###Mapping Sample mFMbES001 done###
working (few minutes after).
(anvio3) const@S620100019620:/media/DataDrive05/Flo/EZ/all_combined$ sh mapping-loop.sh
###Mapping Sample mFMbES001 Start###
/media/DataDrive05/Flo/EZ/all_combined/01_QC/mFMbES001-QUALITY_PASSED_R1.fastq.gz /media/DataDrive05/Flo/EZ/all_combined/01_QC/mFMbES001-QUALITY_PASSED_R2.fastq.gz
Sorted BAM File ..............................: /media/DataDrive05/Flo/EZ/all_combined/04_MAPPING/mFMbES001.bam BAM File Index ...............................: /media/DataDrive05/Flo/EZ/all_combined/04_MAPPING/mFMbES001.bam.bai ###Mapping Sample mFMbES001 done###
I am using anvio3 installed thanks to (conda create -n anvio3 -c bioconda -c conda-forge python=3.5.4 gsl anvio) on a Linux 14.04 LTS
If you have already experienced this or have any idea, that will be helpful!
Cheers,
Flo