示例#1
0
    def test_shift_origin(self):

        pCAPs   = read("./pCAPs.gb")
        self.assertTrue( pCAPs.circular )
        pCAPs_b = shift_origin(pCAPs, 200)
        self.assertEqual( len(pCAPs), len(pCAPs_b) )
        self.assertTrue( pCAPs_b.circular )
        self.assertTrue( eq(pCAPs, pCAPs_b) )
        pCAPs_b_linear = pCAPs_b.tolinear()
        self.assertTrue( eq(pCAPs, pCAPs_b_linear, circular=True) )
        pCAPs_c = pCAPs[200:]+pCAPs[:200]
        self.assertTrue( eq(pCAPs, pCAPs_c, circular=True) )
        with self.assertRaisesRegexp(ValueError, "shift"):
            pCAPs_b = shift_origin(pCAPs, 20000)
示例#2
0
    def test_shift_origin(self):

        pCAPs = read("./pCAPs.gb")
        self.assertTrue(pCAPs.circular)
        pCAPs_b = shift_origin(pCAPs, 200)
        self.assertEqual(len(pCAPs), len(pCAPs_b))
        self.assertTrue(pCAPs_b.circular)
        self.assertTrue(eq(pCAPs, pCAPs_b))
        pCAPs_b_linear = pCAPs_b.tolinear()
        self.assertTrue(eq(pCAPs, pCAPs_b_linear, circular=True))
        pCAPs_c = pCAPs[200:] + pCAPs[:200]
        self.assertTrue(eq(pCAPs, pCAPs_c, circular=True))
        with self.assertRaisesRegexp(ValueError, "shift"):
            pCAPs_b = shift_origin(pCAPs, 20000)
    def test_empty(self):
        """ test YEp24PGK_XK"""

        import os
        import pydna

        cwd = os.getcwd()
        YEp24PGK_XK_correct = pydna.read("YEp24PGK_XK_correct.gb")
        os.chdir("../docs/cookbook/")
        p1 = pydna.read("primer1.txt", ds=False)
        p3 = pydna.read("primer3.txt", ds=False)
        XKS1 = pydna.read("XKS1_orf.txt")
        YEp24PGK = pydna.read("YEp24PGK.txt")

        os.chdir(cwd)

        PCR_prod = pydna.pcr(p1, p3, XKS1)

        from Bio.Restriction import BamHI

        stuffer1, insert, stuffer2 = PCR_prod.cut(BamHI)

        from Bio.Restriction import BglII

        YEp24PGK_BglII = YEp24PGK.cut(BglII).pop()

        YEp24PGK_XK = YEp24PGK_BglII + insert

        YEp24PGK_XK = YEp24PGK_XK.looped()

        YEp24PGK_XK = YEp24PGK_XK.synced("gaattctgaaccagtcctaaaacgagtaaataggaccggcaattc")  # YEp24PGK)

        self.assertTrue(pydna.eq(YEp24PGK_XK, YEp24PGK_XK_correct))
        self.assertEqual(YEp24PGK_XK_correct.seguid(), "HRVpCEKWcFsKhw_W-25ednUfldI")
        self.assertEqual(YEp24PGK_XK.seguid(), "HRVpCEKWcFsKhw_W-25ednUfldI")
示例#4
0
    def test_empty(self):
        ''' test YEp24PGK_XK'''

        import os
        import pydna
        
        cwd = os.getcwd()
        YEp24PGK_XK_correct = pydna.read("YEp24PGK_XK_correct.gb")
        os.chdir("../docs/cookbook/")        
        p1 =   pydna.read("primer1.txt", ds = False)
        p3 =   pydna.read("primer3.txt", ds = False)
        XKS1 = pydna.read("XKS1_orf.txt")
        YEp24PGK = pydna.read("YEp24PGK.txt")
        
        os.chdir(cwd)

        PCR_prod = pydna.pcr(p1, p3, XKS1)

        from Bio.Restriction import BamHI
        
        stuffer1, insert, stuffer2 = PCR_prod.cut(BamHI)

        from Bio.Restriction import BglII

        YEp24PGK_BglII = YEp24PGK.cut(BglII).pop()

        YEp24PGK_XK = YEp24PGK_BglII + insert

        YEp24PGK_XK=YEp24PGK_XK.looped()

        YEp24PGK_XK = YEp24PGK_XK.synced("gaattctgaaccagtcctaaaacgagtaaataggaccggcaattc") #YEp24PGK)
        
        self.assertTrue( pydna.eq(YEp24PGK_XK, YEp24PGK_XK_correct))
        self.assertEqual( YEp24PGK_XK_correct.seguid() ,"HRVpCEKWcFsKhw_W-25ednUfldI" )
        self.assertEqual( YEp24PGK_XK.seguid() ,"HRVpCEKWcFsKhw_W-25ednUfldI" )
