ó
a#nSc           @   s§  d  Z  d d l m Z d d l m Z d d l m Z m Z d d l Z d d l	 Z	 d d l
 m Z m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l Z d d l Z d d l Z d d l m Z e j   Z d Z d Z d   Z g  d  Z d   Z e d d d  Z e d d d  Z  d d  Z! d   Z" e d  Z# d   Z$ e% d k r£e& e j'  d k  re"   n  d j( e j'  e _) e# e  e$ e  e! d d  e j* d k rxB e+ e j*  D]1 Z, e j- j. d e, d e j* f  e  e  qāWn e j/ rd d l0 Z0 d d l1 Z0 e0 j2 d  Z3 e3 j4 e  e  e0 j5 j6 d  Z5 e5 j7   e5 j8 d d  e5 j9 d   n
 e  e  n  d S(!   s   command line utility for building composite models

#DOC

**Usage**

  BuildComposite [optional args] filename

Unless indicated otherwise (via command line arguments), _filename_ is
a QDAT file.

**Command Line Arguments**

  - -o *filename*: name of the output file for the pickled composite

  - -n *num*: number of separate models to add to the composite

  - -p *tablename*: store persistence data in the database
     in table *tablename*

  - -N *note*: attach some arbitrary text to the persistence data

  - -b *filename*: name of the text file to hold examples from the
     holdout set which are misclassified

  - -s: split the data into training and hold-out sets before building
     the composite

  - -f *frac*: the fraction of data to use in the training set when the
     data is split

  - -r: randomize the activities (for testing purposes).  This ignores
     the initial distribution of activity values and produces each
     possible activity value with equal likliehood.

  - -S: shuffle the activities (for testing purposes) This produces
     a permutation of the input activity values.

  - -l: locks the random number generator to give consistent sets
     of training and hold-out data.  This is primarily intended
     for testing purposes.

  - -B: use a so-called Bayesian composite model.

  - -d *database name*: instead of reading the data from a QDAT file,
     pull it from a database.  In this case, the _filename_ argument
     provides the name of the database table containing the data set.

  - -D: show a detailed breakdown of the composite model performance
     across the training and, when appropriate, hold-out sets.
     
  - -P *pickle file name*: write out the pickled data set to the file

  - -F *filter frac*: filters the data before training to change the
     distribution of activity values in the training set.  *filter
     frac* is the fraction of the training set that should have the
     target value.  **See note below on data filtering.**

  - -v *filter value*: filters the data before training to change the
     distribution of activity values in the training set. *filter
     value* is the target value to use in filtering.  **See note below
     on data filtering.**
     
  - --modelFiltFrac *model filter frac*: Similar to filter frac above,
     in this case the data is filtered for each model in the composite
     rather than a single overall filter for a composite. *model
     filter frac* is the fraction of the training set for each model
     that should have the target value (*model filter value*).

  - --modelFiltVal *model filter value*: target value to use for
     filtering data before training each model in the composite.
     
  - -t *threshold value*: use high-confidence predictions for the
     final analysis of the hold-out data.

  - -Q *list string*: the values of quantization bounds for the
     activity value.  See the _-q_ argument for the format of *list
     string*.

  - --nRuns *count*: build *count* composite models

  - --prune: prune any models built

  - -h: print a usage message and exit.

  - -V: print the version number and exit

  *-*-*-*-*-*-*-*- Tree-Related Options -*-*-*-*-*-*-*-*

  - -g: be less greedy when training the models.

  - -G *number*: force trees to be rooted at descriptor *number*.

  - -L *limit*: provide an (integer) limit on individual model
     complexity

  - -q *list string*: Add QuantTrees to the composite and use the list
     specified in *list string* as the number of target quantization
     bounds for each descriptor.  Don't forget to include 0's at the
     beginning and end of *list string* for the name and value fields.
     For example, if there are 4 descriptors and you want 2 quant
     bounds apiece, you would use _-q "[0,2,2,2,2,0]"_.
     Two special cases:
       1) If you would like to ignore a descriptor in the model
          building, use '-1' for its number of quant bounds.
       2) If you have integer valued data that should not be quantized
          further, enter 0 for that descriptor.

  - --recycle: allow descriptors to be used more than once in a tree        

  - --randomDescriptors=val: toggles growing random forests with val
      randomly-selected descriptors available at each node.


  *-*-*-*-*-*-*-*- KNN-Related Options -*-*-*-*-*-*-*-*

  - --doKnn: use K-Nearest Neighbors models

  - --knnK=*value*: the value of K to use in the KNN models

  - --knnTanimoto: use the Tanimoto metric in KNN models
  
  - --knnEuclid: use a Euclidean metric in KNN models
  
  *-*-*-*-*-*-*- Naive Bayes Classifier Options -*-*-*-*-*-*-*-*
  - --doNaiveBayes : use Naive Bayes classifiers
  
  - --mEstimateVal : the value to be used in the m-estimate formula
      If this is greater than 0.0, we use it to compute the conditional
      probabilities by the m-estimate

  *-*-*-*-*-*-*-*- SVM-Related Options -*-*-*-*-*-*-*-*

  **** NOTE: THESE ARE DISABLED ****  

