# total_score changes when decomposing bb hbonds ref2015

3 posts / 0 new
total_score changes when decomposing bb hbonds ref2015
#1

Hi. Really sorry to disturb you but I don't understand some behaviour regarding scoring.
I will first describe the issue and paste the code.  Originally I was using

score_function = ScoreFunctionFactory.create_score_function('ref2015')
total_score = score_function(pose)
total_score_energy = pose.energies().total_energy()
per_residue = pd.DataFrame(pose.energies().residue_total_energies_array())
sum_per_residue = sum(per_residue.total_score)

sr_bb = pose.energies().total_energies()[pr.rosetta.core.scoring.ScoreType.hbond_sr_bb]
lr_bb = pose.energies().total_energies()[pr.rosetta.core.scoring.ScoreType.hbond_lr_bb]

However, I needed to work with residue energies so I used the following energy options:

emo = methods.EnergyMethodOptions()
emo.hbond_options().decompose_bb_hb_into_pair_energies(True)
score_function = ScoreFunctionFactory.create_score_function('ref2015')
score_function.set_energy_method_options(emo)

em_total_score = score_function(pose)
em_total_score_energy = pose.energies().total_energy()
per_residue = pd.DataFrame(pose.energies().residue_total_energies_array())
em_sum_per_residue = sum(per_residue.total_score)

em_sr_bb = pose.energies().total_energies()[pr.rosetta.core.scoring.ScoreType.hbond_sr_bb]
em_lr_bb = pose.energies().total_energies()[pr.rosetta.core.scoring.ScoreType.hbond_lr_bb]

If I compare all the values I get the following

total_score = total_score_energy != sum_per_residue #as expected since sr_bb and lr_bb are non zero

em_total_score = em_total_score_energy = em_sum_per_resdiue #as expected because now all residues have the bb component

total_score != em_total_score and total_score_energy != em_total_score_energy # HOWEVER, I was NOT expecting this. since the total_score already has the bb hbond component I was not expecting the total score to change (from -274 to -359). Furthermore sr_bb = em_sr_bb and lr_bb = em_lr_bb

Could you help me explain why the total_score changes when I apply the energy option on pose.energies().total_energy()?

Category:
Post Situation:
Mon, 2022-10-31 15:40
Liviu Copoiu

My guess is that the default-constructed EnergyMethodOptions object is slightly different than the one used with ref2015.

Instead of creating a new EnergyMethodOptions object, I'd recommend getting the one used with ref2015 by calling score_function.energy_method_options().clone() You can then modify that object and re-set it into the ScoreFunction. (Note that you should clone() and re-set, rather than attempting to modify in-place. That's not supported by the C++ interface, and the set_energy_method_options() function has extra code needed to re-initialize the various energy terms for the new setting.)

Mon, 2022-10-31 15:54
rmoretti

Worked like a charm. All good now.

Mon, 2022-10-31 16:03
Liviu Copoiu