B
    ž3Rc!  ã               @   s4   d Z ddlmZ d	dd„Zd
dd„Zee_ee_dS )z; This functionality gets mixed into the BitEnsemble class

é    )ÚBitEnsembleÚ c             C   sZ   |r|g}ng }x|   ¡ D ]}| d| ¡ qW |r>| |¡ | |d |¡¡ || _dS )z« inializes a db table to store our scores

    idInfo and actInfo should be strings with the definitions of the id and
    activity columns of the table (when desired)

  zBit_%d smallintú,N)ÚGetBitsÚappendZAddTableÚjoinÚ_dbTableName)ÚselfÚdbConnÚ	tableNameZidInfoZactInfoÚcolsÚbit© r   ú>lib/python3.7/site-packages/rdkit/DataStructs/BitEnsembleDb.pyÚ_InitScoreTable   s    
r   Nc       
      C   s–   |dkr0y
| j }W n tk
r.   tdƒ‚Y nX |dk	r@|g}ng }d}x*|  ¡ D ]}|| }	| |	¡ ||	7 }qRW |dk	r†| |¡ | ||¡ dS )zT scores the "signature" that is passed in and puts the
  results in the db table

  Nz9table name not set in BitEnsemble pre call to ScoreToDb()r   )r   ÚAttributeErrorÚ
ValueErrorr   r   Z
InsertData)
r	   Zsigr
   r   ÚidZactr   Zscorer   Úbr   r   r   Ú
_ScoreToDb$   s     


r   )r   r   )NNN)Ú__doc__Zrdkit.DataStructs.BitEnsembler   r   r   ZInitScoreTableZ	ScoreToDbr   r   r   r   Ú<module>   s
   

