B
    ž3Rc÷
  ã               @   sŠ   d Z ddlZddlmZ e d¡Ze d¡Ze d¡Ze d¡Ze d¡Z	e d	¡Z
e	d
fedfe
dfedfedfedffZddd„ZdS )z(  Functionality for SATIS typing atoms

é    N)ÚChemz[CD2]=[OD1]z[CD3]=[OD1]z[CD3](=[OD1])-[#7]zC(=[OD1])-O-[#6]zC(=[OD1])-[OX1]zC(=[OD1])-[OX2]éa   é`   éb   é_   é^   é]   é   c                s€  |   ¡ }|  ¡ }dd„ |D ƒ‰ g }x:tD ]2\}}|  |¡}|r(ttj|Ž ƒ}| ||f¡ q(W dg| }xt|ƒD ]\}	}
dg|d  }t	|
 
¡ dƒ|d< dd„ |
 ¡ D ƒ}t‡ fdd„|D ƒdg|
 ¡   ƒ}t|ƒ|krî|| d… }x$t|dƒD ]\}}t	|dƒ||< qúW t|ƒ|k r`|d d	kr`|
 ¡ }x&|D ]\}}||kr>||d
< P q>W d dd„ |D ƒ¡||	< qtW |S )a©   returns SATIS codes for all atoms in a molecule

   The SATIS definition used is from:
   J. Chem. Inf. Comput. Sci. _39_ 751-757 (1999)

   each SATIS code is a string consisting of _neighborsToInclude_ + 1
   2 digit numbers

   **Arguments**

     - mol: a molecule

     - neighborsToInclude (optional): the number of neighbors to include
       in the SATIS codes

   **Returns**

     a list of strings nAtoms long

  c             S   s   g | ]}|  ¡ ‘qS © )ÚGetAtomicNum)Ú.0Úatomr
   r
   ú/lib/python3.7/site-packages/rdkit/Chem/SATIS.pyú
<listcomp>6   s    zSATISTypes.<locals>.<listcomp>Néc   é   r   c             S   s   g | ]}|  ¡ ‘qS r
   )ÚGetIdx)r   Úxr
   r
   r   r   H   s    c                s   g | ]}ˆ | ‘qS r
   r
   )r   r   )Ú
atomicNumsr
   r   r   I   s    )é   é   éÿÿÿÿÚ c             s   s   | ]}d | V  qdS )z%02dNr
   )r   r   r
   r
   r   ú	<genexpr>X   s    zSATISTypes.<locals>.<genexpr>)ZGetNumAtomsZGetAtomsÚspecialCasesZGetSubstructMatchesÚsetÚ	itertoolsÚchainÚappendÚ	enumerateÚminr   ZGetNeighborsÚsortedZGetTotalNumHsÚlenr   Újoin)ZmolZneighborsToIncludeZnAtomsZatomsZspecialCaseMatchesZpattZspecialCaseIdxZmatchesZcodesÚir   ÚcodeZotherIndicesZ	otherNumsÚjZotherNumZatomIdxr
   )r   r   Ú
SATISTypes   s6    

$
r'   )r	   )Ú__doc__r   Zrdkitr   ZMolFromSmartsZaldehydePattZ
ketonePattZ	amidePattZ	esterPattZcarboxylatePattZcarboxylPattr   r'   r
   r
   r
   r   Ú<module>   s   





