sam_hrecs_error Malformed key:value pair
1
0
Entering edit mode
4.2 years ago
Ric ▴ 430

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

alignment • 2.8k views
ADD COMMENT
1
Entering edit mode
3.0 years ago
jilguero888 ▴ 20

I had this error with samtools sort because I set wrongly the @RG header line when calling bowtie2, in particular because I did not specify the SM tag when adding text to the @RG header line with --rg. For example

wrong: --rg-id idxx --rg text
right: --rg-id idxx --rg SM:text

It worked to me.

ADD COMMENT

Login before adding your answer.

Traffic: 2660 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6