[BioPython] Primer3Parser

Larry l.heisler at utoronto.ca
Fri May 9 11:52:29 EDT 2003


I am running Primer3 on a large number of sequences, using mostly default values.  In most instances, I get the default number of primers (5) returned to an output file.  This writes the primers with 4 blank lines at the end.  When I parse this with using Primer3Parser from Bio.Emboss.Primer, all is fine.  In some instances though fewer than 5 primers are returned and there are more than 4 blank lines at the end of the file.  This causes Primer3Parser to crash.

I was able to fix the problem, but not sure if it is the best way.  I modified the Martel definitions for primer3 output contained in Bio.Emboss.primer3_format.py:

the record definition was
record = Martel.Group("primer3_record",
                      comments + \
                        Martel.Alt(
                         # case 1. primer file with nothing
                         Martel.Str("\n" * 3) +
                         Martel.Opt(Martel.Str("\n" * 4)),
                         # case 2. some primers have been picked
                         Martel.Rep(
                           # case 2a. we are designing a primer pair 
                           Martel.Alt(blank_line + primer_start_line,
                           # case 2b. we are designing a single primer
                                      single_primer_line) +
                           # case 2a. both primer pairs
                           Martel.Alt(forward_line + blank_line + 
                                      reverse_line + blank_line,
                           # case 2b1. Reverse primer
                                      reverse_line + blank_line,
                            # case 2b2, Forward primer
                                      forward_line + blank_line)) +
                           blank_line + blank_line))

I modified the end to allow additional blank lines
record = Martel.Group("primer3_record",
                      comments + \
                        Martel.Alt(
                         # case 1. primer file with nothing
                         Martel.Str("\n" * 3) +
                         Martel.Opt(Martel.Str("\n" * 4)),
                         # case 2. some primers have been picked
                         Martel.Rep(
                           # case 2a. we are designing a primer pair 
                           Martel.Alt(blank_line + primer_start_line,
                           # case 2b. we are designing a single primer
                                      single_primer_line) +
                           # case 2a. both primer pairs
                           Martel.Alt(forward_line + blank_line + 
                                      reverse_line + blank_line,
                           # case 2b1. Reverse primer
                                      reverse_line + blank_line,
                            # case 2b2, Forward primer
                                      forward_line + blank_line)) +
                           blank_line + blank_line + Martel.Rep(blank_line)))
                        

                        
-I am new to Python, still trying to figure out syntax, but this seems to work.  Any advice on a better solution would be appreciated
Thanks
Larry

Lawrence Heisler, PhD
Department of Laboratory Medicine and Pathobiology
Faculty of Medicine
University of Toronto
Phone: 416-946-7921
email: l.heisler at utoronto.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://pw600a.bioperl.org/pipermail/biopython/attachments/20030509/a4ca733f/attachment.html


More information about the BioPython mailing list