Example (copies one samfile to a new BAM file):
original_file = pysam.Samfile('foo')
new_file = pysam.Samfile('foo.bam', mode='wb', template=orginal_file)
for read in original_file: new_file.write(read)
Ben
Use mode='wh' instead, that will work correctly ('h' is for header)
Do you want to submit a bug report so we don't loose track of this
one? <http://code.google.com/p/pysam/issues/list>
Thanks
Ben