##   - --doSVM: use Support-vector machines

##   - --svmKernel=*kernel*: choose the type of kernel to be used for
##     the SVMs.  Options are:
##     The default is:

##   - --svmType=*type*: choose the type of support-vector machine
##     to be used.  Options are:
##     The default is:

##   - --svmGamma=*gamma*: provide the gamma value for the SVMs.  If this
##     is not provided, a grid search will be carried out to determine an
##     optimal *gamma* value for each SVM.
    
##   - --svmCost=*cost*: provide the cost value for the SVMs.  If this is
##     not provided, a grid search will be carried out to determine an
##     optimal *cost* value for each SVM.

##   - --svmWeights=*weights*: provide the weight values for the
##     activities.  If provided this should be a sequence of (label,
##     weight) 2-tuples *nActs* long.  If not provided, a weight of 1
##     will be used for each activity.

##   - --svmEps=*epsilon*: provide the epsilon value used to determine
##     when the SVM has converged.  Defaults to 0.001
    
##   - --svmDegree=*degree*: provide the degree of the kernel (when
##     sensible) Defaults to 3

##   - --svmCoeff=*coeff*: provide the coefficient for the kernel (when
##     sensible) Defaults to 0
    
##   - --svmNu=*nu*: provide the nu value for the kernel (when sensible)
##     Defaults to 0.5

##   - --svmDataType=*float*: if the data is contains only 1 and 0 s, specify by
##     using binary. Defaults to float
    
##   - --svmCache=*cache*: provide the size of the memory cache (in MB)
##     to be used while building the SVM.  Defaults to 40

**Notes**

  - *Data filtering*: When there is a large disparity between the
    numbers of points with various activity levels present in the
    training set it is sometimes desirable to train on a more
    homogeneous data set.  This can be accomplished using filtering.
    The filtering process works by selecting a particular target
    fraction and target value.  For example, in a case where 95% of
    the original training set has activity 0 and ony 5% activity 1, we
    could filter (by randomly removing points with activity 0) so that
    30% of the data set used to build the composite has activity 1.
     

