def sites_outside_snp(target_seq, snp_pos, allele_pos_end): sites_outside = [] pe_len = len(pe.clean_recognition_sequence) pe_seq = expand_sequence(pe.clean_recognition_sequence.lower()) # seq_before_snp = snp.ex_wt_sequence[:snp.snp_pos - pe_len] # seq_after_snp = snp.ex_wt_sequence[snp.snp_pos + snp.wt_allele_len:] for i in range(0, len(target_seq) - pe_len): try: if i in range(snp_pos - pe_len, allele_pos_end): raise fexceps.DigestError for ii in range(0, pe_len): if not can_recognize(target_seq[i+ii], pe_seq[ii]): raise fexceps.DigestError sites_outside.append(i) except fexceps.DigestError: pass if not pe.clean_recognition_sequence == \ reverse_complement(pe.clean_recognition_sequence): pe_seq_rc = expand_sequence(reverse_complement(pe.clean_recognition_sequence.lower())) for i in range(0, len(target_seq) - pe_len): try: if i in range(snp_pos - pe_len, allele_pos_end): raise fexceps.DigestError for ii in range(0, pe_len): if not can_recognize(target_seq[i+ii], pe_seq_rc[ii]): raise fexceps.DigestError sites_outside.append(i) except fexceps.DigestError: pass return sites_outside
def pe_can_determine_snp(pe:PrototypeEnzyme, snp:Snp, max_num_of_mismatches): pe_len = len(pe.clean_recognition_sequence) pe_seq = expand_sequence(pe.clean_recognition_sequence.lower()) wt_sites = gen_mask(pe_len, pe_seq, snp.ex_wt_sequence, snp.snp_pos, snp.wt_pos_end, snp.wt_allele_len, ) mut_sites = gen_mask(pe_len, pe_seq, snp.ex_mut_sequence, snp.snp_pos, snp.mut_pos_end, snp.mut_allele_len, ) if not pe.clean_recognition_sequence == \ reverse_complement(pe.clean_recognition_sequence): pe_seq_rc = expand_sequence(reverse_complement(pe.clean_recognition_sequence.lower())) wt_sites = wt_sites + gen_mask(pe_len, pe_seq_rc, snp.ex_wt_sequence, snp.snp_pos, snp.wt_pos_end, snp.wt_allele_len, ) mut_sites = mut_sites + gen_mask(pe_len, pe_seq_rc, snp.ex_mut_sequence, snp.snp_pos, snp.mut_pos_end, snp.mut_allele_len, ) wt_filtered = [] for wt_site in wt_sites: try: for mut_site in mut_sites: wt_site = test_intercept(wt_site, mut_site) wt_filtered.append(wt_site) except fexceps.SitesCollisionError: pass mut_filtered = [] for mut_site in mut_sites: try: for wt_site in wt_sites: mut_site = test_intercept(mut_site, wt_site) mut_filtered.append(mut_site) except fexceps.SitesCollisionError: pass return (wt_filtered, mut_filtered)