Digesting contig sequence with multiple enzymes
I was trying get a length of each fragment produce by restriction enzyme for each contig present in my contigs.fasta. In my following example enzyme is AflII. So basically, I am digesting each contig with AflII enzyme. So my code for that is as follows
for record in Bio.SeqIO.parse(open("contigs.fasta"), "fasta"):
printrecord.id, [len(fragment) for fragment in Bio.Restriction.AflII.catalyze(record.seq)])
Now, I have more than one enzyme and I have to generate digestion for that. How can I do it using BioPython?
Please let me know, If you are unclear about the question. PS: I am new to the topic and BioPython as well.
• 2,926 views
•
link
1 answer
Can you better explain your desiderata?
My code for what I understand is the following, but I'm not sure of what you want.
from Bio import SeqIO
from Bio.Restriction import *
multi = (BamHI, EcoRI, PstI) # just a few enzymes
for record in SeqIO.parse("contigs.fasta", "fasta"):
for enz in range(len(multi)):
coords = multi[enz].search(record.seq)
for site in range(len(coords)):
print "%s %d %s" % (record.id, coords[site], multi[enz])
• 0 views
•
link
Log in to answer this question.