Beispiel #1
0
 def test_left_overhang_default_behavior(self, gfp):
     """Without setting overhangs, should raise run time error."""
     design = Design()
     design.settings.template(gfp)
     design.settings.left_sequence("AGGCGGCTGA" + gfp[20:40])
     with pytest.raises(Primer3PlusRunTimeError):
         design.run()
Beispiel #2
0
    def test_right_overhang_default_behavior(self, gfp):
        """Without setting overhangs, should raise run time error."""
        design = Design()
        design.settings.template(gfp)

        rseq = "AAAAAA" + rc(gfp[200:220])
        design.settings.right_sequence(rseq)
        with pytest.raises(Primer3PlusRunTimeError):
            design.run()
Beispiel #3
0
def test_gfp(gfp, iter_random_primer):
    fwd_primers = list(iter_random_primer(25, gfp[:250], 16))
    rev_primers = list(iter_random_primer(25, rc(gfp)[:250], 16))

    primers = fwd_primers + rev_primers

    # from itertools import product
    #
    # for f, r in product(fwd_primers,  rev_primers):
    #     design = Design()
    #     design.settings.left_sequence(f)
    #     design.settings.right_sequence(r)
    #     design.settings.task('check_primers')
    #     design.settings.template(gfp)
    #     design.run()

    region_ok = check_primers(gfp, primers)
    # print(region_ok[:1])
    design = Design()
    design.settings.template(gfp)
    print(region_ok)
    design.settings.pair_region_list(region_ok[:10])
    design.settings.product_size([50, 2000])
    pairs, explain = design.run()
    print(explain)
    print(pairs)
Beispiel #4
0
def test_set(gfp):
    design = Design()
    design.settings.template(gfp)
    design.settings.left_sequence(gfp[60:85])
    design.settings.as_generic_task()
    results = design.run()
    print(results)
    assert results
Beispiel #5
0
def test_run_and_optimize_basic(gfp, iter_random_primer):
    fwd = gfp[:25]
    rev = reverse_complement(gfp[-25:])
    design = Design()
    design.settings.template(gfp)
    design.settings.left_sequence(fwd)
    design.settings.right_sequence(rev)
    design.settings.task("check_primers")
    pairs, explain = design.run()
    assert not pairs

    pairs, explain = design.run_and_optimize(15)
    print(explain)
    assert pairs
Beispiel #6
0
    def test_set_long_overhang(self, gfp):
        design = Design()
        design.settings.template(gfp)
        design.settings.left_sequence(gfp[0:50])
        design.PRIMER_MAX_TM.value = 75.0
        design.PRIMER_MAX_SIZE = 35
        design.PRIMER_PICK_ANYWAY = 1
        design.settings.left_overhang("AAAAAAAAA")
        design.settings.long_ok()
        design.settings.use_overhangs()
        design.settings.pick_anyway()
        pairs, explain = design.run()

        print(explain)
        import json

        print(json.dumps(pairs[0]["LEFT"], indent=1))
        assert pairs
Beispiel #7
0
    def test_long_left_primer_with_overhangs(self, gfp):
        """We expect no errors with setting long left primers.

        The settings should automatically readjust the product length to
        match and the 'SEQUENCE', 'OVERHANG', and 'location' and
        'PRODUCT_SIZE' results should automatically be adjusted.
        """
        design = Design()
        design.settings.template(gfp)
        design.settings.left_sequence(gfp[:50])
        design.settings.product_size((len(gfp), len(gfp)))

        loverhang = "TTTTTTT"
        roverhang = "GGGAGAG"

        design.settings.left_overhang(loverhang)
        design.settings.right_overhang(roverhang)
        design.settings.long_ok()
        design.settings.use_overhangs()
        design.settings.pick_anyway()
        pairs, explain = design.run()

        pprint(pairs)
        assert pairs
        for pair in pairs.values():
            assert pair["PAIR"]["PRODUCT_SIZE"] == len(gfp)
            assert pair["RIGHT"]["OVERHANG"] == roverhang
            assert pair["LEFT"]["OVERHANG"] == loverhang
            assert pair["LEFT"]["SEQUENCE"] == gfp[:50]

            lloc = pair["LEFT"]["location"]
            rloc = pair["RIGHT"]["location"]

            assert lloc[0] == 0
            assert lloc[1] == 50

            assert rloc[0] == len(gfp) - 1
        assert pairs
Beispiel #8
0
 def test_as_list_of_tuples(self, gfp):
     design = Design()
     design.settings.template(gfp).excluded([(100, 300)])
     pairs, explain = design.run()
     assert pairs
Beispiel #9
0
 def test_as_list(self, gfp):
     design = Design()
     design.settings.template(gfp).excluded([100, 300])
     print(design.SEQUENCE_EXCLUDED_REGION)
     pairs, explain = design.run()
     assert pairs
Beispiel #10
0
def test_product_size_list(gfp):

    design = Design()
    design.settings.template(gfp)
    design.settings.product_size([(50, 100), (200, 300)])
    design.run()
Beispiel #11
0
 def test_raises_value_error(self, gfp):
     design = Design()
     design.settings.template(gfp).included([None, 100])
     print(design.SEQUENCE_INCLUDED_REGION)
     with pytest.raises(TypeError):
         design.run()
Beispiel #12
0
 def test_as_str(self, gfp):
     design = Design()
     design.settings.template(gfp).included(gfp[100:300])
     print(design.SEQUENCE_INCLUDED_REGION)
     pairs, explain = design.run()
     assert pairs
Beispiel #13
0
 def test_as_tuple(self, gfp):
     design = Design()
     design.settings.template(gfp).included((100, 100))
     print(design.SEQUENCE_INCLUDED_REGION)
     pairs, explain = design.run()
     assert pairs
Beispiel #14
0
 def test_as_str(self, gfp):
     design = Design()
     design.settings.template(gfp).excluded(gfp[100:300])
     pairs, explain = design.run()
     assert pairs