""" Investigating the region of NUDT4P near Notch2NL-A that appears to have segregating deletions. """ roi = ['chr1', 146231874, 146358436] na12878_bam = '/hive/users/ifiddes/longranger-1.2.0/NA12878_combined/outs/phased_possorted_bam.bam' import pysam import numpy as np from extract_linked_bams import bin_reads bam_handle = pysam.Samfile(na12878_bam) reads = bin_reads(roi[0], roi[1], roi[2], bam_handle, offset=10000) # 4730 tags # now, I want to grab any read with these tags, mapped or unmapped. def eval_rec(rec, read_dict): tags = dict(rec.tags) if 'BX' in tags: t = tags['BX'] if t in read_dict: read_dict[t].append(rec) full_reads = reads.copy() for rec in bam_handle.fetch(until_eof=True): eval_rec(rec, full_reads)
""" Attempt to construct unitigs out of reads in the region and map them back to the reference """ roi = ['chr1', 145966000, 146510000] na12878_bam = '/hive/users/ifiddes/longranger-1.2.0/NA12878_combined/outs/phased_possorted_bam.bam' import pysam import numpy as np from collections import defaultdict from extract_linked_bams import bin_reads bam_handle = pysam.Samfile(na12878_bam) unitig_region_mapped_reads = bin_reads(roi[0], roi[1], roi[2], bam_handle, offset=10000) def eval_rec(rec, read_dict): tags = dict(rec.tags) if 'BX' in tags: t = tags['BX'] if t in read_dict: read_dict[t].append(rec) # now bring in the unmapped reads unmapped_bam = '/hive/users/ifiddes/longranger-1.2.0/NA12878_combined/outs/unmapped.bam' unitig_region_mapped_and_unmapped_reads = unitig_region_mapped_reads.copy() unmapped_handle = pysam.Samfile(unmapped_bam) for rec in unmapped_handle.fetch(until_eof=True): eval_rec(rec, unitig_region_mapped_and_unmapped_reads)