B
    3Rc                  @   s   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ e Ze	dZ
dd Zdd	 Zd
Zdd Zdd Zdd Zedkre  dS )    N)Chem)RDLogger)ChemicalFeaturesz[ \t,]c             C   sv   d g|   }| |}xX|D ]P}| }d| | f }x.|D ]&}|| d kr\g ||< || | qDW qW |S )Nz%s-%s)ZGetNumAtomsGetFeaturesForMol
GetAtomIds	GetFamilyGetTypeappend)factorymolZresfeatsfeatZidsZfeatureZid_ r   7lib/python3.7/site-packages/rdkit/Chem/FeatFinderCLI.pyGetAtomFeatInfo   s    


r   c              C   s`   t jdtt jd} | jdddddd | jd	d
dt jtd | jdtdd | jdtdd | S )z Initialize the parser z-Determine pharmacophore features of molecules)ZdescriptionZepilogZformatter_classz-r	reverseItF
store_truez(Set to get atoms lists for each feature.)destdefaultactionhelpz-nmaxLines)r   r   r   typefdefFilenamez%Pharmacophore feature definition file)r   r   smilesFilenamez6The smiles file should have SMILES in the first column)argparseArgumentParser_splashMessageZRawDescriptionHelpFormatteradd_argumentZSUPPRESSintexistingFile)parserr   r   r   
initParser%   s    
r#   z
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  FeatFinderCLI
  Part of the RDKit (http://www.rdkit.org)
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
c             C   s    t j| std| | S )z2 'type' for argparse - check that filename exists z{0} does not exist)ospathexistsr   ZArgumentTypeErrorformat)filenamer   r   r   r!   <   s    r!   c          	   C   s  yt | j}W n$ tk
r4   |d|  Y nX t| j:}x0t|dD ] \}}|| j	d krlP t
| d  }t|}|d krtd||f  qRtd||f  | jr||}x|D ]<}	td|	 |	 f dd td	d
d |	 D  qW qRt||}
xVt|
D ]J\}}td|| |d f dd |rhtdd	| nt  q&W qRW W d Q R X d S )Nz+Could not parse Fdef file {0.fdefFilename}.   r   z)Could not process smiles '%s' on line %d.z	Mol-%d	%sz	%s-%s:  )endz, c             S   s   g | ]}t |qS r   )str).0xr   r   r   
<listcomp>X   s    zprocessArgs.<locals>.<listcomp>z		% 2s(%d)	)r   ZBuildFeatureFactoryr   	Exceptionerrorr'   openr   	enumerater   	splitExprsplitstripr   ZMolFromSmilesloggerZwarningprintr   r   r   r   joinr   r   ZGetAtomWithIdxZ	GetSymbol)argsr"   r
   ZinFZlineNolineZsmir   r   r   ZfeatInfoivr   r   r   processArgsC   s2    


"
"r?   c              C   s   t  } |  }t||  dS )z Main application N)r#   
parse_argsr?   )r"   r;   r   r   r   mainc   s    rA   __main__)r   rer$   Zrdkitr   r   Z
rdkit.Chemr   r8   compiler5   r   r#   r   r!   r?   rA   __name__r   r   r   r   <module>   s   
 