示例#5
0
 def cut_and_religate_Dseq(seq_string, enz, top):
     ds = Dseq(seq_string, linear=top)
     frags = ds.cut(enz)
     if not frags:
         return
     a = frags.pop(0)
     for f in frags:
         a+=f
     if not top:
         a=a.looped()
     self.assertTrue( eq(a,ds) )
示例#6
0
 def cut_and_religate_Dseq(seq_string, enz, top):
     ds = Dseq(seq_string, linear=top)
     frags = ds.cut(enz)
     if not frags:
         return
     a = frags.pop(0)
     for f in frags:
         a += f
     if not top:
         a = a.looped()
     self.assertTrue(eq(a, ds))
示例#7
0
    def test_rogerstager(self):

        from Bio.Seq import Seq
        from Bio.Restriction import BsaI

        answ = []
        answ.append(Dseq('aaaaaaaaaaaaggtctca', 'ttttttttccagagttttt'[::-1]))
        answ.append(Dseq('aaaaaaaaaggtctca', 'tttttccagagttttt'[::-1]))

        tests = [Seq("aaaaaaggtctcaaaaaaa"), Seq("aaaaaaggtctcaaaa")]
        for s in tests:
            d = Dseqrecord(s).looped()
            for f in d.cut(BsaI):
                a = answ.pop(0)
                self.assertTrue(f.seq.watson == a.watson)
                self.assertTrue(f.seq.crick == a.crick)
                self.assertTrue(f.seq.ovhg == a.ovhg)
                self.assertTrue(eq(f.seq, a))
示例#8
0
    def test_empty(self):
        ''' test pGUP1'''

        import os

        cwd = os.getcwd()

        os.chdir("../docs/cookbook/")

        import pydna

        GUP1rec1sens = pydna.read("GUP1rec1sens.txt")
        GUP1rec2AS = pydna.read("GUP1rec2AS.txt")
        GUP1_locus = pydna.read("GUP1_locus.gb")
        pGREG505 = pydna.read("pGREG505.gb")

        os.chdir(cwd)

        insert = pydna.pcr(GUP1rec1sens, GUP1rec2AS, GUP1_locus)

        from Bio.Restriction import SalI

        lin_vect, his3 = pGREG505.cut(SalI)

        a = pydna.Assembly([insert, lin_vect], limit=28)

        pGUP1 = a.circular_products[0]

        pGUP1 = pGUP1.synced(pGREG505.seq[:50])

        pGUP1_correct = pydna.read("pGUP1_correct.gb")

        self.assertEqual(len(pGUP1_correct), 9981)
        self.assertEqual(len(pGUP1), 9981)
        self.assertTrue(pydna.eq(pGUP1, pGUP1_correct))
        self.assertEqual(pGUP1_correct.seguid(), "42wIByERn2kSe_Exn405RYwhffU")
        self.assertEqual(pGUP1.seguid(), "42wIByERn2kSe_Exn405RYwhffU")
示例#9
0
from pydna import parse, eq

new_primer = parse("/home/bjorn/Dropbox/wikidata/PrimersToBuy.wiki", ds=False)
primer = parse("/home/bjorn/Dropbox/wikidata/Primers.wiki", ds=False)

primer = primer[::-1]
old_primer = primer[:37 + 18]
primer = primer[37 + 18:]

new_primer_dict = dict((p.id, p) for p in new_primer)
primer_dict = dict((p.id, p) for p in primer)
old_primer_dict = dict((p.id, p) for p in old_primer)

