o
    Rŀg                     @   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 )Initialize the class. N)commentsprimersself r   F/var/www/html/myenv/lib/python3.10/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 )r       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_gcr   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   	 |   }| rnqd}d}	 |dr*|dur|V  t }| j|7  _d}n|dr=| dkr<| j|7  _n| sBn|dd dkr]t }t|dd |_|j	| n|dd d	kr|
 }|rp|jd
kryt }|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 |_nN|dd dkr'|
 }|r|jd
krt }|j	| t|d |_t|d |_t|d |_t|d |_z|d |_W n ty&   d|_Y nw zt| }W n
 ty7   Y nw q|rA|V  dS dS )zAIterate over primer3 output as Bio.Emboss.Primer3.Record objects.TN)z
# 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recordprimerwordsr   r   r	   parse_   s   


9
r8   c                 C   sT   t | }zt|}W n ty   tddw zt| td ty)   Y |S w )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)r8   r1   r2   
ValueError)r3   iteratorr5   r   r   r	   read   s   
r;   N)r   r   r   r8   r;   r   r   r   r	   <module>   s
   	4H