i’’’’(   t   RDConfig(   t	   listutils(   t	   Compositet   BayesCompositeN(   t	   DataUtilst	   SplitData(   t   ScreenComposite(   t   DbModule(   t	   DbConnect(   t   CompositeRun(   t   DataStructss   3.2.3i   c         C   s!   t  r t j j d |   n  d S(   s„    emits messages to _sys.stdout_
    override this in modules which import this one to redirect output

    **Arguments**

      - msg: the string to be displayed

  s   %s
N(   t   _verboset   syst   stdoutt   write(   t   msg(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   messageÜ   s    	 c         C   s   g  } x~ | D]v } |  j    r5 |  j |  d } n
 | d } |  j |  \ } } | | k r | j | | f  | j |  q q W| S(   s®   screens a number of examples past a composite

    **Arguments**

      - composite: a composite model

      - examples: a list of examples (with results) to be screened

      - badExamples: a list to which misclassified examples are appended

    **Returns**

      a list of 2-tuples containing:

        1) a vote

        2) a confidence

      these are the votes and confidence levels for **misclassified** examples  

  i’’’’(   t   GetActivityQuantBoundst   QuantizeActivityt   ClassifyExamplet   append(   t	   compositet   examplest   badExamplest   wrongt   examplet   answert   rest   conf(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   testallč   s    
c         C   s  d g } | j  d |  j  |  j d k rL | j  d |  j |  j f  n  |  j d k r{ | j  d |  j |  j f  n  |  j r | j  d |  j  n  |  j r“ | j  d  n  |  j	 rĶ | j  d  n  |  j
 d k ró | j  d	 |  j
  n  |  j r| j  d
 |  j  n  |  j r3| j  d |  j  n  |  j rL| j  d  n  t |  d  rt|  j rt| j  d  n  |  j r|  j r| j  d |  j  n  |  j r½| j  d |  j  n  |  j rÕ|  j d k rģ| j  d |  j  n  |  j r| j  d  n  |  j r@t j |  j  } |  j r`| j  d |  q`n  |  j r`| j  d |  j  n  |  j ry| j  d  n  |  j r| j  d |  j  n  |  j r²| j  d  n  |  j rÕ| j  d |  j  qÕn  |  j r4| j  d  |  j d k r| j  d |  j  n  |  j r4| j  d |  j  q4n  |  j r| j  d |  j   |  j! d k rp| j  d  q| j  d  n  |  j" ræ| j  d  |  j# d k ræ| j  d |  j#  qæn  |  j$ rŲ| j  d   n  |  j% rō| j  |  j%  n  d! j& |  S("   s	    #DOC

  t   BuildComposites   -n %dg        s   -F %.3f -v %ds&   --modelFiltFrac=%.3f --modelFiltVal=%ds
   -s -f %.3fs   -Ss   -rs   -t %.3fs   -Q "%s"s   -d %ss   -Dt   noScreens
   --noScreens   -p %ss   -N %si    s   -L %ds   -gs   -q "%s"s   --prunes   -G %ds	   --recycles   --randomDescriptors=%ds   --doSigTrees   --doKnn --knnK %dt   Tanimotos   --knnTanimotos   --knnEuclids   --doNaiveBayess   --mEstimateVal=%.3fs   --replacementSelectiont    ('   R   t   nModelst
   filterFract	   filterValt   modelFilterFract   modelFilterValt   splitRunt	   splitFract   shuffleActivitiest   randomActivitiest	   thresholdt   activityBoundst   activityBoundsValst   dbNamet   detailedRest   hasattrR   t   persistTblNamet   notet   useTreest
   limitDeptht
   lessGreedyt   qBoundsR   t   CompactListReprt   qBoundCountt   pruneItt   startAtt   recycleVarst   randomDescriptorst   useSigTreest   useKNNt	   knnNeighst   knnDistFunct   useNaiveBayest   mEstimateValt   replacementSelectiont	   tableNamet   join(   t   detailst   argst   shortBounds(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   GetCommandLine  s    	   	 	 	  	 	 	  		 	 		 	 	 	 	 	 	 			#	 	 i    c   C   %   C   s}  | j    } |  j r! |  j } n0 d d  l } | j d d  | j d d  f } t j |  g  } |  j d k r t j | d d d |  n+ |  j	 d k rŗ t j | d d d |  n  | j
   }	 |  j d k r:t j t |	  |  j d t \ }
 } g  |
 D] } |	 | ^ q} g  | D] } |	 | ^ q!} n$ g  } g  } t t |	   }
 |	 } |  j d k rot |  d	  r2|  j r2g  } |  j } x§ | D] } | } | d } d } d } xJ | r
| t |  k  r
| | | k  rż| | d <d } qĮ| d 7} qĮW| s| | d <n  | j |  qWn d  } | } t j | |  j |  j d d
 d \ }
 } g  |
 D] } | | ^ qo} | g  | D] } | | ^ q7} | } t j | d | } | j   } | j   t d  x( | D]  } t t | | | f   qčWt j | d | } | j   } | j   t d  x+ | D]  } t t | | | f   qHWn  t |  } t d |  | j   } t d | d  } | j   } xA t d t |   D]* } | | d d k rŹ| j  |  qŹqŹW|  j! d k rFt" |  j! d  } t# j$ | |  t# j$ | |  | j%   n  |  j& r^t' j'   } n t( j(   } | | _) |  j | _* |  j | _+ |  j	 | _, t |  d  rµ|  j | _- n  t |  d  rÓ|  j | _. n  | j/ |  j0 |  j1  | j2 |  j  | j   } |  j r(t |  j  d | d <n  | rT| j3 | j4    | j5 |  j6  n | j5 | j4    | j2 |  j  |  j7 d k rd |  _8 n  |  j9 råd d l: m; } m< }  |  j= g  k rÜd d l: m> }! |! j? }" n d d l: m@ }# |# jA }" | jB }$ |  j< }% | jC |  j=  | j   } |  j rFt |  j  d | d <n  | jD | | d d g | d |$ d |% d |  j7 d |  jE d |  jF d d d |" d |  j= d |  jG d  |  jH d! | d" |  j8 d# |  jI d$ |  jJ d% |  jK d t n|  jL r9d d& l: m; } d d' l: mM }& |& jN }" | jB }$ | j   } |  j rOt |  j  d | d <n  t |  d(  rj|  jO }' n d  }' t |  d)  r|  jP }( n d }( t |  d*  r¬|  jQ }) n tR }) | jD | | d d g | d |$ d |  j7 d d d |" d  |  jH d! | d" |  j8 d# |  jI d$ |  jJ d% |  jK d+ |' d) |( d, |) d t nE|  jS r	d d& lT m; } d d- lT mU }* | jB }$ d }+ |  jV d. k r|* jW }+ n- |  jV d/ k r§|* jX }+ n d s¹tY d0   | jD | | d d g | d |$ d |  j7 d d d1 |  jZ d" |  j8 d2 |+ nx|  j[ s	|  j\ r6
d d& l] m; } | jB }$ t |  d3  oF	|  j\ s©	| jD | | d d g | d |$ d |  j7 d d d |  j= d" |  j8 d# |  jI d4 |  j^ d t 	q~
t |  d)  rÄ	|  jP }( n d }( | jD | | d d g | d |$ d |  j7 d d d |  j= d4 |  j^ d5 t_ d) |( d" |  j8 d# |  jI d t nH d d& l` m; } | jB }$ | jD | | d g | d |  j7 d |$ d d | ja   | jb   | jc   \ }, } }- td je |  } td je |-  }- | j4   | _f x. tg t |,   D] } |, | jh | jf  qē
W| |- }. ti |.  ti |  }/ |- |/ }0 |0 | }0 td jj |0 |0  }0 ti |0  ti |  }1 t d6 d7 |/ d7 |1 f  |  j& r| jk | d8 d n  | jl   | rĄ| jm |  jn  n  to jp t# jq |   |  _r g  }2 |  js ržt |  d9  s|  jt rž|  j rt d:  tu | | |2  }3 t d; t |3  d7 tv t |3   tv t |   f  tv t |3   t |  tw _x qžt d<  tu | |	 |2  }3 t d; t |3  d7 tv t |3   tv t |	   f  tv t |3   t |	  tw _y n  |  js rØt d=  tz j{ t | j     | | | d |  j|  }4 |4 \ }5 }6 }7 }8 }9 }: }; t |	  }< |5 |6 }= tv |6  |= tw _y |8 tw _} |9 tw _~ t |;  tw _ |= |< }> |> d k rŠtv |>  |< tw _ n  |  j rØt d>  tz j{ t t |   | | | d |  j|  }4 |4 \ }5 }6 }7 }8 }9 }: }; t |  }< |5 |6 }= tv |6  |= tw _x |8 tw _ |9 tw _ t |;  tw _ |= |< }> |> d k r„tv |>  |< tw _ q„qØn  |  j ró|  j rót d? |  j |  j f  |  j d@ |  j dA |  j  n  |  j d k rot" |  j dB  }? xK tg t |2   D]7 } |2 | }@ |3 | }A dC |@ |A f }B |? j |B  q'W|? j%   n  | jl   | S(D   Ni’’’’i    g    .Ai   t   shufflet
   runDetailst   silentg        R,   t   indicesOnlyt   boundss   Result Counts in training set:s   Result Counts in test set:s   Training with %d examplest    s   wb+R#   R$   (   t   CrossValidatet	   PruneTree(   t   BuildQuantTree(   t   ID3t   nPossibleValst   buildDrivert   prunert   nTriesR9   R5   t   needsQuantizationt   treeBuildert   nQuantBoundsR:   t   maxDeptht   progressCallbackt   holdOutFracRC   R;   R<   (   RP   (   t   BuildSigTreet   sigTreeBiasListt   useCMIMt   allowCollectionst   biasListt   allowCollection(   t   DistFunctionst	   EuclideanR    s   Bad KNN distance metric valuet   numNeight   distFunct   useSigBayesRB   t   useSigss>   # Overall Average Error: %%% 5.2f, Average Deviation: %%% 6.2fg      Y@t   verboseR   s   Testing all hold-out exampless)   %d examples (%% %5.2f) were misclassifieds   Testing all exampless   