assert str(primer_dict["509_mycGFPr"].seq) == "CTACTTGTACAGCTCGTCCA"
assert primer[0].id == "0_S1"
assert primer[1].id == "1_5CYC1clone"
assert primer[580].id == "580_GXF1_YPK_fwd"

fprimer = parse("/home/bjorn/Dropbox/wikidata/New10.wiki", ds=False)
fprimer = fprimer[::-1]
fold_primer = fprimer[:37 + 18]
fprimer = fprimer[37 + 18:]

print len(primer), len(fprimer)

for i in range(1, len(primer)):
    if not eq(primer[i], fprimer[i]):
        print i
        print primer[i].id, fprimer[i].id
        raw_input()
示例#10
0
    def test_features_change_ori(self):

        s = read('''
                    LOCUS       New_DNA                   13 bp ds-DNA     circular     12-NOV-2013
                    DEFINITION  .
                    ACCESSION
                    VERSION
                    SOURCE      .
                    ORGANISM  .
                    COMMENT
                    COMMENT     ApEinfo:methylated:1
                    FEATURES             Location/Qualifiers
                         misc_feature    join(9..10,12..13,1..1,3..6)
                                         /label=hej
                                         /ApEinfo_fwdcolor=cyan
                                         /ApEinfo_revcolor=green
                                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                                         width 5 offset 0
                    ORIGIN
                            1 gattttaatc acc
                    //''')

        #from pydna_helper import ape

        for i in range(1, len(s)):
            b = s.shifted(i)
            self.assertTrue(
                str(b.features[0].extract(b).seq).lower() == "tcccgtttt")

        s = read('''
                LOCUS       New_DNA                   21 bp ds-DNA     circular     03-APR-2013
                DEFINITION  a
                ACCESSION
                VERSION
                SOURCE      .
                  ORGANISM  .
                COMMENT
                COMMENT     ApEinfo:methylated:1
                FEATURES             Location/Qualifiers
                     misc_feature    join(18..21,1..4)
                                     /label=bb
                                     /ApEinfo_fwdcolor=cyan
                                     /ApEinfo_revcolor=green
                                     /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                                     width 5 offset 0
                     misc_feature    5..17
                                     /label=ins
                                     /ApEinfo_fwdcolor=#e03c2b
                                     /ApEinfo_revcolor=green
                                     /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                                     width 5 offset 0
                ORIGIN
                        1 aaaGGTACCt ttGGATCCggg
                //
            ''')

        self.assertTrue(str(s.features[0].extract(s).seq) == "CGGGAAAG")
        self.assertTrue(str(s.features[1].extract(s).seq) == "GTACCTTTGGATC")

        for i in range(1, len(s)):

            b = s.shifted(i)
            self.assertTrue([
                str(f.extract(b).seq) for f in b.features
                if f.qualifiers["label"][0] == 'ins'
            ][0] == "GTACCTTTGGATC")
            self.assertTrue([
                str(f.extract(b).seq) for f in b.features
                if f.qualifiers["label"][0] == 'bb'
            ][0] == "CGGGAAAG")

        from Bio.Restriction import Acc65I, KpnI, BamHI

        bb1, ins1 = sorted(s.cut(Acc65I, BamHI), key=len, reverse=True)

        for i in range(1, len(s)):
            b = s.shifted(i)

            bb, ins = sorted(b.cut(Acc65I, BamHI), key=len, reverse=True)

            self.assertTrue(eq(bb1, bb))
            self.assertTrue(eq(ins1, ins))

            self.assertTrue(
                bb.features[0].extract(bb).seq.watson == "CGGGAAAG")
            self.assertTrue(bb.features[0].extract(bb).seq.crick == "CTTTCCCG")

            self.assertTrue(
                eq(bb.features[0].extract(bb), s.features[0].extract(s)))

            self.assertTrue(
                ins.features[0].extract(ins).seq.watson == "GTACCTTTG")
            self.assertTrue(
                ins.features[0].extract(ins).seq.crick == "GATCCAAAG")

            self.assertTrue(
                str(ins.features[0].extract(ins).seq) == str(
                    s.features[1].extract(s).seq))
