Last active
January 19, 2016 14:35
-
-
Save mdshw5/1f084f69fcbd8ac93991 to your computer and use it in GitHub Desktop.
biostars 173201
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from simplesam import Reader | |
from pyfaidx import Fasta | |
with Reader(open('library.bam', 'r')) as sam_file, Fasta('hg38.fa', as_raw=True) as hg38: | |
for read in sam_file: | |
if read.mapped: | |
# might also want to handle read.reverse here | |
prior_pos = read.pos - 2 # read.pos is 1-based | |
prior_base = hg38[read.rname][prior_pos] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment