brittneybrinsfield / pysam

Automatically exported from code.google.com/p/pysam
0 stars 0 forks source link

Opening a SAM or BAM file without SQ fields in the header #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Sam file without SQ fields in the header

What is the expected output? What do you see instead?
The sam file opens without a problem, but instead I see:
    infile = pysam.Samfile(opts.filename,'rb')
  File "csamtools.pyx", line 459, in csamtools.Samfile.__cinit__ (pysam/csamtools.c:4992)
  File "csamtools.pyx", line 591, in csamtools.Samfile._open (pysam/csamtools.c:6438)
ValueError: file header is empty (mode='rb') - is it SAM/BAM format?

This is extremely useful as the output of many pipelines produce unmapped BAMs, 
and it is necessary to manipulate such data without a reference.

Original issue reported on code.google.com by nilsho...@gmail.com on 17 Oct 2012 at 4:31

GoogleCodeExporter commented 9 years ago
Tricky. Basically, iterating in a bam file without SQ lines works only if there 
are only unmapped reads. If there are mapped reads, a segfault occurs within 
C-samtools.

I have kept the check for header and sq lines, but added the options
check_header and check_sq to turn checking off.

Best wishes,
Andreas

Original comment by andreas....@gmail.com on 20 Nov 2012 at 7:14