Disembowel a SAM file
BismarkSam is a class of tools to take
apart a SAM file from the output of Bismark when you need to mess with individual reads.
In particular, this was designed to get at the XM tag that indicates methylation status within a read.
Import a SAM file
Read a sample SAM file into memory as a list of BismarkSam objects. It is assumed that the SAM file came from a BAM file that had been aligned with Bismark.
from methlab.BismarkSam import *
path = "tests/test_data/chloroplast.sam"
sam = read_SAM(path)
Return some basic information about the third read in the file: read ID, read length, chromosome and read sequence.
sam[2].id
sam[2].length
sam[2].chr
sam[2].seq
How many methylated sites?
sam[2].count_mC()returns a list showing the total number of methylated and unmethylated cytosinessam[2].mC_per_read()returns a list showing the number of methylated reads, unmethylated reads, total read length, and whether or not cytosines are occur next to one another