Samtools view error:
2
0
Entering edit mode
3.5 years ago
jaqx008 ▴ 110

Hello all,

I am having an error which is new to me and I couldn't really find any useful tips.

I am trying to convert a sam file generated with bowtie (one) into a bam file using samtools view -b. The command prints the following code and a 27byte bam output. see error bellow. Do anyone know what might be the issue or how I can rectify this?

[E::sam_hrecs_error] Header line does not have a two character key at line 246:
"@A00881:421:HM7W5DRXX:1:2101:1118:1016 16  NC_005109.4 73902262    255 23M GTCAACATCAGTCTGATAAGCTA IIIIIIIIIIIIIIIIIIIIIII XA:i:0  MD:Z:23 NM:i:0  XM:i:2"
samtools view: failed to add PG line to the header ^Z

Thank you

bowtie Samtools • 4.7k views
ADD COMMENT
0
Entering edit mode
ADD REPLY
0
Entering edit mode

The error may be fixable by editing the SAM file header.

ADD REPLY
0
Entering edit mode

@ Istvan Albert I saw that I can edit the header with samtools header but not sure what the new header should read (what to include).

ADD REPLY
0
Entering edit mode

Thank you. The link recommended adding --no-PG to the command. This did not really help. it produced the error

error: node035: task 0: Exited with exit code 1
ADD REPLY
0
Entering edit mode

what is the output of

cat data.sam | head -100 | grep ^@

that would tell you which headers seem malformed.

ADD REPLY
2
Entering edit mode
3.2 years ago
arrmino ▴ 20

I guess the problem is that the name of reads have the @ as start and samtools interprets that as a header line. Probably this happens if you run for example bowtie2 using a FASTA instead of a FASTQ file, i.e. for FASTA the @ in read names does not get removed. Use sed to edit the file like: sed 's/\@A00881/A00881/g' yoursamfile > newsamfile

ADD COMMENT
0
Entering edit mode
3.0 years ago
jilguero888 ▴ 20

It seems that samtools is becoming stricter about proper format of sam files about tags in header lines. I had a similar error to the one reported here just because I did not set properly the SM tag in the @RG header line when calling bowtie2.

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: 1706 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