Restriction For Automated Primer Design
1
4
Entering edit mode
13.7 years ago
Whetting ★ 1.6k

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
biopython python primer • 3.6k views
ADD COMMENT
6
Entering edit mode
13.7 years ago

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):

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 COMMENT
0
Entering edit mode

Thanks Brad, that worked did exactly what I needed

ADD REPLY

Login before adding your answer.

Traffic: 2078 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6