Entire data set:s   
Hold-out data:s   Updating results table %s:%st   dbt   tables   w+s   %s	%s
(   t   GetNPtst
   lockRandomt
   randomSeedt   randomt   randintR   t   InitRandomNumbersR)   t   RandomizeActivitiesR*   t   GetNamedDataR'   R   t   SplitIndicest   lenR(   R   t   rangeR#   R0   R,   R   t   Nonet
   FilterDataR$   t   CountResultst   keyst   sortR   t   strt   GetNVarst   GetNPossibleValst   removet   pickleDataFileNamet   opent   cPicklet   dumpt   closet
   bayesModelR   R   t   _randomSeedt
   _splitFract   _shuffleActivitiest   _randomizeActivitiest   _filterFract
   _filterValt   SetModelFilterDataR%   R&   t   SetActivityQuantBoundst   SetInputOrdert   GetVarNamest   SetDescriptorNamest
   _descNamesR"   t   internalHoldoutFracR3   t   rdkit.ML.DecTreeRP   RQ   R6   RR   t   QuantTreeBootRS   t   ID3Boott   CrossValidationDrivert   SetQuantBoundst   GrowR9   R5   R:   R4   RC   R;   R<   R=   R^   t   SigTreeBuilderR_   R`   Ra   t   FalseR>   t   rdkit.ML.KNNRd   R@   t   EuclideanDistt   TanimotoDistt   AssertionErrorR?   RA   Rh   t   rdkit.ML.NaiveBayesRB   t   Truet   rdkit.ML.Neuralt   AverageErrorst
   SortModelst
   GetAllDatat   numpyt   arrayt	   _varNamest   xranget	   NameModelt   sumt   sqrtt   Traint   ClearModelExamplest   Picklet   outNameR   t   binaryHoldert   dumpst   modelR/   R   R   t   floatt   _runDetailst   holdout_errort   overall_errorR   t   ShowVoteResultsR+   t   overall_correct_conft   overall_incorrect_conft   reprt   overall_result_matrixt   overall_fraction_droppedt   holdout_correct_conft   holdout_incorrect_conft   holdout_result_matrixt   holdout_fraction_droppedR1   R.   t   Storet   badNameR   (C   RF   t   dataR\   t   saveItt   setDescNamest	   nExamplest   seedRp   t   testExamplest   namedExamplest   trainIdxt   testIdxt   xt   trainExamplest	   tExamplesRN   t   ptt   actt   placedt   boundt   tempt   tmpt   countst   kst   kt   nVarst   attrsRT   t   it   pickleDataFileR   RP   RQ   RR   t   builderRS   t   driverRV   R^   Rb   R`   Ra   Rd   t   dfunct	   modelListt   avgErrst   weightedErrst
   averageErrt   devst   avgDevR   R   t   resTupt   nGoodt   nBadt   nSkipt   avgGoodt   avgBadt   avgSkipt   voteTabt   nPtst   nClasst   nRejt   badFilet   ext   votet   outStr(    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt	   RunOnDatah  s   	$ 	

	!



!																												
								"




	
$	
+"
+"	

		
	

		



c      	   C   s8  t  j   |  _ |  j j   } |  j d k r= | d |  _ n  |  j sy |  j g  k rg t j	 |  } qt j
 |  } n |  j s |  j r² | |  _ |  j d d d t j  } na |  j g  k sĖ |  j rć | |  _ |  j   } n0 t j |  j | d |  j d |  j d |  j } t |  | d	 | d
 | d | } | S(   sĻ   does the actual work of building a composite model

    **Arguments**

      - details:  a _CompositeRun.CompositeRun_ object containing details
        (options, parameters, etc.) about the run

      - progressCallback: (optional) a function which is called with a single
        argument (the number of models built so far) after each model is built.

      - saveIt: (optional) if this is nonzero, the resulting model will be pickled
        and dumped to the filename specified in _details.outName_

      - setDescNames: (optional) if nonzero, the composite's _SetInputOrder()_ method
        will be called using the results of the data set's _GetVarNames()_ method;
        it is assumed that the details object has a _descNames attribute which
        is passed to the composites _SetDescriptorNames()_ method.  Otherwise
        (the default), _SetDescriptorNames()_ gets the results of _GetVarNames()_.

    **Returns**

      the composite model constructed


  RO   s   .pklt	   pickleColi    t   pickleClasst	   quantNamet   usert   passwordR\   RÅ   RĘ   (   t   timet   asctimet   rundateRD   t   stripR°   R.   R6   R   t   TextFileToDatat   BuildQuantDataSetR=   Rh   t
   GetDataSetR
   t   ExplicitBitVectR3   t   DBToQuantDatat
   qTableNamet   dbUsert
   dbPasswordRõ   (   RF   R\   RÅ   RĘ   t   fNameRÄ   R   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   RunItæ  s&    			c         C   s8   d t  GH|  r4 d d l } d GHd j | j  GHn  d S(   s    prints the version number

  s$   This is BuildComposite.py version %si’’’’Ns   command line was:R!   (   t   __VERSION_STRINGR   RE   t   argv(   t   includeArgsR   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   ShowVersionņ  s
    	c          C   s"   d d l  }  t GH|  j d  d S(   sM    provides a list of arguments for when this is used from the command line

  i’’’’N(   R   t   __doc__t   exit(   R   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   Usageü  s    c         C   s"   |  d k r t }  n  t j |   S(   s    initializes a details object with default values

      **Arguments**

        - details:  (optional) a _CompositeRun.CompositeRun_ object.
          If this is not provided, the global _runDetails will be used.

      **Returns**

        the initialized _CompositeRun_ object.


  N(   Rx   Rµ   R	   t   SetDefaults(   RK   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyR    s     	c         C   s	  d d l  } | j  t j d d d d d d d	 d
 d d d d d d d d d d d d d g  \ } } d |  _ x| D]}\ } } | d k r” t |  |  _ qw | d k r¹ | |  _ qw | d k rŃ | |  _ qw | d k r.t |  } t	 |  t	 g   t	 dI  g k st
 d   | |  _ | |  _ qw | d k rF| |  _ qw | d k r^| |  _ qw | d  k rvd |  _ qw | d! k rd |  _ qw | d" k r¦| |  _ qw | d# k r¾d |  _ qw | d$ k rÖd |  _ qw | d% k rōt |  |  _ qw | d& k rt |  |  _ qw | d' k r0t |  |  _ qw | d( k rHd |  _ qw | d) k r`d |  _ qw | d* k r~t |  |  _ qw | d+ k r| |  _ qw | d, k r®d |  _ qw | d- k rĢt |  |  _ qw | d. k räd |  _ qw | d/ k rt |  |  _ qw | d0 k r_t |  } t	 |  t	 g   t	 dJ  g k sJt
 d1   | |  _  | |  _! qw | d2 k rt"   t j# d  qw | d3 k r t |  |  _$ qw | d4 k r¾t |  |  _% qw | d5 k rÜt |  |  _& qw | d6 k rōd |  _' qw | d7 k rd |  _ qw | d8 k r$d |  _( qw | d9 k rBt |  |  _) qw | d: k rld |  _* d |  _ d |  _+ qw | d; k rt |  |  _, qw | d< k r¢d= |  _- qw | d> k rŗd? |  _- qw | d@ k rķd |  _* d |  _ d |  _+ d |  _. qw | dA k rt/ |  _0 qw | dB k r8d |  _+ d |  _* d |  _ d |  _1 qw | dC k rkd |  _1 d |  _+ d |  _* d |  _ qw | dD k rt |  |  _2 qw | dE k r§t |  |  _3 qw | dF k ræd |  _4 qw | dG k r×d |  _5 qw | dH k rķt6   qw t6   qw W| d |  _7 d S(K   s    parses command line arguments and updates _runDetails_

      **Arguments**

        - runDetails:  a _CompositeRun.CompositeRun_ object.

  i’’’’Ni   s(   P:o:n:p:b:sf:F:v:hlgd:rSTt:BQ:q:DVG:N:L:s   nRuns=t   prunet   profiles   seed=R   s   modelFiltFrac=s   modelFiltVal=t   recycles   randomDescriptors=t   doKnns   knnK=t   knnTanimotot	   knnEuclidt	   doSigTreeRa   t   doNaiveBayess   mEstimateVal=t
   doSigBayesRC   i    s   -ns   -Ns   -os   -Qs4   bad argument type for -Q, specify a list as a strings   -ps   -Ps   -rs   -Ss   -bs   -Bs   -ss   -fs   -Fs   -vs   -ls   -gs   -Gs   -ds   -Ts   -ts   -Ds   -Ls   -qs4   bad argument type for -q, specify a list as a strings   -Vs   --nRunss   --modelFiltFracs   --modelFiltVals   --prunes	   --profiles	   --recycles   --randomDescriptorss   --doKnns   --knnKs   --knnTanimotoR    s   --knnEuclidRe   s   --doSigTrees   --allowCollectionss   --doNaiveBayess   --doSigBayess   --mEstimateVals   --seeds
   --noScreens   --replacementSelections   -h(    (    (8   t   getoptR   R
  t	   profileItt   intR"   R2   R°   t   evalt   typeR   R,   R-   R1   R   R*   R)   RĆ   t   bayesModelsR'   R“   R(   R#   R$   Rn   R5   R:   R.   R3   R+   R/   R4   R8   R6   R  R  t   nRunsR%   R&   R9   R;   R<   R>   RA   R?   R@   R=   R”   Ra   Rh   RB   Ro   R   RC   R  RD   (   RK   R  RG   t   extrat   argt   valR6   (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt	   ParseArgs  sņ    		0	0												)
t   __main__i   R!   R  sT   ---------------------------------
	Doing %d of %d
---------------------------------
s   prof.datRū   t   callsi   (:   R  t   rdkitR    t   rdkit.utilsR   t   rdkit.ML.CompositeR   R   R¦   t   matht   rdkit.ML.DataR   R   t   rdkit.MLR   t   rdkit.DbaseR   t   rdkit.Dbase.DbConnectionR   R	   R   R   Rū   R
   Rµ   R	  R   R   R   RI   Rx   Rõ   R  R  R  R  R$  t   __name__Rv   R
  RE   t   cmdR   Rw   RŪ   t   stderrR   R  t   hotshott   hotshot.statst   Profilet   proft   runcallt   statst   loadt
   strip_dirst
   sort_statst   print_stats(    (    (    sY   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/python2.7/site-packages/rdkit/ML/BuildComposite.pyt   <module>Č   sZ   $	#	]’ X3
		Å


!	