示例#11
0
    def test_Dseqrecord_cutting_adding(self):
        from Bio.Restriction import Bsu36I, BstAPI
        pCAPs = read("./pCAPs.gb")
        a, b = pCAPs.cut(Bsu36I, BstAPI)
        c = (a + b).looped()
        self.assertTrue(eq(c, pCAPs))

        a = (
            Dseqrecord(
                Dseq('AATTCACANGGTACCNGGTACCNGCGGATATC',
                     'GTGTNCCATGGNCCATGGNCGCCTATAG'[::-1], -4)),
            Dseqrecord(
                Dseq('CACANGGTACCNGGTACCNGCGGATATC',
                     'GTGTNCCATGGNCCATGGNCGCCTATAG'[::-1], 0)),
            Dseqrecord(
                Dseq('CACANGGTACCNGGTACCNGCGGATATC',
                     'AATTGTGTNCCATGGNCCATGGNCGCCTATAG'[::-1], 4)),
        )

        from Bio.Restriction import KpnI, Acc65I, NlaIV

        enzymes = [Acc65I, NlaIV, KpnI]

        for enz in enzymes:
            for f in a:
                b, c, d = f.cut(enz)
                e = b + c + d
                assert str(e.seq).lower() == str(f.seq).lower()

        #from pydna import *
        #from pydna_helper import gb, ape
        from Bio.Restriction import KpnI, BamHI, Acc65I, NlaIV, EcoRI, EcoRV

        a = read('''

    LOCUS       New_DNA                   10 bp ds-DNA     linear       02-APR-2013
    DEFINITION
    ACCESSION   New_DNA
    VERSION     New_DNA
    KEYWORDS    .
    SOURCE
      ORGANISM  . .
    COMMENT
    COMMENT     ApEinfo:methylated:1
    FEATURES             Location/Qualifiers
         misc_feature    1..1
                         /label=1
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    2..2
                         /label=2
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    3..3
                         /label=3
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    4..4
                         /label=4
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    5..5
                         /label=5
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    6..6
                         /label=6
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    7..7
                         /label=7
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    8..8
                         /label=8
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    9..9
                         /label=9
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    10..10
                         /label=10
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
    ORIGIN
            1 ttGGTACCgg
    //''')

        b, c = a.cut(Acc65I)

        self.assertEqual([f.qualifiers["label"] for f in b.features],
                         [['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7']])
        self.assertEqual([f.qualifiers["label"] for f in c.features],
                         [['4'], ['5'], ['6'], ['7'], ['8'], ['9'], ['10']])

        a = read('''

    LOCUS       New_DNA                   33 bp ds-DNA     linear       08-NOV-2012
    DEFINITION  .
    ACCESSION
    VERSION
    SOURCE      .
      ORGANISM  .
    COMMENT
    COMMENT     ApEinfo:methylated:1
    FEATURES             Location/Qualifiers
         misc_feature    1..11
                         /label=Acc65I-1
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    12..18
                         /label=Acc65I-2
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    19..33
                         /label=Acc65I-3
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    1..15
                         /label=KpnI-1
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    16..22
                         /label=KpnI-2
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    23..33
                         /label=KpnI-3
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    1..13
                         /label=NlaIV-1
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    14..20
                         /label=NlaIV-2
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
         misc_feature    21..33
                         /label=NlaIV-3
                         /ApEinfo_fwdcolor=cyan
                         /ApEinfo_revcolor=green
                         /ApEinfo_graphicformat=arrow_data {{0 1 2 0 0 -1} {} 0}
                         width 5 offset 0
    ORIGIN
            1 GAATTCacan ggtaccnGGT ACCngcgGAT ATC
    //

        ''')

        self.assertTrue(a.seguid() == "di3hL8t2G4iQQsxlm_CtvnUMBz8")

        self.assertTrue(([x.qualifiers["label"][0] for x in a.features] == [
            'Acc65I-1', 'Acc65I-2', 'Acc65I-3', 'KpnI-1', 'KpnI-2', 'KpnI-3',
            'NlaIV-1', 'NlaIV-2', 'NlaIV-3'
        ]))

        b, c, d = a.cut(Acc65I)

        self.assertTrue(
            [x.qualifiers["label"][0]
             for x in b.features] == ['Acc65I-1', 'KpnI-1', 'NlaIV-1'])
        self.assertTrue(
            [x.qualifiers["label"][0]
             for x in c.features] == ['Acc65I-2', 'KpnI-2', 'NlaIV-2'])
        self.assertTrue(
            [x.qualifiers["label"][0]
             for x in d.features] == ['Acc65I-3', 'KpnI-3', 'NlaIV-3'])
        e = b + c + d
        self.assertTrue(
            sorted([x.qualifiers["label"][0] for x in e.features]) ==
            [x.qualifiers["label"][0] for x in a.features])
        self.assertTrue(str(a.seq) == str(e.seq))

        b, c, d = a.cut(KpnI)
        self.assertTrue(
            [x.qualifiers["label"][0]
             for x in b.features] == ['Acc65I-1', 'KpnI-1', 'NlaIV-1'])
        self.assertTrue(
            [x.qualifiers["label"][0]
             for x in c.features] == ['Acc65I-2', 'KpnI-2', 'NlaIV-2'])
        self.assertTrue(
            [x.qualifiers["label"][0]
             for x in d.features] == ['Acc65I-3', 'KpnI-3', 'NlaIV-3'])
        e = b + c + d
        self.assertTrue(
            sorted([x.qualifiers["label"][0] for x in e.features]) ==
            [x.qualifiers["label"][0] for x in a.features])

        b, c, d = a.cut(NlaIV)
        self.assertTrue([x.qualifiers["label"][0]
                         for x in b.features] == ['Acc65I-1', 'NlaIV-1'])
        self.assertTrue([x.qualifiers["label"][0]
                         for x in c.features] == ['NlaIV-2'])
        self.assertTrue([x.qualifiers["label"][0]
                         for x in d.features] == ['KpnI-3', 'NlaIV-3'])
        e = b + c + d
        self.assertTrue(str(a.seq) == str(e.seq))

        b, c = a.cut(EcoRI)
        e = b + c
        self.assertTrue(str(a.seq) == str(e.seq))

        b, c = a.cut(EcoRV)
        e = b + c
        self.assertTrue(str(a.seq) == str(e.seq))

        b, c, d = a.cut(EcoRI, EcoRV)
        e = b + c + d

        self.assertTrue(str(a.seq) == str(e.seq))

        b, c, d, f = a.cut(Acc65I, EcoRI)
        e = b + c + d + f
        self.assertTrue(str(a.seq) == str(e.seq))

        b, c, d, f = a.cut(EcoRI, Acc65I)
        e = b + c + d + f
        self.assertTrue(str(a.seq) == str(e.seq))
