[BioPython] running primer3 with multiple sequences
Maqbool, Nauman
nauman.maqbool at agresearch.co.nz
Sun Oct 3 21:44:33 EDT 2004
Hi
I am trying to run eprimer3 using biopython and am not sure how to input
multiple options. E.g. if I am reading in a fasta file with hundreds of
sequences with different primer design parameters for each sequence, do
I have to hard code the parameters individually for each sequence?
In the example below:
from Bio.Emboss.Applications import Primer3Commandline
from Bio.Emboss.Primer import Primer3Parser
from Bio.Application import generic_run
def get_primers(fasta_record, start, end):
open("in.pr3", "w").write(str(fasta_record) + "\n")
primer_cl = Primer3Commandline()
primer_cl.set_parameter("-sequence", "in.pr3")
primer_cl.set_parameter("-outfile", "out.pr3")
primer_cl.set_parameter("-productsizerange", "350,500")
primer_cl.set_parameter("-target", "%s,%s" % (start, end))
result, r, e = generic_run(primer_cl)
parser = Primer3Parser()
return parser.parse(open("out.pr3"))
def main(fasta_file, output_file):
output_handle = open(output_file, "w")
output_handle.write("name,forward_primer,reverse_primer\n")
parser = Fasta.RecordParser()
iterator = Fasta.Iterator(open(fasta_file), parser)
while 1:
cur_record = iterator.next()
if not(cur_record): break
primer_record = get_primers(cur_record, 100, 250)
if len(primer_record.primers) > 0:
primer = primer_record.primers[0]
output_handle.write("%s,%s,%s\n" % (
cur_record.title, primer.forward_seq,
primer.reverse_seq))
else:
print "No primers found for %s" % cur_record.title
the start and end positions, i.e. the target area, to be included in the
product, remains the same (100 to 250 in this case), how do I change
these if I have a different target area for different sequences?
Also, how do I use biopython if I give the sequences and parameters in
the format below, rather than using a fasta file?
PRIMER_SEQUENCE_ID=test_seq1
SEQUENCE=atgatgatgtnnnnnnnnntgatgatgatgcaccatagatgatcacacaccattaaacatcat
catcttgatgatgatgcaccatagatgatcacacaccattaaacatcatcatcttaaacatcatcatcttga
tgatgatgcaccatagatgatcacacaccataaacatcatcatctgatgatgatgcaccatagatgatcaca
caccattaaacatcatcatcttaaacatcatcatcttgatgatgatgcaccatagatgatcacacaccatta
aacatcatcatcttaaacatcatcatcttgatgatgatgcaccatagatgatcacacacca
INCLUDED_REGION=150,329
PRIMER_OPT_SIZE=19
PRIMER_MIN_SIZE=17
PRIMER_MAX_SIZE=22
PRIMER_PRODUCT_SIZE_RANGE=64-629
PRIMER_EXPLAIN_FLAG=1
=
Thanks a lot
Nauman
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================
More information about the BioPython
mailing list