コード例 #1
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_near_index():
    '''Test binding near index for circular templates.'''
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))
    template = template.circularize()
    seq = DNA('aggccctttcgtctcgcgcgttt')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    print fwd_matches
    print loc[0]
    print loc[1]
    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))
    for match in loc[0]:
        expected = match + len(seq)
        if expected > len(template):
            expected -= len(template)
        assert_true(expected in fwd_indices)
    for match in loc[1]:
        expected = match + len(seq)
        if expected > len(template):
            expected -= len(template)
        assert_true(expected in rev_indices)
コード例 #2
0
def test_near_index():
    '''Test binding near index for circular templates.'''
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))
    template = template.circularize()
    seq = DNA('aggccctttcgtctcgcgcgttt')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    print fwd_matches
    print loc[0]
    print loc[1]
    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))
    for match in loc[0]:
        expected = match + len(seq)
        if expected > len(template):
            expected -= len(template)
        assert_true(expected in fwd_indices)
    for match in loc[1]:
        expected = match + len(seq)
        if expected > len(template):
            expected -= len(template)
        assert_true(expected in rev_indices)
コード例 #3
0
def test_multiple_priming():
    ''' test multiple binding sites '''

    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))
    template = template.circularize()
    seq = DNA('cgccagggttttcccagtcacgac')
    template = template.linearize()
    template = template + seq + DNA("AGGCGTATGC") + seq
    template = (template + DNA("GGGGGGG") + seq.reverse_complement() +
                DNA("GGAAAG"))
    template = template.circularize()
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)
コード例 #4
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_multiple_priming():
    ''' test multiple binding sites '''

    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))
    template = template.circularize()
    seq = DNA('cgccagggttttcccagtcacgac')
    template = template.linearize()
    template = template + seq + DNA("AGGCGTATGC") + seq
    template = (template + DNA("GGGGGGG") + seq.reverse_complement() +
                DNA("GGAAAG"))
    template = template.circularize()
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)
コード例 #5
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_overhang():
    ''' test forward priming '''
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))
    seq = DNA('cgccagggttttcccagtcacgac')
    overhang = DNA('ggggggg')
    seq2 = overhang + seq
    primer = Primer(seq2, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches

    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_indices) == len(loc[0]))
    assert_true(len(rev_indices) == len(loc[1]))
    # FIXME: Add match length check for all these cases.
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)

    # Test forward priming.
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))
    seq = DNA('ACAAGAGAGATTGGGAAGGAAAGGATCA')
    overhang = DNA('ggggggg')
    seq2 = overhang + seq
    primer = Primer(seq2, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_indices) == len(loc[0]))
    assert_true(len(rev_indices) == len(loc[1]))

    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)
コード例 #6
0
def test_overhang():
    ''' test forward priming '''
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))
    seq = DNA('cgccagggttttcccagtcacgac')
    overhang = DNA('ggggggg')
    seq2 = overhang + seq
    primer = Primer(seq2, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches

    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_indices) == len(loc[0]))
    assert_true(len(rev_indices) == len(loc[1]))
    # FIXME: Add match length check for all these cases.
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)

    # Test forward priming.
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))
    seq = DNA('ACAAGAGAGATTGGGAAGGAAAGGATCA')
    overhang = DNA('ggggggg')
    seq2 = overhang + seq
    primer = Primer(seq2, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_indices) == len(loc[0]))
    assert_true(len(rev_indices) == len(loc[1]))

    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)
コード例 #7
0
ファイル: test_pcr.py プロジェクト: eyu-boltthreads/coral
def test_over_origin():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                              "pMODKan-HO-pACT1GEV.ape"))
    assert_true(template.topology == "circular")
    primer1 = design.primer(template[-200:])
    primer2 = design.primer(template.reverse_complement()[-200:])
    over_origin = reaction.pcr(template, primer1, primer2)
    expected = template[-200:] + template[0:200]
    assert_equal(str(over_origin), str(expected))
