#!/usr/bin/env python # coding: utf-8 # # This notebook shows rich jupyter representations of Dseqrecord and derived classes # # * Dseqrecord --> base class # * GenbankRecord(Dseqrecord) --> read from Genbank link # * GenbankFile(Dseqrecord) --> read from local file # * Amplicon(Dseqrecord) --> PCR product # * Contig(Dseqrecord) --> Produced through Assembly # In[1]: try: from pydna.readers import read from pydna.parsers import parse_primers from pydna.dseqrecord import Dseqrecord from pydna.genbank import Genbank from pydna.amplify import pcr from pydna.assembly import Assembly except ImportError: import sys, os sys.path.append(os.pardir) from pydna.readers import read from pydna.parsers import parse_primers from pydna.dseqrecord import Dseqrecord from pydna.genbank import Genbank from pydna.amplify import pcr from pydna.assembly import Assembly # ### Dseqrecord # In[2]: ldsr = Dseqrecord("aaa") # In[3]: type(ldsr) # In[4]: ldsr # In[5]: [ldsr, ldsr] # In[6]: cdsr = Dseqrecord("aaa", circular=True) # In[7]: type(cdsr) # In[8]: cdsr # In[9]: [cdsr, cdsr] # In[10]: cdsr.reverse_complement() # In[11]: [cdsr.reverse_complement(), cdsr.reverse_complement()] # In[12]: fromstring = read(">string\naaaa") # In[13]: type(fromstring) # In[14]: fromstring # In[15]: [fromstring, fromstring] # In[16]: [fromstring.reverse_complement(), fromstring.reverse_complement()] # ### GenbankRecord # In[17]: from pydna.genbankrecord import GenbankRecord # In[18]: # The GenbankRecord is not meant to be used directly gbr = GenbankRecord("aaa", item="AccessionNumber", start=1, stop=3, circular=True) # In[19]: type(gbr) # In[20]: # This link is dead as expected gbr # In[21]: gbr.hyperlink # In[22]: gbr.reverse_complement() # In[23]: gbr.reverse_complement().hyperlink # In[24]: gbr.reverse_complement().reverse_complement().hyperlink # In[25]: gb = Genbank("bjornjobb@gmail.com") # In[26]: gbr2 = gb.nucleotide("E05006") # In[27]: type(gbr2) # In[28]: gbr2 # In[29]: gbr2.reverse_complement() # In[30]: gbr3 = gb.nucleotide("E05006 REGION: 5..15") # In[31]: type(gbr3) # In[32]: gbr4 = gb.nucleotide("E05006 REGION: complement(5..15)") # In[33]: type(gbr4) # In[34]: gbr4 # In[35]: gbr4.reverse_complement() # ### GenbankFile # In[36]: from pydna.genbankfile import GenbankFile # In[37]: gbf = GenbankFile("aaa") # In[38]: type(gbf) # In[39]: # The GenbankFile is not supposed to be used directly # The link below is dead as expected gbf # In[40]: gbf1 = read("sequence.gb") # In[41]: type(gbf1) # In[42]: gbf1 # In[43]: gbf1.reverse_complement() # In[44]: gbf2 = read("subfolder/sequence.gb") # In[45]: type(gbf2) # In[46]: gbf2 # In[47]: gbf2.reverse_complement() # ### Amplicon # In[48]: from pydna.amplicon import Amplicon # In[49]: # The Amplicon class is not meant to be used directly, but it is possible amp = Amplicon("aaa") # In[50]: type(amp) # In[51]: amp # In[52]: primers = parse_primers( ''' >ForwardPrimer gctactacacacgtactgactg >ReversePrimer tgtggttactgactctatcttg ''' ) # In[53]: temp = Dseqrecord("gctactacacacgtactgactg" + "gatc" * 239 + "caagatagagtcagtaaccaca") # In[54]: prd = pcr(primers, temp) # In[55]: type(prd) # In[56]: prd.figure() # In[57]: prd.program() # In[58]: (prd, prd) # In[59]: prd.reverse_complement() # In[60]: (prd.reverse_complement(), prd.reverse_complement()) # In[61]: prd.reverse_complement().figure() # In[62]: prd.reverse_complement().program() # ### Contig # In[63]: from pydna.contig import Contig # In[64]: # Contig is not meant to be used directly, but it is possible cnt = Contig("aaa") # In[65]: type(cnt) # In[66]: a = Dseqrecord("acgatgctatactaagCCCCtgtgctgtgctct", name="SequenceA") b = Dseqrecord("tgtgctgtgctctTTTTTTTtattctggctgtat", name="SequenceB") c = Dseqrecord("tattctggctgtatGGGGGtacgatgctatactaa", name="SequenceC") x = Assembly((a, b, c), limit=13) # In[67]: x # In[68]: type(x) # In[69]: cnt = x.assemble_circular()[0] # In[70]: type(cnt) # In[71]: cnt # In[72]: cnt.detailed_figure() # In[73]: cnt.reverse_complement() # In[74]: cnt.reverse_complement().detailed_figure()