
:>"^1
  ã               @   sX   d  Z  Gd d „  d e ƒ Z Gd d „  d e ƒ Z Gd d „  d e ƒ 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   ú</tmp/pip-build-ww9dw3qa/biopython/Bio/Emboss/PrimerSearch.pyÚ__init__   s    zInputRecord.__init__c             C   s>   d } x1 |  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  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   3   s    	zAmplifier.__init__N)r   r   r   r   r   r   r   r   r   r   0   s   r   c             C   s3  t  ƒ  } xå |  D]Ý } | j ƒ  s( q q | j d ƒ rW | j ƒ  d } g  | j | <q | j d ƒ r† t ƒ  } | j | j | ƒ q | j d ƒ r­ | j d d ƒ | _ q | j d ƒ rÞ | j ƒ  d	 } t	 | ƒ | _
 q | j | 7_ q Wx; | j D]0 } x' | j | D] } | j j ƒ  | _ qWqû 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)ÚhandleÚrecordÚliner	   Z	amplifierr   r   r   r   Úread9   s(    		r$   N)r   Úobjectr   r   r   r$   r   r   r   r   Ú<module>   s   	