Entering edit mode
4.8 years ago
Ric
▴
440
Hi, I am using the following bash script to map all FASTQ files in a folder with Bowtie2 and should convert it to bam files:
#!/bin/bash
#usage: sh bowtie2_pairend_pbs.sh /data ref.fasta bams
mkdir $3
for r1 in $(find $1 -name "*_R1*.fq");
do
output=$(basename $(echo $r1 | sed 's/_R1//g'))
r2=$(echo $r1 | sed 's/_R1/_R2/g')
#cat <<EOF
qsub <<EOF
#!/bin/bash -l
#PBS -N $output
#PBS -l walltime=24:00:00
#PBS -j oe
#PBS -l mem=30G
#PBS -l ncpus=8
##PBS -m bea
cd \$PBS_O_WORKDIR
conda activate bowtie2
# Alignment
bowtie2 -p 8 \
--rg-id ${output} --rg ${output} --rg ${output} --rg ${output} --rg ${output} \
-x ${2%.*} -1 $r1 -2 $r2 | samtools sort -@ 8 - -o ${3}/${output}-bowtie2.sorted.bam
samtools index ${3}/${output}-bowtie2.sorted.bam
samtools stats ${3}/${output}-bowtie2.sorted.bam > ${3}/${output}-bowtie2.sorted.bam.stats
conda deactivate
EOF
done
Unfortunately, I got the following error
[E::sam_hrecs_error] Malformed key:value pair at line 6494: "@RG ID:faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq"
[E::sam_hrecs_error] Malformed key:value pair at line 6494: "@RG ID:faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq faspt-rm_adapters_correction.232.fq"
samtools sort: failed to change sort order header to 'coordinate'
How is it possible to fix it?
Thank you in advance