B
    b                 @   s4   d Z G dd dZG dd dZdd Zdd Zd	S )
a  Code to parse output from the EMBOSS eprimer3 program.

As elsewhere in Biopython there are two input functions, read and parse,
for single record output and multi-record output. For primer3, a single
record object is created for each target sequence and may contain
multiple primers.

i.e. If you ran eprimer3 with a single target sequence, use the read
function. If you ran eprimer3 with multiple targets, use the parse
function to iterate over the retsults.
c               @   s   e Zd ZdZdd ZdS )RecordzRepresent information from a primer3 run finding primers.

    Members:

        - primers  - list of Primer objects describing primer pairs for
          this target sequence.
        - comments - the comment line(s) for the record

    c             C   s   d| _ g | _dS )zInitialize the class. N)commentsprimers)self r   1lib/python3.7/site-packages/Bio/Emboss/Primer3.py__init__%   s    zRecord.__init__N)__name__
__module____qualname____doc__r   r   r   r   r   r      s   	r   c               @   s    e Zd ZdZdd Zdd ZdS )Primersa  A primer set designed by Primer3.

    Members:

        - size - length of product, note you can use len(primer) as an
          alternative to primer.size

        - forward_seq
        - forward_start
        - forward_length
        - forward_tm
        - forward_gc

        - reverse_seq
        - reverse_start
        - reverse_length
        - reverse_tm
        - reverse_gc

        - internal_seq
        - internal_start
        - internal_length
        - internal_tm
        - internal_gc

    c             C   sd   d| _ d| _d| _d| _d| _d| _d| _d| _d| _d| _	d| _
d| _d| _d| _d| _d| _dS )zInitialize the class.    r   g        N)sizeforward_seqforward_startforward_length
forward_tm
forward_gcreverse_seqreverse_startreverse_length
reverse_tm
reverse_gcinternal_seqinternal_startinternal_lengthinternal_tminternal_gc)r   r   r   r   r   G   s     zPrimers.__init__c             C   s   | j S )z1Length of the primer product (i.e. product size).)r   )r   r   r   r   __len__Z   s    zPrimers.__len__N)r	   r
   r   r   r   r   r   r   r   r   r   +   s   r   c             c   s  x|   }| rP qW d}d}xz|ds8|drb|dk	rF|V  t }| j|7  _d}n|dr| dkr| j|7  _n| sn|dd dkrt }t|dd |_|j	| n|dd d	krP|
 }|r|jd
kr
t }|j	| t|d |_t|d |_t|d |_t|d |_|d |_n$|dd dkr|
 }|r||jd
krt }|j	| t|d |_t|d |_t|d |_t|d |_|d |_n|dd dkrt|
 }|r|jd
krt }|j	| t|d |_t|d |_t|d |_t|d |_y|d |_W n tk
rr   d|_Y nX yt| }W q$ tk
r   P Y q$X q$W |r|V  dS )zAIterate over primer3 output as Bio.Emboss.Primer3.Record objects.Nz
# EPRIMER3z	# PRIMER3#z9#                      Start  Len   Tm     GC%   Sequence      zPRODUCT SIZE: zFORWARD PRIMERr               zREVERSE PRIMERzINTERNAL OLIGOr   )readlinestrip
startswithr   r   r   intr   r   appendsplitr   r   floatr   r   r   r   r   r   r   r   r   r   r   r   r   
IndexErrornextStopIteration)handlelinerecordZprimerZwordsr   r   r   parse_   s|    
r4   c             C   sb   t | }yt|}W n tk
r2   tddY nX yt| tdW n tk
r\   Y nX |S )zParse 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.
    zNo records found in handleNz$More than one record found in handle)r4   r/   r0   
ValueError)r1   iteratorr3   r   r   r   read   s    r7   N)r   r   r   r4   r7   r   r   r   r   <module>   s   4H