コード例 #8
0
def test_construction():
    plasmid_path = os.path.join(os.path.dirname(__file__), 'gibson_test.fasta')
    f1_path = os.path.join(os.path.dirname(__file__), 'fragment_1.fasta')
    f2_path = os.path.join(os.path.dirname(__file__), 'fragment_2.fasta')
    f3_path = os.path.join(os.path.dirname(__file__), 'fragment_3.fasta')
    f3_linear_path = os.path.join(os.path.dirname(__file__),
                                  'fragment_3_linear.fasta')
    plasmid = seqio.read_dna(plasmid_path).circularize()
    f1 = seqio.read_dna(f1_path)
    f2 = seqio.read_dna(f2_path)
    f3 = seqio.read_dna(f3_path)
    f3_linear = seqio.read_dna(f3_linear_path)

    gibsoned_circular = reaction.gibson([f1, f2, f3])
    gibsoned_linear = reaction.gibson([f1, f2, f3_linear], linear=True)
#
    expected_length = len(plasmid)
    gibsoned_circular_length = len(gibsoned_circular)
    gibsoned_linear_length = len(gibsoned_linear)
    assert_equal(gibsoned_circular_length, expected_length)
    assert_equal(gibsoned_linear_length, expected_length)
    assert_equal(gibsoned_circular.topology, 'circular')
    assert_equal(gibsoned_linear.topology, 'linear')
    assert(plasmid.is_rotation(gibsoned_circular))
    try:
        assert_equal(str(plasmid), str(gibsoned_linear))
    except AssertionError:
        assert_equal(str(plasmid), str(gibsoned_linear.flip()))

    # Should fail with circular input
    assert_raises(ValueError, reaction.gibson, [f1.circularize()])
    # Should fail if compatible end can't be found
    assert_raises(Exception, reaction.gibson, [f1, f3[50:-50]], linear=True)
    normal = [f1, f2, f3]
    rotated = [f1, f2, f3.reverse_complement()]
    # Gibson should work regardless of fragment orientation
    assert_true(reaction.gibson(normal).is_rotation(reaction.gibson(rotated)))
    # A redundant fragment shouldn't affect the outcome
    assert_equal(reaction.gibson([f1, f2, f3]),
                 reaction.gibson([f1, f2, f2, f3]))
    # A fragment that can't circularize should raise a ValueError
    assert_raises(ValueError, reaction.gibson, [f1, f2, f3[:-80]])
コード例 #9
0
def test_construction():
    plasmid_path = os.path.join(os.path.dirname(__file__), 'gibson_test.fasta')
    f1_path = os.path.join(os.path.dirname(__file__), 'fragment_1.fasta')
    f2_path = os.path.join(os.path.dirname(__file__), 'fragment_2.fasta')
    f3_path = os.path.join(os.path.dirname(__file__), 'fragment_3.fasta')
    f3_linear_path = os.path.join(os.path.dirname(__file__),
                                  'fragment_3_linear.fasta')
    plasmid = seqio.read_dna(plasmid_path).circularize()
    f1 = seqio.read_dna(f1_path)
    f2 = seqio.read_dna(f2_path)
    f3 = seqio.read_dna(f3_path)
    f3_linear = seqio.read_dna(f3_linear_path)

    gibsoned_circular = reaction.gibson([f1, f2, f3])
    gibsoned_linear = reaction.gibson([f1, f2, f3_linear], linear=True)
    #
    expected_length = len(plasmid)
    gibsoned_circular_length = len(gibsoned_circular)
    gibsoned_linear_length = len(gibsoned_linear)
    assert_equal(gibsoned_circular_length, expected_length)
    assert_equal(gibsoned_linear_length, expected_length)
    assert_equal(gibsoned_circular.topology, 'circular')
    assert_equal(gibsoned_linear.topology, 'linear')
    assert (plasmid.is_rotation(gibsoned_circular))
    try:
        assert_equal(str(plasmid), str(gibsoned_linear))
    except AssertionError:
        assert_equal(str(plasmid), str(gibsoned_linear.flip()))

    # Should fail with circular input
    assert_raises(ValueError, reaction.gibson, [f1.circularize()])
    # Should fail if compatible end can't be found
    assert_raises(Exception, reaction.gibson, [f1, f3[50:-50]], linear=True)
    normal = [f1, f2, f3]
    rotated = [f1, f2, f3.reverse_complement()]
    # Gibson should work regardless of fragment orientation
    assert_true(reaction.gibson(normal).is_rotation(reaction.gibson(rotated)))
    # A redundant fragment shouldn't affect the outcome
    assert_equal(reaction.gibson([f1, f2, f3]),
                 reaction.gibson([f1, f2, f2, f3]))
    # A fragment that can't circularize should raise a ValueError
    assert_raises(ValueError, reaction.gibson, [f1, f2, f3[:-80]])
