B
    IWc!              
   @   s   d Z ddlZddlmZ ddlmZ e Zejejej	ej
ejejejejejejiZG dd deZddd	ZdddZdddZdddZdddZdd ZdddZddddd	ddddg	ZdS )T    N)rdinchi)RDLoggerc               @   s   e Zd ZdS )InchiReadWriteErrorN)__name__
__module____qualname__ r   r   /lib/python3.7/site-packages/rdkit/Chem/inchi.pyr   1   s   r   Fc       
   
   C   s   yt | ||\}}}}W n0 tk
rJ }	 ztt|	 dS d}	~	X Y nX |dk	r|tkrhtd| t| }|dkr|| |dkr|dkrt| n
t| |r|dkrt|||S )a  Construct a molecule from a InChI string

    Keyword arguments:
    sanitize -- set to True to enable sanitization of the molecule. Default is
    True
    removeHs -- set to True to remove Hydrogens from a molecule. This only
    makes sense when sanitization is enabled
    logLevel -- the log level used for logging logs and messages from InChI
    API. set to None to diable the logging completely
    treatWarningAsError -- set to True to raise an exception in case of a
    molecule that generates warning in calling InChI API. The resultant
    molecule  and error message are part of the excpetion

    Returns:
    a rdkit.Chem.rdchem.Mol instance
    NzUnsupported log level: %dr      )	r   Z
InchiToMol
ValueErrorloggererrorstrlogLevelToLogFunctionLookupwarningr   )
inchiZsanitizeZremoveHslogLeveltreatWarningAsErrormolretcodemessageloger   r   r	   MolFromInchi5   s$    

r    c       
      C   s   t | |\}}}}}|dk	rJ|tkr2td| t| }	|dkrJ|	| |dkrp|dkrft| n
t| |r|dkrt|||||fS )ae  Returns the standard InChI string and InChI auxInfo for a molecule

    Keyword arguments:
    logLevel -- the log level used for logging logs and messages from InChI
    API. set to None to diable the logging completely
    treatWarningAsError -- set to True to raise an exception in case of a
    molecule that generates warning in calling InChI API. The resultant InChI
    string and AuxInfo string as well as the error message are encoded in the
    exception.

    Returns:
    a tuple of the standard InChI string and the auxInfo string returned by
    InChI API, in that order, for the input molecule
    NzUnsupported log level: %dr   r
   )r   
MolToInchir   r   r   r   r   r   )
r   optionsr   r   r   r   r   logsauxr   r   r   r	   MolToInchiAndAuxInfo]   s    
r   c       
      C   s   t | |\}}}}}|dk	rJ|tkr2td| t| }	|dkrJ|	| |dkrp|dkrft| n
t| |r|dkrt|||||fS )af  Returns the standard InChI string and InChI auxInfo for a mol block

    Keyword arguments:
    logLevel -- the log level used for logging logs and messages from InChI
    API. set to None to diable the logging completely
    treatWarningAsError -- set to True to raise an exception in case of a
    molecule that generates warning in calling InChI API. The resultant InChI
    string and AuxInfo string as well as the error message are encoded in the
    exception.

    Returns:
    a tuple of the standard InChI string and the auxInfo string returned by
    InChI API, in that order, for the input molecule
    NzUnsupported log level: %dr   r
   )r   MolBlockToInchir   r   r   r   r   r   )
molblockr   r   r   r   r   r   r   r   r   r   r   r	   MolBlockToInchiAndAuxInfo}   s    
r"   c          
   C   sz   | ddkr$|r|d7 }n|d7 }yt| |||d\}}W n8 tk
rt } z|j\}}}t||W dd}~X Y nX |S )a  Returns the standard InChI string for a molecule

    Keyword arguments:
    logLevel -- the log level used for logging logs and messages from InChI
    API. set to None to diable the logging completely
    treatWarningAsError -- set to True to raise an exception in case of a
    molecule that generates warning in calling InChI API. The resultant InChI
    string and AuxInfo string as well as the error message are encoded in the
    exception.

    Returns:
    the standard InChI string returned by InChI API for the input molecule
    AuxNonez	 /AuxNonez/AuxNone)r   r   N)findr   r   args)r   r   r   r   r   r   instr   r   r   r	   r      s    
r   c          
   C   sz   | ddkr$|r|d7 }n|d7 }yt| |||d\}}W n8 tk
rt } z|j\}}}t||W dd}~X Y nX |S )a  Returns the standard InChI string for a mol block

    Keyword arguments:
    logLevel -- the log level used for logging logs and messages from InChI
    API. set to None to diable the logging completely
    treatWarningAsError -- set to True to raise an exception in case of a
    molecule that generates warning in calling InChI API. The resultant InChI
    string and AuxInfo string as well as the error message are encoded in the
    exception.

    Returns:
    the standard InChI string returned by InChI API for the input molecule
    r#   r$   z	 /AuxNonez/AuxNone)r   r   N)r%   r"   r   r&   )r!   r   r   r   r   r   r'   r   r   r   r	   r       s    
r    c             C   s   t | }|r|S dS dS )zEReturn the InChI key for the given InChI string. Return None on errorN)r   InchiToInchiKey)r   Zretr   r   r	   r(      s    
r(   c             C   s   t | |S )zReturns the standard InChI key for a molecule

    Returns:
    the standard InChI key returned by InChI API for the input molecule
    )r   MolToInchiKey)r   r   r   r   r	   r)      s    r)   INCHI_AVAILABLE)TTNF)r   NF)r   NF)r   NF)r   NF)r   )r*   ZloggingZ
rdkit.Chemr   Zrdkitr   r   INFOinfoDEBUGdebugZWARNINGr   ZCRITICALZcriticalZERRORr   r   	Exceptionr   r   r   r"   r   r    r(   r)   __all__r   r   r   r	   <module>    s&   
(
 
 


