Back to index

python-biopython  1.60
Classes | Functions
Bio.Emboss.Primer3 Namespace Reference

Classes

class  Record
class  Primers

Functions

def parse
def read

Function Documentation

def Bio.Emboss.Primer3.parse (   handle)
Iterate over primer3 output as Bio.Emboss.Primer3.Record objects.

Definition at line 84 of file Primer3.py.

00084 
00085 def parse(handle):
00086     """Iterate over primer3 output as Bio.Emboss.Primer3.Record objects.
00087     """
00088     # Skip blank lines at head of file
00089     while True:
00090         line = handle.readline()
00091         if line.strip():
00092             break # Starting a record
00093 
00094     # Read each record
00095     record = None
00096     primer = None
00097     while True:
00098         if line.startswith('# EPRIMER3') or line.startswith('# PRIMER3'):
00099             # Record data
00100             if record is not None:
00101                 yield record
00102             record = Record()
00103             record.comments += line
00104             primer = None
00105         elif line.startswith('#'):
00106             if line.strip() != '#                      Start  Len   Tm     GC%   Sequence':
00107                 record.comments += line
00108         elif not line.strip():
00109             pass
00110         elif line[5:19]=="PRODUCT SIZE: ":
00111             primer = Primers()
00112             primer.size = int(line[19:])
00113             record.primers.append(primer)
00114         elif line[5:19]=="FORWARD PRIMER":
00115             words = line.split()
00116             if not primer or primer.size==0:
00117                 primer = Primers()
00118                 record.primers.append(primer)
00119             primer.forward_start = int(words[2])
00120             primer.forward_length = int(words[3])
00121             primer.forward_tm = float(words[4])
00122             primer.forward_gc = float(words[5])
00123             primer.forward_seq = words[6]
00124         elif line[5:19]=="REVERSE PRIMER":
00125             words = line.split()
00126             if not primer or primer.size==0:
00127                 primer = Primers()
00128                 record.primers.append(primer)
00129             primer.reverse_start = int(words[2])
00130             primer.reverse_length = int(words[3])
00131             primer.reverse_tm = float(words[4])
00132             primer.reverse_gc = float(words[5])
00133             primer.reverse_seq = words[6]
00134         elif line[5:19]=="INTERNAL OLIGO":
00135             words = line.split()
00136             if not primer or primer.size==0:
00137                 primer = Primers()
00138                 record.primers.append(primer)
00139             primer.internal_start = int(words[2])
00140             primer.internal_length = int(words[3])
00141             primer.internal_tm = float(words[4])
00142             primer.internal_gc = float(words[5])
00143             primer.internal_seq = words[6]
00144         try:
00145             line = handle.next()
00146         except StopIteration:
00147             break
00148     if record:
00149         yield record
00150 

Here is the caller graph for this function:

def Bio.Emboss.Primer3.read (   handle)
Parse primer3 output into a Bio.Emboss.Primer3.Record object.

This is for when there is one and only one target sequence. If
designing primers for multiple sequences, use the parse function.

Definition at line 151 of file Primer3.py.

00151 
00152 def read(handle):
00153     """Parse primer3 output into a Bio.Emboss.Primer3.Record object.
00154 
00155     This is for when there is one and only one target sequence. If
00156     designing primers for multiple sequences, use the parse function.
00157     """
00158     iterator = parse(handle)
00159     try:
00160         first = iterator.next()
00161     except StopIteration:
00162         raise ValueError("No records found in handle")
00163     try:
00164         second = iterator.next()
00165     except StopIteration:
00166         second = None
00167     if second is not None:
00168         raise ValueError("More than one record found in handle")
00169     return first

Here is the call graph for this function: