ó
a#nSc           @   sM   d  Z  d d l m Z d d d  Z d d d d  Z e e _ e e _ d S(   s;    This functionality gets mixed into the BitEnsemble class

iÿÿÿÿ(   t   BitEnsemblet    c         C   s|   | r | g } n g  } x% |  j    D] } | j d |  q% W| rV | j |  n  | j | d j |   | |  _ d S(   s«    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)

  s   Bit_%d smallintt   ,N(   t   GetBitst   appendt   AddTablet   joint   _dbTableName(   t   selft   dbConnt	   tableNamet   idInfot   actInfot   colst   bit(    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/DataStructs/BitEnsembleDb.pyt   _InitScoreTable   s    c   
      C   sÅ   | d k r9 y |  j } Wq9 t k
 r5 t d  q9 Xn  | d k	 rQ | g } n g  } d } x5 |  j   D]' } | | }	 | j |	  | |	 7} qj W| d k	 r± | j |  n  | j | |  d S(   sV    scores the "signature" that is passed in and puts the
  results in the db table
  
  s9   table name not set in BitEnsemble pre call to ScoreToDb()i    N(   t   NoneR   t   AttributeErrort
   ValueErrorR   R   t
   InsertData(
   R   t   sigR	   R
   t   idt   actR   t   scoreR   t   b(    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/DataStructs/BitEnsembleDb.pyt
   _ScoreToDb"   s     
N(   t   __doc__t   rdkit.DataStructs.BitEnsembleR    R   R   R   t   InitScoreTablet	   ScoreToDb(    (    (    sa   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/DataStructs/BitEnsembleDb.pyt   <module>   s
   	