You are here

hbond_sr_bb, hbond_lr_bb, fa_intra_rep energies from ScoreFunction()

5 posts / 0 new
Last post
hbond_sr_bb, hbond_lr_bb, fa_intra_rep energies from ScoreFunction()
#1

I would like to compute the whole energy of a pose object by accumulating the individual energy terms. 

I have a POSE object, and a scoring fucnction called SCOREFXN. What i do is the following: 

for comb in itertools.combinations(range(1, POSE.size() + 1), 2):  # Two body energies
    SCOREFXN.eval_cd_2b(POSE.residue(comb[0]), POSE.residue(comb[1]), POSE, energy_vector)
    SCOREFXN.eval_ci_2b(POSE.residue(comb[0]), POSE.residue(comb[1]), POSE, energy_vector)
for idx in range(1, POSE.size() + 1):  # One body energies
    SCOREFXN.eval_intrares_energy(POSE.residue(idx), POSE, energy_vector)
    SCOREFXN.eval_ci_1b(POSE.residue(idx), POSE, energy_vector)
    SCOREFXN.eval_cd_1b(POSE.residue(idx), POSE, energy_vector)

Using the method i am able to calculate most of the energies for the strucure. 

If i calculate the whol energy with 

print(SCOREFXN.show(POSE))

I see that hbond_sr_bb and hbond_lr_bb values are 0. Why? How can i calculate these?

I also see that the fa_intra_rep energy term is mush lower if i calculate it with  SCOREFXN.eval_intrares_energy. How can i calculate it correctly?

SCOREFXN.eval_intrares_energy returns ScoreType.fa_intra_rep 0.9421216272875226
While SCOREFXN.show(POSE) returns 413.928

I calculate all of the energies with weight = 1

Thanks a lot!

Category: 
Post Situation: 
Tue, 2017-04-18 04:46
gerdos

For hbond_sr_bb and hbond_lr_bb, this is probably due to a speed optimization that occurs with backbone hydrogen bonds. If you want to get an accurate breakdown of the hydrogen bonds, you would want to set decompose_bb_hb_into_pair_energies in the energy method option. Something like the following should work in PyRosetta (I think - this is an untested translation of C++ code.)

emopts = core.scoring.methods.EnergyMethodOptions( scorefxn.energy_method_options() ) # make a copy
emopts.hbond_options().decompose_bb_hb_into_pair_energies( True )
scorefxn.set_energy_method_options( emopts )

 

For the fa_intra_rep term, my initial thought would be that it's a weighting issue, but if you've set all the weights to 1, that shouldn't be an issue (you'd probably also see it with other terms as well.) 

The one possiblity is that there's something going on with the setup that's missing with your system. I'd recommend doing a regular scoring call with the scorefunction *prior* to doing the per-term scoring, to make sure that everything is set up appropriately. The other issue I notice is that the fa_intra_rep eval_intrares_energy() currently overwrites rather than sums into energy_vector, so I think you may be getting the value for just the last residue in the structure, rather than the sum of everything.  

Tue, 2017-04-18 11:07
rmoretti

HBonds works like a charm, thanks a lot!

Also you were right about the fa_intra_rep as well, the problem was that it does not accumulate. Why is this? Every other energy term accumulates, but not fa_intra_rep? Is there a workaround to make it a sum?

On the API page:

eval_intrares_energy(...)  ... Accumulates for rsd the unweighted intra-residue..

eval_ci_intrares_energy(...) ... Accumulates the unweighted intra-residue one body energies ..

But both seems to overwrite, not acumulate. 

Also i see that fa_intra_rep is a part of the ci_2b_types() function, however it is not calculated with eval_ci_2b. Why?

Wed, 2017-04-19 01:21
gerdos

The fact that it doesn't accumulate is probably a bug - I'm currently in discussions with other Rosetta developers as to what the correct behavior of this function is. (In the C++ version of Rosetta, the distinction between accumulating and overwriting never comes up.) Thanks for pointing out the issue.

fa_intra_rep is implemented as a 2-body EnergyMethod because it's actually implemented by the same EnergyMethod object which evaluates fa_rep (and fa_atr), and those have to be a 2-body energies. It's not evaluated when you calculate 2-body energies with eval_vci_2b() because fa_intra_rep is *defined* to be the 1-body portion of the fa_rep term. (It's evaluated on a per-residue basis. If you rolled it into the pairwise calculation, you'd overcount when you summed across all pairs.) The eval_intrares_energy() method is actually specific to the 1-body portions of the TwoBodyEnergy method objects. OneBodyEnergy method objects actually score residues through the residue_energy() method.  It will be calculated if you called the ScoreFunction.eval_intrares_energy() method.

Thu, 2017-04-20 13:51
rmoretti

Thanks a lot again! Your responses really helped me to gain a deeper understanding of PyRosetta!

I ll mark this question as solved, million thanks!

Fri, 2017-04-21 01:53
gerdos