Altering Score/EMapVector

Member Site Forums PyRosetta PyRosetta – General Altering Score/EMapVector

Viewing 1 reply thread
  • Author
    • #1146


        I would like to alter the energies of some residues in a pose after applying the scoring function. I want to do something along the lines:

        pose.energies().residue_total_energies(‘some resi’)[fa_atr] = ‘some value’

        Obviously this is not directly possible, since:

        “TypeError: ‘EMapVector’ object does not support item assignment”

        Is there any way to tinker around with an ‘EMapVector’ object? I was thinking maybe one can generate a new ‘EMapVector’ fill it with the old values (plus the altering of some) and then assign it (maybe via ‘EMapVector.assign(EMapVector)’) to the old object.

        However, I did not get far with this strategy, so maybe it’s bollocks. Any help/suggestion much appreciated!


      • #6590

          Why do you want to assign values to a list of scores, or for what purpose do the scores need to be modified? Rosetta tells you what the scores of the pose are; you can’t tell it what the scores are because it is the thing that does the scoring.

        • #6591

            Another thing to point out is that the Energies object in a pose is really just a storage container. Anything that causes that residue to move (or even residues which are in energetic contact with that residue) will invalidate that cached value, and cause it to be recalculated, ignoring and discarding whatever value is there currently. Packing and minimization have their own energy caching mechanisms, which I believe are distinct from the Energies object, so they won’t be affected by changing that value. So even if you could change the value, it would quickly be invalidated, and really wouldn’t affect most of Rosetta’s internal mechanisms.

            If you want to adjust the results of an energy calculation, the best way to go about doing it is to define your own custom energy term. There’s a way to do this through the Python interface, at least with PyRosetta 2.011 (“Examples can be found in test/*Subclassing*”)

          • #6597

              well, i understand your point but essentially i want to weight the energies of some residues in a model stronger than others. but i only know which residues are affected after repacking of the side chains. i could just read out the energies and do all the calculations outside of the pose but after the weighting i want to pass the pose to an mc object. thus, i would like to alter the energies inside the pose directly. i do not care if the energies/scores change back to ‘normal’ again later. and i do not think a custom energy term would help me much here, because that would apply to all and not only a few selected residues in a pose, wouldn’t it? i hope all this does not sound too garbled. anyway, thanks for your help!

            • #6599

                What you want to do makes sense now.

                Monte Carlo will re-score the Pose if it detects the scores are out-of-date, so you cannot do it in the way you envision. You might get it to work if you altered a lot of the Energies and MC object, but it’s dangerous.

                There are two options I can think of: First, do your MC control without the Monte Carlo object. Basic MC control is not very hard to code yourself into your cycles-loop. This will let you alter scores as you please.

                Second, you could detect the whatever-you’re-detecting and add constraints to alter the scorefunction. Constraints are evaluated on a per-residue basis as you seem to need. Don’t forget to dump the previous cycle’s constraints.

              • #6601

                  That’s the benefit of writing a custom energy term – you can check the residues you’re scoring against whatever list you’re using, and only put in non-zero energies for those residues you want to upweight. (i.e. if the residue or residue pair isn’t on your list, just give a value of zero for that residue/residue pair, and let the regular energy term handle the non-unweighted value). You can also incorporate the detection logic for which residues are on the list in the scoreterm object itself, automating the detection on repacking.

                  I’m not quite sure what you’re trying to achieve, but it sounds similar to protocols.enzdes.ProteinLigandInterfaceUpweighter, which specifically upweights the (packer) interactions between a ligand and surrounding residues. It uses a core.pack.task.IGEdgeReweighter and core.pack.task.IGEdgeReweightContainer (IG = interaction graph) to do the job. Specifically, it looks like it uses a protocols.toolbox.IGLigandDesignEdgeUpweighter, but there is also a protocols.toolbox.ResidueGroupIGEdgeUpweighter for increasing the weights between groups of residues. Best I can tell, though, those are for increasing the weights on all the scoreterms, and only work with the packer. I’m not sure if there is a similar general solution for up-weighting specific residue interactions in all instances

                  I can’t tell if it’s in your version of PyRosetta, but in the C++ version, the protocols::moves::MonteCarlo object has two boltzmann() member functions, one which takes a pose, and another which just takes a score delta. You could possibly use the latter instead of the former, and then keep track of the accepted Poses separately. That way you can do whatever score manipulation you need prior to passing it to the MonteCarlo object. I don’t know how that function version is exposed under the PyRosetta interface, though.

              Viewing 1 reply thread
              • You must be logged in to reply to this topic.