Question: Restriction For Automated Primer Design
4
gravatar for Whetting
7.8 years ago by
Whetting1.5k
Bethesda, MD
Whetting1.5k wrote:

Hi, I am pretty new to BioPython, but I am trying to write a script that would allow the user to input a fasta-file and the multiple cloning site of the target vector. In my script e.g. pQCXIN is the MCS of a vector. I successfully feed digest the insert and get a list of enzymes that does not cut the insert. However, the list lost the order of the restriction sites defined in the beginning of my code (probably because dictionaries are not ordered??). But the order is essential for my primer design step, as I would obviously like to add a 5' RE to my 5' primer... so basically, how do I get the "no_cutter" as a list that has the same order as the input in the beginning of my code Any help, suggestions would be appreciated This is my code so far...

from Bio.Seq import Seq
from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA
from Bio.Restriction import *
from Bio import SeqIO

##Define the MCS of several vectors this list will get populated while in use##
pQCXIN = RestrictionBatch([NotI,AgeI,BsiWI,PacI,BamHI,EcoRI])
pUC19 = RestrictionBatch([HindIII,SphI,PstI,SalI,XbaI,BamHI,SmaI,KpnI,SacI,EcoRI])

##prompt for vector and insert##
sequence=raw_input('''select your sequence file in FASTA format: ''')
vector=raw_input('''select your vector: ''')
#print vector


for seq in SeqIO.parse(sequence, "fasta"):
    Digest = Analysis(eval(vector), seq.seq, linear=True)
    print seq.id
    #Digest.print_as('map')
    #print Digest.print_that()
    no_cutters = list(Digest.without_site())
    print no_cutters[1].site
python biopython primer • 2.3k views
ADD COMMENTlink modified 7.4 years ago by Brad Chapman9.2k • written 7.8 years ago by Whetting1.5k
6
gravatar for Brad Chapman
7.8 years ago by
Brad Chapman9.2k
Boston, MA
Brad Chapman9.2k wrote:

You can store the vector choices as a dictionary with the names as keys and the values as your ordered list of sites. This avoids the 'eval' in your code, and also gives you a reference to the original ordered list.

Using the ordered list, you can post-sort the returned list of sites using the Decorate-Sort-Undecorate trick (or Schwartzian transform for Perl folks):

http://wiki.python.org/moin/HowTo/Sorting/#TheOldWayUsingDecorate-Sort-Undecorate

Here's your code updated with these two modifications:

from Bio.Seq import Seq
from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA
from Bio.Restriction import *
from Bio import SeqIO

##Define the MCS of several vectors this list will get populated while in use##
vectors = dict(
    pQCXIN = [NotI,AgeI,BsiWI,PacI,BamHI,EcoRI],
    pUC19 = [HindIII,SphI,PstI,SalI,XbaI,BamHI,SmaI,KpnI,SacI,EcoRI])

##prompt for vector and insert##
sequence=raw_input('''select your sequence file in FASTA format: ''')
vector=raw_input('''select your vector (%s) ''' % ", ".join(vectors.keys()))
#print vector

for seq in SeqIO.parse(sequence, "fasta"):
    Digest = Analysis(RestrictionBatch(vectors[vector]), seq.seq, linear=True)
    print seq.id
    no_cutters = list(Digest.without_site())
    no_cutters_w_index = [(vectors[vector].index(r), r) for r in no_cutters]
    no_cutters_w_index.sort()
    no_cutters = [r for (_, r) in no_cutters_w_index]
    print no_cutters[0].site
ADD COMMENTlink modified 7.8 years ago • written 7.8 years ago by Brad Chapman9.2k

Thanks Brad, that worked did exactly what I needed

ADD REPLYlink written 7.8 years ago by Whetting1.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1657 users visited in the last hour