示例#12
0
    def test_Dseq_cutting_adding(self):

        from Bio.Seq import Seq
        from Bio.Restriction import BamHI, EcoRI, PstI, EcoRV, SmaI
        from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA
        from Bio.SeqUtils.CheckSum import seguid
        from pydna import Dseq

        a = Dseq(
            'GGATCCtcatctactatcatcgtagcgtactgatctattctgctgctcatcatcggtactctctataattatatatatatgcgcgtGGATCC',
            'CCTAGGagtagatgatagtagcatcgcatgactagataagacgacgagtagtagccatgagagatattaatatatatatacgcgcaCCTAGG'[::
                                                                                                           -1],
            linear=True,
            ovhg=0)

        b = a.cut(BamHI)[1]

        self.assertEqual(
            b.watson,
            "GATCCtcatctactatcatcgtagcgtactgatctattctgctgctcatcatcggtactctctataattatatatatatgcgcgtG"
        )
        self.assertEqual(
            b.crick,
            "GATCCacgcgcatatatatataattatagagagtaccgatgatgagcagcagaatagatcagtacgctacgatgatagtagatgaG"
        )

        c = Dseq(
            'nCTGCAGtcatctactatcatcgtagcgtactgatctattctgctgctcatcatcggtactctctataattatatatatatgcgcgtGAATTCn',
            'nGACGTCagtagatgatagtagcatcgcatgactagataagacgacgagtagtagccatgagagatattaatatatatatacgcgcaCTTAAGn'[::
                                                                                                             -1],
            linear=True,
            ovhg=0)

        f, d, l = c.cut((EcoRI, PstI))

        self.assertEqual(
            d.watson,
            "GtcatctactatcatcgtagcgtactgatctattctgctgctcatcatcggtactctctataattatatatatatgcgcgtG"
        )
        self.assertEqual(
            d.crick,
            "AATTCacgcgcatatatatataattatagagagtaccgatgatgagcagcagaatagatcagtacgctacgatgatagtagatgaCTGCA"
        )

        e = Dseq(
            "nGAATTCtcatctactatcatcgtagcgtactgatctattctgctgctcatcatcggtactctctataattatatatatatgcgcgtCTGCAGn",
            "nCTTAAGagtagatgatagtagcatcgcatgactagataagacgacgagtagtagccatgagagatattaatatatatatacgcgcaGACGTCn"[::
                                                                                                             -1],
            linear=True,
            ovhg=0)

        f = e.cut((EcoRI, PstI))[1]

        self.assertEqual(
            f.watson,
            "AATTCtcatctactatcatcgtagcgtactgatctattctgctgctcatcatcggtactctctataattatatatatatgcgcgtCTGCA"
        )
        self.assertEqual(
            f.crick,
            "GacgcgcatatatatataattatagagagtaccgatgatgagcagcagaatagatcagtacgctacgatgatagtagatgaG"
        )
        ''' blunt cloning '''

        pUC19 = read("./pUC19.gb")

        self.assertFalse(pUC19.linear)

        self.assertTrue(len(pUC19) == 2686)
        self.assertTrue(len(pUC19.seq.watson) == 2686)
        self.assertTrue(len(pUC19.seq.crick) == 2686)

        self.assertTrue(pUC19.seq.circular == True)
        self.assertTrue(pUC19.seq.linear == False)

        pUC19_SmaI = pUC19.cut(SmaI)
        self.assertTrue(len(pUC19_SmaI) == 1)
        pUC19_SmaI = pUC19_SmaI.pop()

        self.assertTrue(pUC19_SmaI.linear)
        self.assertTrue(len(pUC19_SmaI) == 2686)
        self.assertTrue(pUC19_SmaI.linear)

        pUC19_SmaI_a = pUC19_SmaI.seq + a

        self.assertTrue(pUC19_SmaI_a.linear)
        self.assertFalse(pUC19_SmaI_a.circular)

        pUC19_SmaI_a = pUC19_SmaI_a.looped()
        self.assertTrue(len(pUC19_SmaI_a) == 2778)

        self.assertTrue(pUC19_SmaI_a.circular)
        self.assertFalse(pUC19_SmaI_a.linear)
        self.assertTrue(eq(pUC19_SmaI_a, read("./pUC19-SmaI-a.gb")))
        ''' sticky end cloning '''

        pUC19_BamHI = pUC19.cut(BamHI)

        self.assertTrue(len(pUC19_BamHI) == 1)

        pUC19_BamHI = pUC19_BamHI.pop().seq

        self.assertTrue(
            len(pUC19_BamHI.watson) == len(pUC19_BamHI.crick) == 2686)

        pUC19_BamHI_a = pUC19_BamHI + b

        self.assertTrue(
            len(pUC19_BamHI_a.watson) == len(pUC19_BamHI_a.crick) == 2772)

        self.assertTrue(pUC19_BamHI_a.circular == False)
        self.assertTrue(pUC19_BamHI_a.linear == True)

        pUC19_BamHI_a = pUC19_BamHI_a.looped()

        self.assertTrue(pUC19_BamHI_a.circular == True)
        self.assertTrue(pUC19_BamHI_a.linear == False)

        self.assertTrue(eq(pUC19_BamHI_a, read("./pUC19-BamHI-a.gb")))

        pUC19_BamHI_a_rc = pUC19_BamHI + b.rc()

        pUC19_BamHI_a_rc = pUC19_BamHI_a_rc.looped()

        self.assertTrue(pUC19_BamHI_a.circular == True)
        self.assertTrue(pUC19_BamHI_a.linear == False)
        self.assertTrue(eq(pUC19_BamHI_a_rc, read("./pUC19-BamHI-a-rc.gb")))
        ''' adding (ligating) dsDNA objects '''
        with self.assertRaisesRegexp(TypeError, "circular"):
            pUC19 + a
        with self.assertRaisesRegexp(TypeError, "circular"):
            a + pUC19
        with self.assertRaisesRegexp(TypeError, "compatible"):
            a + b
        with self.assertRaisesRegexp(TypeError, "compatible"):
            b + a
        with self.assertRaisesRegexp(TypeError, "compatible"):
            d + d
        ''' directional cloning '''

        pUC19_EcoRI_PstI = pUC19.cut(EcoRI, PstI).pop(0)

        with self.assertRaisesRegexp(TypeError, "compatible"):
            pUC19_EcoRI_PstI + d

        pUC19_EcoRI_PstI_d = pUC19_EcoRI_PstI + d.rc()

        pUC19_EcoRI_PstI_d = pUC19_EcoRI_PstI_d.looped()

        self.assertTrue(
            eq(pUC19_EcoRI_PstI_d, read("./pUC19-EcoRI_PstI-d-rc.gb")))
        self.assertTrue(
            eq(pUC19_EcoRI_PstI_d.rc(), read("./pUC19-EcoRI_PstI-d-rc.gb")))
