Skip to content

'missing SAM header' when opening SAM files

Created by: AlexanderDilthey

Hi,

There seems to be an issue with iterating over alignments in a SAM file. I get the errors

[E::sam_parse1] missing SAM header
[W::sam_read1] parse error at line 4

although there are headers.

Code for reproducing the problem:

use Bio::DB::HTS;
my $sam =  Bio::DB::HTS->new(-bam => 'test.sam');
my $alignment_iterator = $sam->features(-iterator => 1);	
$alignment_iterator->next_seq;

and test.sam:

@HD	VN:1.5	SO:coordinate
@SQ	SN:ref	LN:100
r001	99	ref	1	30	1M3D2M	=	37	3	TAT	*
r002	99	ref	1	30	1M2D2M	=	37	3	TAT	*

samtools can view the SAM without problems.