B
    ‰°bá	  ã               @   s:   d Z G dd„ dƒZG dd„ dƒZG dd„ dƒZdd„ Zd	S )
z;Code to interact with the primersearch program from EMBOSS.c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚInputRecordz¥Represent the input file into the primersearch program.

    This makes it easy to add primer information and write it out to the
    simple primer file format.
    c             C   s
   g | _ dS )zInitialize the class.N)Úprimer_info)Úself© r   ú6lib/python3.7/site-packages/Bio/Emboss/PrimerSearch.pyÚ__init__   s    zInputRecord.__init__c             C   s0   d}x&| j D ]\}}}|d|||f 7 }qW |S )z4Summarize the primersearch input record as a string.Ú z	%s %s %s
)r   )r   ÚoutputÚnameZprimer1Zprimer2r   r   r   Ú__str__   s    zInputRecord.__str__c             C   s   | j  |||f¡ dS )z%Add primer information to the record.N)r   Úappend)r   Zprimer_nameZfirst_primer_seqZsecond_primer_seqr   r   r   Úadd_primer_set   s    zInputRecord.add_primer_setN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r   r   r   r   r      s   r   c               @   s   e Zd ZdZdd„ ZdS )ÚOutputRecordz»Represent the information from a primersearch job.

    amplifiers is a dictionary where the keys are the primer names and
    the values are a list of PrimerSearchAmplifier objects.
    c             C   s
   i | _ dS )zInitialize the class.N)Ú
amplifiers)r   r   r   r   r   )   s    zOutputRecord.__init__N)r   r   r   r   r   r   r   r   r   r   "   s   r   c               @   s   e Zd ZdZdd„ ZdS )Ú	Amplifierz/Represent a single amplification from a primer.c             C   s   d| _ d| _dS )zInitialize the class.r   é    N)Úhit_infoÚlength)r   r   r   r   r   1   s    zAmplifier.__init__N)r   r   r   r   r   r   r   r   r   r   .   s   r   c             C   sâ   t ƒ }x¦| D ]ž}| ¡ sqq| d¡r>| ¡ d }g |j|< q| d¡r`tƒ }|j|  |¡ q| d¡rz| dd¡|_q| d¡rœ| ¡ d }t	|ƒ|_
q| j|7  _qW x.|jD ]$}x|j| D ]}|j ¡ |_qÆW q¶W |S )z=Get output from primersearch into a PrimerSearchOutputRecord.zPrimer nameéÿÿÿÿZAmplimerz	Sequence: r   z	Amplimer length: éþÿÿÿ)r   ÚstripÚ
startswithÚsplitr   r   r   Úreplacer   Úintr   Úrstrip)ZhandleÚrecordÚliner	   Z	amplifierr   r   r   r   Úread7   s(    




r!   N)r   r   r   r   r!   r   r   r   r   Ú<module>   s   	