示例#13
0
    def test_eq(self):
        ''' test eq'''
        self.assertTrue(eq("AAA", "TTT", linear=True))
        self.assertTrue(eq("AAA", "TTT", linear=False))

        self.assertTrue(eq("aAA", "TtT", linear=True))
        self.assertTrue(eq("AAa", "TtT", linear=False))

        self.assertTrue(eq("ATA", "AAT", circular=True))
        self.assertFalse(eq("ATA", "AAT", circular=False))
        self.assertTrue(eq("AAA", "AAA", linear=True))
        self.assertTrue(eq("AAA", "AAA", linear=False))

        self.assertTrue(eq("ATA", Seq("AAT"), circular=True))
        self.assertFalse(eq("ATA", Seq("AAT"), circular=False))
        self.assertTrue(eq("AAA", Seq("AAA"), linear=True))
        self.assertTrue(eq("AAA", Seq("AAA"), linear=False))

        self.assertTrue(eq("ATA", SeqRecord("AAT"), circular=True))
        self.assertFalse(eq("ATA", SeqRecord("AAT"), circular=False))
        self.assertTrue(eq("AAA", SeqRecord("AAA"), linear=True))
        self.assertTrue(eq("AAA", SeqRecord("AAA"), linear=False))

        self.assertTrue(eq("ATA", Dseqrecord("AAT"), circular=True))
        self.assertFalse(eq("ATA", Dseqrecord("AAT"), circular=False))
        self.assertTrue(eq("AAA", Dseqrecord("AAA"), linear=True))
        self.assertTrue(eq("AAA", Dseqrecord("AAA"), linear=False))

        self.assertTrue(eq(Seq("ATA"), SeqRecord("AAT"), circular=True))
        self.assertFalse(eq(Seq("ATA"), SeqRecord("AAT"), circular=False))
        self.assertTrue(eq(Seq("AAA"), SeqRecord("AAA"), linear=True))
        self.assertTrue(eq(Seq("AAA"), SeqRecord("AAA"), linear=False))

        self.assertTrue(eq(Seq("ATA"), Dseqrecord("AAT"), circular=True))
        self.assertFalse(eq(Seq("ATA"), Dseqrecord("AAT"), circular=False))
        self.assertTrue(eq(Seq("AAA"), Dseqrecord("AAA"), linear=True))
        self.assertTrue(eq(Seq("AAA"), Dseqrecord("AAA"), linear=False))

        self.assertTrue(
            eq(Dseqrecord("AAA", circular=False),
               Dseqrecord("AAA", circular=False)))
        self.assertTrue(
            eq(Dseqrecord("AAA", circular=True),
               Dseqrecord("AAA", circular=True)))
        self.assertFalse(
            eq(Dseqrecord("ATA", circular=False),
               Dseqrecord("AAT", circular=False)))
        self.assertTrue(
            eq(Dseqrecord("ATA", circular=True),
               Dseqrecord("AAT", circular=True)))

        self.assertEqual(True, True)
        self.assertTrue(True)
        self.assertFalse(False)

        with self.assertRaises(TypeError):
            1 + "1"

        with self.assertRaisesRegexp(TypeError, "unsupported"):
            1 + "1"