def test_primer_Design(): ''' test_primer_design''' a=Dseqrecord("atgactgctaacccttccttggtgttgaacaagatcgacgacatttcgttcgaaacttacgatg") b=Dseqrecord("ccaaacccaccaggtaccttatgtaagtacttcaagtcgccagaagacttcttggtcaagttgcc") c=Dseqrecord("tgtactggtgctgaaccttgtatcaagttgggtgttgacgccattgccccaggtggtcgtttcgtt") primer_pairs = assembly_primers([a,b,c]) frags=[] for (f,r),t in zip(primer_pairs,[a,b,c]): frags.append(pcr(f,r,t)) asm=Assembly(frags) assert asm.linear_products[0].seguid() == "1eNv3d_1PqDPP8qJZIVoA45Www8" frags=[] primer_pairs = assembly_primers([a,b,c], circular=True) for (f,r),t in zip(primer_pairs,[a,b,c]): frags.append(pcr(f,r,t)) #print frags asm=Assembly(frags) assert asm.circular_products[0].cseguid() == "V3Mi8zilejgyoH833UbjJOtDMbc"
def test_primer_Design_with_linker(self): ''' test_primer_design''' from pydna import Dseqrecord, Assembly, pcr, assembly_primers b = Dseqrecord("agctactgactattaggggttattctgatcatctgatctactatctgactgtactgatcta") l = Dseqrecord("AAATTTCCCGGG") c = Dseqrecord("tctgatctactatctgactgtactgatctattgacactgtgatcattctagtgtattactc") ((bf,br),(cf,cr)) = assembly_primers((b,l,c)) nb = pcr((bf,br),b) nc = pcr((cf,cr),c) asm1 = Assembly((nb,nc)) self.assertEqual(asm1.linear_products[0].seguid(),(b+l+c).seguid(),'l95igKB8iKAKrvvqE9CYksyNx40') b = Dseqrecord("agctactgactattaggggttattctgatcatctgatctactatctgactgtactgatcta") l = Dseqrecord("AAATTTCCCGGG") c = Dseqrecord("tctgatctactatctgactgtactgatctattgacactgtgatcattctagtgtattactc") ((bf,br),(cf,cr)) = assembly_primers((b,l,c), circular = True) nb = pcr((bf,br),b) nc = pcr((cf,cr),c) asm = Assembly((nb,nc)) self.assertEqual((b+l+c).looped().cseguid(), asm.circular_products[0].cseguid(), 'qMEHxKkTsWIXkbqGA5O35631eMU')
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" )
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")
def test_primer_Design_with_linker(): ''' test_primer_design''' from pydna import Dseqrecord, Assembly, pcr, assembly_primers b = Dseqrecord("agctactgactattaggggttattctgatcatctgatctactatctgactgtactgatcta") l = Dseqrecord("AAATTTCCCGGG") c = Dseqrecord("tctgatctactatctgactgtactgatctattgacactgtgatcattctagtgtattactc") ((bf,br),(cf,cr)) = assembly_primers((b,l,c)) nb = pcr((bf,br),b) nc = pcr((cf,cr),c) asm1 = Assembly((nb,nc)) assert asm1.linear_products[0].seguid(),(b+l+c).seguid() == 'l95igKB8iKAKrvvqE9CYksyNx40' b = Dseqrecord("agctactgactattaggggttattctgatcatctgatctactatctgactgtactgatcta") l = Dseqrecord("AAATTTCCCGGG") c = Dseqrecord("tctgatctactatctgactgtactgatctattgacactgtgatcattctagtgtattactc") ((bf,br),(cf,cr)) = assembly_primers((b,l,c), circular = True) nb = pcr((bf,br),b) nc = pcr((cf,cr),c) asm = Assembly((nb,nc)) #print (b+l+c).looped().seq assert (b+l+c).looped().cseguid() == asm.circular_products[0].cseguid() #print (b+l+c).looped().cseguid() == 'jdHXfQI5k4Sk2ESiZYfKv4oP2FI' assert (b+l+c).looped().cseguid() == 'jdHXfQI5k4Sk2ESiZYfKv4oP2FI'
def test_cut_feat(self): puc19 = read('PUC19_MarkBudde.gb') pf, pr = cloning_primers(puc19) pcrProd = pcr(pf, pr, puc19) self.assertEqual(23, len(pcrProd.features)) #print len(pcrProd.cut(EcoRI)[1].features) self.assertEqual(17, len(pcrProd.cut(EcoRI)[1].features)) def amplicon_to_dseqrecord(a): d = Dseqrecord(a.seq) d.features = a.features return d pcrProdDseqrecord = amplicon_to_dseqrecord(pcrProd) self.assertEqual(17, len(pcrProdDseqrecord.cut(EcoRI)[1].features))
def test_circ_pcr(self): ''' test circ pcr''' s = parse(''' >MCT4_flaghis_rv gccgcaagcttgtcgtcatcgtctttgtagtcCATggccaggagggttggttccgcc >MCT4_flaghis_fw ccaccaccaccaccaccaccaccaccaccacggaggggccgtggtggacgagggcc''', ds=False) t = parse(''' >hej circular TCAGGTGAGGCGGAACCAACCCTCCTGGCCATGggaggggccgtggtggacgagggccccacaggcg ''') p = pcr(s,t) self.assertTrue( p.seguid() == 'wYEpbWxO8tfgA_AL67wqGzYmc5k')
def test_circ_pcr(self): ''' test circ pcr''' s = parse(''' >MCT4_flaghis_rv gccgcaagcttgtcgtcatcgtctttgtagtcCATggccaggagggttggttccgcc >MCT4_flaghis_fw ccaccaccaccaccaccaccaccaccaccacggaggggccgtggtggacgagggcc''', ds=False) t = parse(''' >hej circular TCAGGTGAGGCGGAACCAACCCTCCTGGCCATGggaggggccgtggtggacgagggccccacaggcg ''') p = pcr(s, t) self.assertTrue(p.seguid() == 'wYEpbWxO8tfgA_AL67wqGzYmc5k')
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")
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")
def test_pcr(self): ''' test pcr''' raw = [] raw.append(( '7JOV1MJBZJp2Smja/7KFGhS2SWY', parse(''' >524_pFA6aF (29-mer) cacatacgatttaggtgacactatagaac >523_AgTEF1tpR (21-mer) ggttgtttatgttcggatgtg '''), parse("./pAG25.gb"), )) raw.append(( '7pPxy/bQvs4+7CaOgiywQVzUFDc', parse(''' >lowgc_f TTTCACTAGTTACTTGTAGTCGacgtgccatctgtgcagacaaacgcatcaggatat >lowgc_r AAGTTGGAAATCTAGCTTTTCTTgacgtcagcggccgcattgcaca '''), parse("./pCAPs.gb"), )) raw.append(( '7JOV1MJBZJp2Smja/7KFGhS2SWY', parse(''' >524_pFA6aF (29-mer) cacatacgatttaggtgacactatagaac >523_AgTEF1tpR (21-mer) ggttgtttatgttcggatgtg '''), parse("../tests/pAG25.gb"), )) raw.append(( 'yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer1 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS sequence_50_bp 46 bp DNA circular UNK 08-FEB-2013 DEFINITION sequence_50_bp circular ACCESSION sequence_50_bp VERSION sequence_50_bp KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt // '''), )) raw.append(( 'yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer2 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS template 46 bp DNA circular UNK 15-OCT-2012 DEFINITION template circular ACCESSION template VERSION template KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt // '''), )) raw.append(( 'yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer3 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS template 46 bp DNA circular UNK 08-FEB-2013 DEFINITION template circular ACCESSION template VERSION template KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 tccaagatag agtcagtaac cacagctact acacacgtac tgactg // '''), )) raw.append(( 'yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer4 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS template 46 bp DNA circular UNK 15-OCT-2012 DEFINITION template circular ACCESSION template VERSION template KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 gtccaagata gagtcagtaa ccacagctac tacacacgta ctgact // '''), )) raw.append(( '60meNXeGKO7ahZwcIl5yXHFC3Yg', parse(''' >fw1 cacatacgatttaggtgacactatagaac >rv ggttgtttatgttcggatgtg LOCUS tm 50 bp DNA circular UNK 15-OCT-2012 DEFINITION tm circular ACCESSION tm VERSION tm KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 cacatccgaa cataaacaac ccacatacga tttaggtgac actatagaac // '''), )) raw.append(( '60meNXeGKO7ahZwcIl5yXHFC3Yg', parse(''' >fw2 cacatacgatttaggtgacactatagaac >rv ggttgtttatgttcggatgtg LOCUS tm 50 bp DNA circular UNK 15-OCT-2012 DEFINITION tm circular ACCESSION tm VERSION tm KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 acatccgaac ataaacaacc cacatacgat ttaggtgaca ctatagaacc // '''), )) raw.append(( '60meNXeGKO7ahZwcIl5yXHFC3Yg', parse(''' >fw3 cacatacgatttaggtgacactatagaac >rv ggttgtttatgttcggatgtg LOCUS tm 50 bp DNA circular UNK 15-OCT-2012 DEFINITION tm circular ACCESSION tm VERSION tm KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 ccacatccga acataaacaa cccacatacg atttaggtga cactatagaa // '''), )) raw.append(( 'y6ohCJ4O+8Is012DItz4F4saxNo', parse(''' >f_Eric_Ma ARATGAGTCTTCTRACCGAGGTCG >r_Eric_Ma TGAAAAGACATCYTCAAGYYTCTG >templ AGCAAAAGCAGGTAGATATTGAAAAATGAGTCTTCTAACCGAGGTCGAAACGTACGTTCTCTCTATCGTCCCGTCAGGCCCCCTCAAAGCCGAGATCGCGCAGAGACTTGAAGATGTCTCTGCAGGGAAGAACACTGATCTCGAGGCTCTCATGGAATGGCTAAAGACAAGACCAATCCTGTCACCTCTGACTAAGGGGATTTTAGGGTTTGTGTTCACGCTCACCGTGCCCAGTGAGCGAGGACTGCAGCGTAGACGCTTTGTCCAGAATGCCTTAAATGGGAATGGAGACCCAAACAACATGGACAGGGCAGTCAAACTATACAGGAAGCTGAAAAGAGAGATAACATTCCATGGGGCTAAAGAGGTTGCACTCAGCTATTCAACCGGTGCACTTGCCAGTTGCATGGGTCTCATATACAACAGGATGGGAACGGTAACCACAGAAGTAGCTTTTGGCCTGGTGTGTGCCACTTGTGAGCAGATTGCTGACTCACAGCATCGATCTCACAGACAGATGGTGACTACCACCAACCCACTAATCAGGCATGAAAACAGAATGGTGCTGGCCAGCACTACAGCTAAGGCTATGGAGCAGATGGCTGGATCGAGTGAACAGGCAGCGGAAGCCATGGAGGTTGCTAGTCAGGCTAGGCAGATGGTGCAGGCAATGAGGACAATTGGGACTCACCCTAGCTCCAGTGCCGGTCTGAAAGATGATCTTCTTGAAAATTTGCAGGCCTACCAGAAGCGGATGGGAGTGCAAATGCAGCGATTCAAGTGATCCTCTCGTTATTGCCGCAAGTATCATTGGGATCTTGCACTTGATATTGTGGATTCTTGATCGTCCTTTCTTCAAATGTATTTATCGTCGCCTTAAATACGGTTTGAAAAGAGGGCCTTCTACGGAAGGAGTGCCTGAGTCTATGAGGGAAGAGTATCGGCAGGAACAGCAGAGTGCTGTGGATGTTGACGATGGTCATTTTGTCAACATAGAGCTGGAGTAAAAAACTACCTTGTTTCTACT '''), )) for key, tst in enumerate(raw): print key print tst[1][0].name print "pcr test", key print self.assertEqual(tst[0], seguid(pcr(tst[1:]).seq))
raw_input("Press any key and wait for the script to finish!") # Establish the two primers. These sequences can be found in (1) GUP1rec1sens = SeqRecord( Seq("gaattcgatatcaagcttatcgataccgatgtcgctgatcagcatcctgtctcc")) GUP1rec2AS = SeqRecord( Seq("gacataactaattacatgactcgaggtcgactcagcattttaggtaaattccg")) # Read the GUP1 locus sequence into a Dseqrecord object # This sequence was taken from the Saccharomyces genome Database: # http://www.yeastgenome.org/cgi-bin/getSeq?query=YGL084C&flankl=1000&flankr=1000&format=fasta GUP1 = read("GUP1_locus.gb") # The insert is formed by PCR using the two primers and the template sequence insert = pcr(GUP1rec1sens, GUP1rec2AS, GUP1) # The sequence for the plasmid is read into a Dseqrecord object called pGREG505 # this sequence was found at # http://www.euroscarf.de/plasmid_details.php?accno=P30350 # This sequence is circular, this information is parsed from the Genbank file. pGREG505 = read("pGREG505.gb") # Import the SalI restriction enzyme from Biopython from Bio.Restriction import SalI # Cut the circular pGREG505 plasmid with SalI # this enzyme cuts twice, so two fragments are formed linear_vector, his3 = pGREG505.cut(SalI) # Circular recombination products are formed
for insertname, pf, pr, status in (x.split() for x in tps.split("\n")): print "in:", letter, insertname, pf, pr, fp = lp.primer[int(pf)] rp = lp.primer[int(pr)] gbref = sg.gene[insertname.upper()].promoter().description gblink = sg.gene[insertname.upper()].cds().id template = pydna.Dseqrecord(sg.gene[insertname.upper()].promoter()) templatesize = len(template) insertseguid = template.seguid() finalcseguid = (pYPKa.linearize(enz)+pydna.pcr(fp, rp, template)).looped().cseguid() #import sys;sys.exit() r = t.format( tp = insertname, enz=repr(enz), gbref = gbref, gblink =gblink, templatesize = templatesize, insertseguid = insertseguid, finalcseguid = finalcseguid, fpn=fp.name, fps=fp.seq, rpn=rp.name, rps=rp.seq)
def __init__(self, enzyme, data): fp_tail = "ttaaat" rp_tail = "taattaa" if enzyme == ZraI: fp = p577 rp = p342 desc_re = re.compile("pYPKa_Z_([^\d\W]\w{2,15})tp") self.letter = "Z" elif enzyme == AjiI: fp = p468 rp = p342 fp_tail = "aa" rp_tail = "" desc_re = re.compile("pYPKa_A_([^\d\W]\w{2,15})") self.letter = "A" elif enzyme == EcoRV: fp = p568 rp = p342 desc_re = re.compile("pYPKa_E_([^\d\W]\w{2,15})tp") self.letter = "E" else: raise Exception(u"Enzyme has to be ZraI, Ajii or EcoRV, but got {}".format(enzyme)) self.enzyme = enzyme self.insert_length = cloned(pYPKa, enzyme, data) if self.insert_length: m = desc_re.search(data.description) if not m: raise Exception(u"{} is a pYPKa_{} sequence but was not correctly named.".format(data.description, self.letter)) self.insert_description = m.group(1) self.name = m.group(0) self.code = "{} = read('{}.txt')".format({ "Z":"first", "A":"middle", "E":"last"}[self.letter], self.name) self.files = { "{}.txt".format(self.name) : data.format("gb").encode("utf-8"), "{}_plan.rst".format(self.name) : u"This vector was given!"} self.rec = data self.flag = True elif data.linear: self.insert_description = data.name # .id .description f,r = pydna.cloning_primers(data, minlength=pYPKa_clone.minlength, maxlength=pYPKa_clone.maxlength, fp_tail=fp_tail, rp_tail=rp_tail) self.insert = pydna.pcr(f, r, data) self.insert_length = len(self.insert) self.insert.description+= "_prd" self.name = u"pYPKa_{}_{}{}".format(self.letter, data.name.split("tp")[0], {ZraI : "tp", AjiI : "", EcoRV: "tp" }[enzyme]) code = pYPKa_clone.codetempl.format( enz = self.enzyme, tp = data.name, f = f.format("fasta"), r = r.format("fasta"), vn = self.name) self.rec = (pYPKa.linearize(self.enzyme) + self.insert).looped().synced("tcgcgcgtttcggtgatgacggtgaaaacctctg") self.rec_rv = (pYPKa.linearize(self.enzyme) + self.insert.rc()).looped().synced("tcgcgcgtttcggtgatgacggtgaaaacctctg") self.rec.id = self.name[:15] self.rec.description = self.name plan = pYPKa_clone.plantempl.format( template = u"{}_template".format(data.name), rec = self.name, fwd = self.insert.forward_primer.name, rev = self.insert.reverse_primer.name, figure = add_space(self.insert.figure()), program = add_space(self.insert.program()), pcr_product =self.insert_description, length = len(self.insert), enz=enzyme, name = self.name, line = "="*len(self.name), fp = fp.name, rp = rp.name, f = f.name, correct_products = ", ".join(str(f) for f in [len(p) for p in pydna.Anneal((fp,rp,f), self.rec).products]), reversed_products = ", ".join(str(f) for f in [len(p) for p in pydna.Anneal((fp,rp,f), self.rec_rv).products]), clone_empty = ", ".join(str(f) for f in [len(p) for p in pydna.Anneal((fp,rp,f), pYPKa).products])) self.files = { "{}_template.txt".format(data.name) : data.format("gb").decode("utf-8"), "{}.txt".format(self.insert_description) : self.insert.format("gb").decode("utf-8"), "{}.txt".format(self.name) : self.rec.format("gb").decode("utf-8"), "{}.py".format(self.name) : code, "{}_plan.rst".format(self.name) : plan} self.code = "from {0} import {0} as {1}".format(self.name, {ZraI : "first", AjiI : "middle", EcoRV: "last" }[enzyme]) self.flag = False else: raise Exception("{} has to be a linear DNA fragment or a pYPKa_{} clone!".format(data.description, self.letter))
def right_product(self): return pydna.pcr(p775, p578, self.seq)
def assembly_product(self): return pydna.pcr(p775, p778, self.seq)
def left_product(self): return pydna.pcr(p577, p778, self.seq)
def __init__(self, *args): self.pYPKa_ZraI_tp1 = None self.pYPKa_AjiI_gene = None self.pYPKa_EcoRV_tp2 = None if len(args)==1: self.seq = args[0] m = pYPK0_tp_gene_tp.desc_re.search(self.seq.description) if not m: raise Exception( "{} is a pYPK0 tp-gene_tp sequence but was not correctly named.".format(last.description)) self.tp1_description = m.group(1) self.gene_description = m.group(2) self.tp2_description = m.group(3) self.pYPKa_clones = [] self.seq.description = self.seq.description.replace(" ","_") self.files = { "{}.txt".format(self.seq.description) : self.seq.format("gb"), "{}_plan.rst".format(self.seq.description) : u"This vector was given!"} self.code = "{i} = read('{f}')".format(f= "{}.txt".format(self.seq.description), i= "{}") elif len(args)==3: self.pYPKa_clones = [pYPKa_clone(ZraI, args[0]), pYPKa_clone(AjiI, args[1]), pYPKa_clone(EcoRV,args[2])] first = pydna.pcr( p577, p567, self.pYPKa_clones[0].rec) middle = pydna.pcr( p468, p467, self.pYPKa_clones[1].rec) last = pydna.pcr( p568, p578, self.pYPKa_clones[2].rec) self.assembly = pydna.Assembly([pYPK0_tp_gene_tp.pYPKpw_lin, first, middle, last], limit=31) self.seq = self.assembly.circular_products[0] self.tp1_description = self.pYPKa_clones[0].insert_description self.gene_description = self.pYPKa_clones[1].insert_description self.tp2_description = self.pYPKa_clones[2].insert_description self.seq.name = "pYPK0_tp_gene_tp" self.seq.id = "-" #self.seq.annotations['source'] = "123" # SOURCE #self.seq.annotations['organism'] = "123" # ORGANISM #self.seq.annotations['comment'] = "123" # COMMENT self.seq.description = "pYPK0_{}tp_{}_{}tp".format(self.pYPKa_clones[0].insert_description.split("tp")[0], self.pYPKa_clones[1].insert_description, self.pYPKa_clones[2].insert_description.split("tp")[0]) tp_gene_size = [len(p) for p in pydna.Anneal((p577,p467), self.seq).products] gene_tp_size = [len(p) for p in pydna.Anneal((p468,p578), self.seq).products] plan = pYPK0_tp_gene_tp.plantempl.format( name = self.seq.description, tp1 = first.name, gene = middle.name, tp2 = last.name, figure = add_space(self.seq.small_fig()), pcr1=add_space(first.figure()), pcr2=add_space(middle.figure()), pcr3=add_space(last.figure()), prg1=add_space(first.program()), prg2=add_space(middle.program()), prg3=add_space(last.program()), tp1_name = self.pYPKa_clones[0].name+"_pcr_prd", gene_name = self.pYPKa_clones[1].name+"_pcr_prd", tp2_name = self.pYPKa_clones[2].name+"_pcr_prd", tmp1 = self.pYPKa_clones[0].name, tmp2 = self.pYPKa_clones[1].name, tmp3 = self.pYPKa_clones[2].name, line = "="*len(self.seq.description), p1 = first.forward_primer.name, p2 = first.reverse_primer.name, p3 = middle.forward_primer.name, p4 = middle.reverse_primer.name, p5 = last.forward_primer.name, p6 = last.reverse_primer.name, correct_first_tp_gene_prd = ", ".join(str(s) for s in tp_gene_size), missing_first_tp_prd = ", ".join(str(s-self.pYPKa_clones[0].insert_length) for s in tp_gene_size), missing_gene_prd1 = ", ".join(str(s-self.pYPKa_clones[1].insert_length) for s in tp_gene_size), empty_prd1 = ", ".join(str(s-self.pYPKa_clones[0].insert_length-self.pYPKa_clones[1].insert_length ) for s in tp_gene_size), correct_gene_tp_prd = ", ".join(str(s) for s in gene_tp_size), missing_gene_prd2 = ", ".join(str(s-self.pYPKa_clones[1].insert_length) for s in gene_tp_size), missing_last_tp_prd = ", ".join(str(s-self.pYPKa_clones[2].insert_length) for s in gene_tp_size), empty_prd2 = ", ".join(str(s-self.pYPKa_clones[1].insert_length-self.pYPKa_clones[2].insert_length) for s in gene_tp_size),) code = [ self.pYPKa_clones[0].code, self.pYPKa_clones[1].code, self.pYPKa_clones[2].code] code = pYPK0_tp_gene_tp.codetempl.format(code = "\n".join(code), vn = self.seq.description) self.files = {self.pYPKa_clones[0].name+"_pcr_prd.txt" : first.format("gb").decode("utf-8"), self.pYPKa_clones[1].name+"_pcr_prd.txt" : middle.format("gb").decode("utf-8"), self.pYPKa_clones[2].name+"_pcr_prd.txt" : last.format("gb").decode("utf-8"), "{}.py".format(self.seq.description) : code, "{}.txt".format(self.seq.description) : self.seq.synced("tcgcgcgtttcggtgatgacggtgaaaacctctg").format("gb").decode("utf-8"), "{}_plan.rst".format(self.seq.description) : plan} self.code = "from {i} import {i} as {c}".format(i=self.seq.description, c="{}") else: raise Exception("Either one or three arguments!")
print info raw_input("Press any key and wait for the script to finish!") # Establish the two primers. These sequences can be found in (1) GUP1rec1sens = SeqRecord(Seq("gaattcgatatcaagcttatcgataccgatgtcgctgatcagcatcctgtctcc")) GUP1rec2AS = SeqRecord(Seq("gacataactaattacatgactcgaggtcgactcagcattttaggtaaattccg")) # Read the GUP1 locus sequence into a Dseqrecord object # This sequence was taken from the Saccharomyces genome Database: # http://www.yeastgenome.org/cgi-bin/getSeq?query=YGL084C&flankl=1000&flankr=1000&format=fasta GUP1 = read("GUP1_locus.gb") # The insert is formed by PCR using the two primers and the template sequence insert = pcr(GUP1rec1sens, GUP1rec2AS, GUP1) # The sequence for the plasmid is read into a Dseqrecord object called pGREG505 # this sequence was found at # http://www.euroscarf.de/plasmid_details.php?accno=P30350 # This sequence is circular, this information is parsed from the Genbank file. pGREG505 = read("pGREG505.gb") # Import the SalI restriction enzyme from Biopython from Bio.Restriction import SalI # Cut the circular pGREG505 plasmid with SalI # this enzyme cuts twice, so two fragments are formed linear_vector, his3 = pGREG505.cut(SalI) # Circular recombination products are formed
def test_pcr(self): ''' test pcr''' raw=[] raw.append( ('7JOV1MJBZJp2Smja/7KFGhS2SWY', parse(''' >524_pFA6aF (29-mer) cacatacgatttaggtgacactatagaac >523_AgTEF1tpR (21-mer) ggttgtttatgttcggatgtg '''), parse("./pAG25.gb"),) ) raw.append( ('7pPxy/bQvs4+7CaOgiywQVzUFDc', parse(''' >lowgc_f TTTCACTAGTTACTTGTAGTCGacgtgccatctgtgcagacaaacgcatcaggatat >lowgc_r AAGTTGGAAATCTAGCTTTTCTTgacgtcagcggccgcattgcaca '''), parse("./pCAPs.gb"),) ) raw.append( ('7JOV1MJBZJp2Smja/7KFGhS2SWY', parse(''' >524_pFA6aF (29-mer) cacatacgatttaggtgacactatagaac >523_AgTEF1tpR (21-mer) ggttgtttatgttcggatgtg '''), parse("../tests/pAG25.gb"), )) raw.append( ('yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer1 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS sequence_50_bp 46 bp DNA circular UNK 08-FEB-2013 DEFINITION sequence_50_bp circular ACCESSION sequence_50_bp VERSION sequence_50_bp KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt // '''),)) raw.append( ('yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer2 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS template 46 bp DNA circular UNK 15-OCT-2012 DEFINITION template circular ACCESSION template VERSION template KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 ccaagataga gtcagtaacc acagctacta cacacgtact gactgt // '''),)) raw.append( ('yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer3 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS template 46 bp DNA circular UNK 08-FEB-2013 DEFINITION template circular ACCESSION template VERSION template KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 tccaagatag agtcagtaac cacagctact acacacgtac tgactg // '''),)) raw.append( ('yshvYTXr9iXCnh3YytWQRDBNQzI', parse(''' >ForwardPrimer4 gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg LOCUS template 46 bp DNA circular UNK 15-OCT-2012 DEFINITION template circular ACCESSION template VERSION template KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 gtccaagata gagtcagtaa ccacagctac tacacacgta ctgact // '''),)) raw.append( ('60meNXeGKO7ahZwcIl5yXHFC3Yg', parse(''' >fw1 cacatacgatttaggtgacactatagaac >rv ggttgtttatgttcggatgtg LOCUS tm 50 bp DNA circular UNK 15-OCT-2012 DEFINITION tm circular ACCESSION tm VERSION tm KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 cacatccgaa cataaacaac ccacatacga tttaggtgac actatagaac // '''),) ) raw.append( ('60meNXeGKO7ahZwcIl5yXHFC3Yg', parse(''' >fw2 cacatacgatttaggtgacactatagaac >rv ggttgtttatgttcggatgtg LOCUS tm 50 bp DNA circular UNK 15-OCT-2012 DEFINITION tm circular ACCESSION tm VERSION tm KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 acatccgaac ataaacaacc cacatacgat ttaggtgaca ctatagaacc // '''),) ) raw.append( ('60meNXeGKO7ahZwcIl5yXHFC3Yg', parse(''' >fw3 cacatacgatttaggtgacactatagaac >rv ggttgtttatgttcggatgtg LOCUS tm 50 bp DNA circular UNK 15-OCT-2012 DEFINITION tm circular ACCESSION tm VERSION tm KEYWORDS . SOURCE . ORGANISM . . FEATURES Location/Qualifiers ORIGIN 1 ccacatccga acataaacaa cccacatacg atttaggtga cactatagaa // '''),) ) raw.append( ('y6ohCJ4O+8Is012DItz4F4saxNo', parse(''' >f_Eric_Ma ARATGAGTCTTCTRACCGAGGTCG >r_Eric_Ma TGAAAAGACATCYTCAAGYYTCTG >templ AGCAAAAGCAGGTAGATATTGAAAAATGAGTCTTCTAACCGAGGTCGAAACGTACGTTCTCTCTATCGTCCCGTCAGGCCCCCTCAAAGCCGAGATCGCGCAGAGACTTGAAGATGTCTCTGCAGGGAAGAACACTGATCTCGAGGCTCTCATGGAATGGCTAAAGACAAGACCAATCCTGTCACCTCTGACTAAGGGGATTTTAGGGTTTGTGTTCACGCTCACCGTGCCCAGTGAGCGAGGACTGCAGCGTAGACGCTTTGTCCAGAATGCCTTAAATGGGAATGGAGACCCAAACAACATGGACAGGGCAGTCAAACTATACAGGAAGCTGAAAAGAGAGATAACATTCCATGGGGCTAAAGAGGTTGCACTCAGCTATTCAACCGGTGCACTTGCCAGTTGCATGGGTCTCATATACAACAGGATGGGAACGGTAACCACAGAAGTAGCTTTTGGCCTGGTGTGTGCCACTTGTGAGCAGATTGCTGACTCACAGCATCGATCTCACAGACAGATGGTGACTACCACCAACCCACTAATCAGGCATGAAAACAGAATGGTGCTGGCCAGCACTACAGCTAAGGCTATGGAGCAGATGGCTGGATCGAGTGAACAGGCAGCGGAAGCCATGGAGGTTGCTAGTCAGGCTAGGCAGATGGTGCAGGCAATGAGGACAATTGGGACTCACCCTAGCTCCAGTGCCGGTCTGAAAGATGATCTTCTTGAAAATTTGCAGGCCTACCAGAAGCGGATGGGAGTGCAAATGCAGCGATTCAAGTGATCCTCTCGTTATTGCCGCAAGTATCATTGGGATCTTGCACTTGATATTGTGGATTCTTGATCGTCCTTTCTTCAAATGTATTTATCGTCGCCTTAAATACGGTTTGAAAAGAGGGCCTTCTACGGAAGGAGTGCCTGAGTCTATGAGGGAAGAGTATCGGCAGGAACAGCAGAGTGCTGTGGATGTTGACGATGGTCATTTTGTCAACATAGAGCTGGAGTAAAAAACTACCTTGTTTCTACT '''),) ) for key, tst in enumerate(raw): print key print tst[1][0].name print "pcr test", key print self.assertEqual(tst[0], seguid(pcr(tst[1:]).seq))
####################################################### gb = pydna.Genbank("*****@*****.**") # Tell Genbank who you are! gene = gb.nucleotide("X06997") # Kluyveromyces lactis LAC12 gene for lactose permease. ####################################################### genome = pydna.read('FSC237.fasta') #genome = fasta_seq('FSC237.fasta') primer_f,primer_r = pydna.parse(''' >B4_400_1-F AGCAGTGCCTGTTGTACC >B4_400_1-R AGTTTCTCAACATGGAAT ''', ds=False) pcr_prod = pydna.pcr(primer_f,primer_r, genome) #stssearch -seqall genome.fasta -infile primers.txt -stdout --auto primersearch -seqall genome.fasta -infile primers.txt -mismatchpercent 1 -stdout --auto -mismatchpercent 10 primersearch -seqall ../../rawdata/FSC770.1.fna -infile primers.txt -mismatchpercent 1 -stdout --auto -mismatchpercent 20 -scircular1
else: xks1_gene = read("Z72979.gb") print "A local copy of Genbank record Z72979 is used" YEp24PGK = read("KC562906.gb") print "A local copy of Genbank record KC562906 is used\n" raw_input("press return!\n") primers=''' >primer1 GCGGATCCTCTAGAATGGTTTGTTCAGTAATTCAG >primer3 AGATCTGGATCCTTAGATGAGAGTCTTTTCCAG ''' primer1, primer2 = parse(primers, ds=False) xks1_pcr_product = pcr(primer1, primer2, xks1_gene) YEp24PGK_bgl = YEp24PGK.cut(BglII).pop() stuffer1, xks1_bam, stuffer2 = xks1_pcr_product.cut(BamHI) YEp24PGK_XK = (YEp24PGK_bgl+xks1_bam.rc()).looped() YEp24PGK_XK = YEp24PGK_XK.synced(YEp24PGK) print "The sequence of YEp24PGK_XK was generated" print "Seguid of YEp24PGK_XK is correct", YEp24PGK_XK.seguid() == "HRVpCEKWcFsKhw/W+25ednUfldI" YEp24PGK_XK.write("YEp24PGK_XK.gb") print '''
else: xks1_gene = read("Z72979.gb") print "A local copy of Genbank record Z72979 is used" YEp24PGK = read("KC562906.gb") print "A local copy of Genbank record KC562906 is used\n" raw_input("press return!\n") primers = ''' >primer1 GCGGATCCTCTAGAATGGTTTGTTCAGTAATTCAG >primer3 AGATCTGGATCCTTAGATGAGAGTCTTTTCCAG ''' primer1, primer2 = parse(primers, ds=False) xks1_pcr_product = pcr(primer1, primer2, xks1_gene) YEp24PGK_bgl = YEp24PGK.cut(BglII).pop() stuffer1, xks1_bam, stuffer2 = xks1_pcr_product.cut(BamHI) YEp24PGK_XK = (YEp24PGK_bgl + xks1_bam.rc()).looped() YEp24PGK_XK = YEp24PGK_XK.synced(YEp24PGK) print "The sequence of YEp24PGK_XK was generated" print "Seguid of YEp24PGK_XK is correct", YEp24PGK_XK.seguid( ) == "HRVpCEKWcFsKhw/W+25ednUfldI" YEp24PGK_XK.write("YEp24PGK_XK.gb")
# p2 = pydna.read(">p2\ngtgctatcagatgatacagtcg", ds = False) # ann = pydna.Anneal((p1, p2), template) import pydna a = pydna.Dseqrecord("atgactgctaacccttccttggtgttgaacaagatcgacgacatttcgttcgaaacttacgatg") b = pydna.Dseqrecord( "ccaaacccaccaggtaccttatgtaagtacttcaagtcgccagaagacttcttggtcaagttgcc" ) c = pydna.Dseqrecord( "tgtactggtgctgaaccttgtatcaagttgggtgttgacgccattgccccaggtggtcgtttcgtt" ) primer_pairs = pydna.assembly_primers([a, b, c], circular=True) p = [] for t, (f, r) in zip([a, b, c], primer_pairs): p.append(pydna.pcr(f, r, t)) obj = pydna.Assembly(p) # print(assemblyobj) # @memorize("function") # def times_two(n): # return n*2 # # @memorize("method") # class Doubler(object): # def __init__(self, n): # self.n=n # self.key=str(n) # def result(self): # return self.n*2 #
>621_ScTPI1tpr_PacI (35-mer) taattaaTTTTAGTTTATGTATGTGTTTTTTGTAG''', ds=False) #PDC1tp_ScTKL1_RPS19btp # RPS19btp_ScRPE1_RPS19atp # RPS19atp_ScRKI1tp_TPI1tp # TPI1tp_CiGXF1_ENO2tp from pYPK0_PDC1tp_ScTKL1_RPS19btp import pYPK0_PDC1tp_ScTKL1_RPS19btp as cas1 from pYPK0_RPS19btp_ScRPE1_RPS19atp import pYPK0_RPS19btp_ScRPE1_RPS19atp as cas2 from pYPK0_RPS19atp_ScRKI1_TPI1tp import pYPK0_RPS19atp_ScRKI1_TPI1tp as cas3 from pYPK0_TPI1tp_CiGXF1_ENO2tp import pYPK0_TPI1tp_CiGXF1_ENO2tp as cas4 cas1 = pcr( p167, p647, cas1) cas2 = pcr( p648, p651, cas2) cas3 = pcr( p538, p621, cas3) cas4 = pcr( p419, p166, cas4) pYPK0_E_Z, stuffer = pYPK0.cut((EcoRV, ZraI)) #print [cas1, cas2, cas3, cas4, pYPK0_E_Z] a = Assembly([cas1, cas2, cas3, cas4, pYPK0_E_Z], limit = 61) seq = a.circular_products[0] print seq.small_fig() seq=seq.synced("tcgcgcgtttcggtgatgacggtgaaaacctctg")