コード例 #10
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_min_primer_length():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))

    # Test forward priming
    seq = DNA('cgccagggttttcccagtcacgac')
    seq = seq[:15]
    primer = Primer(seq, 50.6)
    assert_raises(analysis._sequence.anneal.PrimerLengthError, analysis.anneal,
                  template, primer, min_len=16)
コード例 #11
0
def test_min_tm():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))

    # Test forward priming
    # Tm should be ~40 C
    seq = DNA('CTTCTATCGAACAA')
    primer = Primer(seq, seq.tm())
    matches = analysis.anneal(template, primer, min_tm=60.0)
    assert_true(len(matches[0]) == 0)
    matches = analysis.anneal(template, primer, min_tm=30.0)
    assert_true(len(matches[0]) > 0)
コード例 #12
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_min_tm():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))

    # Test forward priming
    # Tm should be ~40 C
    seq = DNA('CTTCTATCGAACAA')
    primer = Primer(seq, seq.tm())
    matches = analysis.anneal(template, primer, min_tm=60.0)
    assert_true(len(matches[0]) == 0)
    matches = analysis.anneal(template, primer, min_tm=30.0)
    assert_true(len(matches[0]) > 0)
コード例 #13
0
def test_min_primer_length():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))

    # Test forward priming
    seq = DNA('cgccagggttttcccagtcacgac')
    seq = seq[:15]
    primer = Primer(seq, 50.6)
    assert_raises(analysis._sequence.anneal.PrimerLengthError,
                  analysis.anneal,
                  template,
                  primer,
                  min_len=16)
コード例 #14
0
def test_no_priming():
    ''' test no priming '''

    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))
    seq = DNA('ggaggagggcggcgaggcgagcgacggaggggga')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    loc = template.locate(seq)
    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_matches)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_matches)
コード例 #15
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_no_priming():
    ''' test no priming '''

    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))
    seq = DNA('ggaggagggcggcgaggcgagcgacggaggggga')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    loc = template.locate(seq)
    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_matches)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_matches)
コード例 #16
0
ファイル: test_anneal.py プロジェクト: Guangyou/coral
def test_basic():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(os.path.join(current_path,
                                           "pMODKan-HO-pACT1GEV.ape"))
    # Test forward priming.
    seq = DNA('cgccagggttttcccagtcacgac')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    # fwd_lens = [match[1] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]
    # rev_lens = [match[1] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))

    # Top strand matches
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    # Top strand matches
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)

    # Test reverse priming
    seq = DNA('ACAAGAGAGATTGGGAAGGAAAGGATCA')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_indices) == len(loc[0]))
    assert_true(len(rev_indices) == len(loc[1]))
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)
コード例 #17
0
def test_basic():
    current_path = os.path.dirname(__file__)
    template = seqio.read_dna(
        os.path.join(current_path, "pMODKan-HO-pACT1GEV.ape"))
    # Test forward priming.
    seq = DNA('cgccagggttttcccagtcacgac')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    # fwd_lens = [match[1] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]
    # rev_lens = [match[1] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_matches) == len(loc[0]))
    assert_true(len(rev_matches) == len(loc[1]))

    # Top strand matches
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    # Top strand matches
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)

    # Test reverse priming
    seq = DNA('ACAAGAGAGATTGGGAAGGAAAGGATCA')
    primer = Primer(seq, 50.6)
    matches = analysis.anneal(template, primer)
    fwd_matches, rev_matches = matches
    fwd_indices = [match[0] for match in fwd_matches]
    rev_indices = [match[0] for match in rev_matches]

    loc = template.locate(seq)

    assert_true(len(fwd_indices) == len(loc[0]))
    assert_true(len(rev_indices) == len(loc[1]))
    for match in loc[0]:
        assert_true(match + len(seq) in fwd_indices)
    for match in loc[1]:
        assert_true(match + len(seq) in rev_indices)
コード例 #18
0
 def read_reference(self, path):
     '''Read in sequencing reference sequence.'''
     seq = seqio.read_dna(path)
     return seq
コード例 #19
0
ファイル: test_sequencing.py プロジェクト: cgevans/coral
 def read_reference(self, path):
     '''Read in sequencing reference sequence.'''
     seq = seqio.read_dna(path)
     return seq