You are here

Using a custom scoring method in a high resolution refinement

2 posts / 0 new
Last post
Using a custom scoring method in a high resolution refinement


I am using pyRosetta and am trying to add my own custom scoring method into an energy function and then use that energy function in a refinement. When I run refinement with a scoring function that has only my custom scoring method both the "MinMover" and "PackRotamersMover" do not minimise or at all change the pose. Why is this? Have I done something wrong in writing up my custom scoring method? I have attached an example of the energy method I am trying to define as well as the refinement file (which is based on the pyRosetta demo file) I have been using.

Thanks in advance.

This is an example code of how I defined my custom energy method:

import rosetta.core.scoring.methods as methods
import rosetta

class testScoreMethod(methods.WholeStructureEnergy):
    def __init__(self):
        methods.WholeStructureEnergy.__init__(self, self.creator())

    def finalize_total_energy(self, pose, efunc, emap):

        #Calculate what score should be. Below is just demo scoring method that should force the protein to crunch at position 0,0,0.
        score = 0
        for i in range (1, pose.total_residue()):
            pos = pose.residue(i).xyz('CA')
            score += abs(pos[0]) + abs(pos[1]) + abs(pos[2])

        emap.set(self.scoreType, score)

testScoreMethod.py_.txt639 bytes
TestScript.py_.txt1.6 KB
Post Situation: 
Sun, 2015-10-25 22:28

To make packing and minimizing computationally feasible, the two algorithms use different functions in the energy interface to compute the energy, which are different from the functions which are used to do plain scoring.

In particular, packing requires a pairwise-decomposable energy term. Non-pairwise decomposable terms can be in the energy function, but they won't contribute to the rotamer optimization. In particular, you would need to use one of ContextDependentOneBodyEnergy, ContextIndependentOneBodyEnergy, ContextDependentTwoBodyEnergy, or ContextIndependentTwoBodyEnergy instead of the WholeStructureEnergy as a base class. Details on the differences can be found in the Leaver-Fay et al. Methods in Enzymology paper: -- Basically, if your score term only depends on one residue (even if there are multiple atoms within the same residue), it's a OneBody term, and if it's a pair of residues it's a TwoBody term. More than that and you're back to WholeStructure energies and difficulties with packing. ContexDependent/ContextIndependent has to do with if you use the neighbor graph or not in your calculations - you're probably ContextIndependant. A final complication is that TwoBody energies come in short range and long range versions. The standard, short range versions are ones which fall to zero outside a certain distance (typically 6 Ang or so). If you don't drop to zero outside a certain distance, you need the long range versions, and things get more complex.

Which functions you would need to overload depend on which version of the term you need to use. For example, for TwoBodyEnergies, the residue_pair_energy() method is the main point of customization, but there are other functions which you might want to change, depending how you want to implement things.

For minimization, things become more complicated, as in addition to the score, you also have to implement function derivatives. We use the scheme of Abe, Braun, Noguti and Go (1984)  Computers & Chemistry 8(4) pp. 239-247 for the derivatives, which is more complicated than a simple partial derivative over X,Y and Z. If this is not implemented, the derivatives are cnsidered zero and the minimizer doesn't change things.

Generally, it's best to take a look at the C++ code of a score term that's similar to the one you want to implement, and then model your terms behavior on that implementation. There's a bunch of moving parts that are poorly documented at best. 


Mon, 2015-10-26 13:57