Package schrodinger :: Package application :: Package glide :: Package packages :: Module sp_filter :: Class CutoffCalculator
[hide private]
[frames] | no frames]

Class CutoffCalculator

object --+
         |
        CutoffCalculator
Known Subclasses:

A stateful cutoff calculator. The client interacts with it by checking wheter a score meets the cutoff. Each such transaction has the side effect of adjusting the cutoff in order to keep the acceptance rate close to the target rate.

The calculator keeps a "current cutoff", meaning the one that was used to test the last score to be seen, and a "next cutoff", which is the latest cutoff to be computed, to be used for testing the next score.

Instance Methods [hide private]
 
__init__(self, target_rate=0.1, induction_period=30, move_size=10.0, csvwriter=None)
x.__init__(...) initializes x; see help(type(x)) for signature
{str: float}
getCutoffs(self)
Return a dict with the current and next cutoff.
 
_updateCutoff(self, pose)
Update the cutoff given a pose.
 
computeInitialCutoff(self, tolerance=1.5, max_rate=0.99)
Using the statistical distribution of the scores collected so far, compute a cutoff that should accept the target rate, times a tolerance factor.
{str: float}
addPoses(self, poses)
Add multiple poses at once, and return the current and next cutoffs.
list of float
getScores(self)
Return a list with all the scores that have been processed by the calculator.
 
addPoseAndUpdateCutoff(self, pose)
Add a pose to the calculator and update the new cutoff.
 
_addScore(self, score)
Add a score to the calculator without updating the cutoff.
 
_sleep(self, t)
bool
_checkScore(self, score)
Test a pose to see if it passes the filters, WITHOUT updating the cutoff.
bool
checkScore(self, score, title)
Test a pose to see if it passes the filters and update the cutoff as a side effect.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, target_rate=0.1, induction_period=30, move_size=10.0, csvwriter=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • target_rate (float) - desired acceptance rate
  • induction_period (int) - number of poses to accept unconditionally to collect statistics before enabling filter
  • move_size (float) - how much can the cutoff be adjusted after each ligand
  • csvwriter (csv.writer or NoneType) - optional writer object to write the score and current cutoff for each ligand
Overrides: object.__init__

getCutoffs(self)

 

Return a dict with the current and next cutoff.

Returns: {str: float}
dict with 'cutoff' and 'next_cutoff' keys

_updateCutoff(self, pose)

 

Update the cutoff given a pose.

Parameters:
  • pose (Pose) - current pose

computeInitialCutoff(self, tolerance=1.5, max_rate=0.99)

 

Using the statistical distribution of the scores collected so far, compute a cutoff that should accept the target rate, times a tolerance factor. We choose to err on the generous side for the initial cutoff because the guess is not perfect, and we would rather have false positives than false negatives early in the job.

The initial cutoff is based on fitting the scores to a normal distribution and using the inverse cumulative distribution function to find the cutoff covering the desired fraction, capped at 'max_rate' to prevent the cutoff from going all the way to +inf when self.target_rate * tolerance >= 1.0.

addPoses(self, poses)

 

Add multiple poses at once, and return the current and next cutoffs. This strange combination is meant to minimize the number of transactions when running in client-server mode.

Parameters:
  • poses (list of Pose)
Returns: {str: float}
dict with 'cutoff' and 'next_cutoff' keys

getScores(self)

 

Return a list with all the scores that have been processed by the calculator.

Returns: list of float
scores

addPoseAndUpdateCutoff(self, pose)

 

Add a pose to the calculator and update the new cutoff.

Parameters:
  • pose (Pose) - current pose

_addScore(self, score)

 

Add a score to the calculator without updating the cutoff.

Parameters:
  • score (float) - score of current pose

_checkScore(self, score)

 

Test a pose to see if it passes the filters, WITHOUT updating the cutoff.

Parameters:
  • score (float) - score of current pose
Returns: bool
True if score meets the cutoff, False otherwise

checkScore(self, score, title)

 

Test a pose to see if it passes the filters and update the cutoff as a side effect.

Parameters:
  • score (float) - score of current pose
  • title (str) - pose title (for logging purposes)
Returns: bool
True if score meets the cutoff, False otherwise