def test_primer_design_overorigin(self): """Tests whether primers can be designed over an origin of a cyclic sequence.""" fixtures = join(abspath(dirname(__file__)), "fixtures") with open(join(fixtures, "template.txt")) as f: template = f.read().strip() region = Region(2020, 1616, len(template), cyclic=True) adjusted_template = region.get_slice(template) + region.invert()[0].get_slice( template ) rprimer = "CGCTGGAGAAAACCTTCGTATCGGCgcatgcacgcgtgtcgacatcg" assert ( rc("CGCTGGAGAAAACCTTCGTATCGGCgcatgcacgcgtgtcgacatcg".upper()) in adjusted_template.upper() ) fwd, rev = anneal(adjusted_template, [rprimer]) print(rev[0]["top_strand_slice"]) rprimer = "CGCTGGAGAAAACCTTCGTATCGGCgcatgcacgcgtgtcgacatcg" pairs, explain = _design_primers(template, region, None, rseq=rprimer) print(json.dumps(pairs, indent=1)) print(explain) assert pairs
def test_anneal(): s = "ACGTGTATGTGATGATGTGCGTGTGTCGTGTAGCTTATTATATGCGGAGTCGTTGATGCTGTGAGT" fwd, rev = anneal(s, ["AAAAAGTGCGTGTGTCGTGTAG".lower()]) match = list(fwd)[0] assert match["start"] == 16 assert match["start"] + match["length"] == 33 assert match["anneal"] == "GTGCGTGTGTCGTGTAG".lower() assert match["overhang"] == "AAAAA".lower() print(match)
def test_anneal_rev(): s = "ACGTGTATGTGATGATGTGCGTGTGTCGTGTAGCTTATTATATGCGGAGTCGTTGATGCTGTGAGT" fwd, rev = list(anneal(s, ["ANNNN" + reverse_complement(s[20:40])])) print(rev[0]) assert rev[0]["start"] == 39 assert rev[0]["top_strand_slice"] == (20, 40) assert rev[0]["anneal"] == reverse_complement(s[20:40]) assert rev[0]["overhang"] == "ANNNN" assert rev[0]["strand"] == -1
def test_anneal_fwd(): s = "ACGTGTATGTGATGATGTGCGTGTGTCGTGTAGCTTATTATATGCGGAGTCGTTGATGCTGTGAGT" fwd, rev = list(anneal(s, ["NNNNN" + s[20:40]])) assert fwd[0]["start"] == 20 assert fwd[0]["start"] + fwd[0]["length"] == 40 assert fwd[0]["top_strand_slice"] == (20, 40) assert fwd[0]["anneal"] == s[20:40] assert fwd[0]["overhang"] == "NNNNN" assert fwd[0]["strand"] == 1
def check_primers(gfp, primerlist): fwd, rev = anneal(gfp, primerlist, n_bases=16) span_region_ok = [] for primer in fwd: s = primer["start"] l = len(primer["anneal"]) span_region_ok.append([s, l, -1, -1]) for primer in rev: s = primer["start"] l = len(primer["anneal"]) span_region_ok.append([-1, -1, s, l]) return span_region_ok
def test_anneal_end(): s = "ACGTGTATGTGATGATGTGCGTGTGTCGTGTAGCTTATTATATGCGGAGTCGTTGATGCTGTGAGT" fwd, rev = anneal(s, [s[-16:]]) match = list(fwd)[0] assert match["start"] == len(s) - 16 assert match["start"] + match["length"] == len(s)
def test_anneal_rev2(gfp): fwd, rev = list(anneal(gfp, ["ANNNN" + reverse_complement(gfp[200:220])])) assert rev print(rev) assert not fwd