From c41e3f4e20ded2169d515526aeb5351885fb307b Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Wed, 18 Jan 2017 07:54:58 +0100 Subject: [PATCH] Implement a ToFrameResidue function for Rotamers --- sidechain/doc/rotamer.rst | 23 ++++++++++++++++++++-- sidechain/pymod/_reconstruct_sidechains.py | 3 +-- sidechain/pymod/export_rotamer.cc | 2 ++ sidechain/src/rotamer.cc | 18 +++++++++++++++++ sidechain/src/rotamer.hh | 5 +++++ sidechain/src/sidechain_reconstructor.cc | 9 ++------- 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/sidechain/doc/rotamer.rst b/sidechain/doc/rotamer.rst index b8dd468e..de974604 100644 --- a/sidechain/doc/rotamer.rst +++ b/sidechain/doc/rotamer.rst @@ -184,6 +184,15 @@ Rotamers :raises: :exc:`~exceptions.RuntimeError` if *res_idx* is invalid + .. method:: ToFrameResidue(res_idx) + + Generates and returns a :class:`FrameResidue` based on the internal + particles. + + :param res_idx: Idx passed over to :class:`FrameResidue` constructor + :type res_idx: :class:`int` + + :returns: The constructed :class:`FrameResidue` .. method:: GetInternalEnergyPrefactor() @@ -331,6 +340,16 @@ Rotamers :raises: :exc:`~exceptions.RuntimeError` if *res_idx* is invalid + .. method:: ToFrameResidue(res_idx) + + Generates and returns a :class:`FrameResidue` based on the internal + particles of the active subrotamer. + + :param res_idx: Idx passed over to :class:`FrameResidue` constructor + :type res_idx: :class:`int` + + :returns: The constructed :class:`FrameResidue` + .. method:: GetSubrotamerDefinition(index) :param index: Index of subrotamer @@ -441,8 +460,8 @@ Rotamers The provided **idx** relates to the subrotamer definitions added at the rotamer buildup. This idx controls which subrotamer is used when - :func:`ApplyOnResidue` gets called. By default, the value is 0 - => first added subrotamer definition gets used. + :func:`ApplyOnResidue` of :func:`ToFrameResidue` gets called. + By default, the value is 0 => first added subrotamer definition gets used. :param idx: Index of subrotamer definition applied on residues diff --git a/sidechain/pymod/_reconstruct_sidechains.py b/sidechain/pymod/_reconstruct_sidechains.py index ac41d155..c6b49bf0 100644 --- a/sidechain/pymod/_reconstruct_sidechains.py +++ b/sidechain/pymod/_reconstruct_sidechains.py @@ -184,8 +184,7 @@ def _AddCysteinFrameResidues(frame_residues, incomplete_sidechains, # handle cysteins participating in a disulfid bond for cys_idx, cys_rot in zip(disulfid_indices, disulfid_rotamers): # add FrameResidue - frame_residue = sidechain.FrameResidue([cys_rot[0]], cys_idx) - frame_residues.append(frame_residue) + frame_residues.append(cys_rot.ToFrameResidue(cys_idx)) # set the position in the proteins residues cys_rot.ApplyOnResidue(res_list[cys_idx].handle, consider_hydrogens=False) diff --git a/sidechain/pymod/export_rotamer.cc b/sidechain/pymod/export_rotamer.cc index 47f99e55..f2bf1e87 100644 --- a/sidechain/pymod/export_rotamer.cc +++ b/sidechain/pymod/export_rotamer.cc @@ -157,6 +157,7 @@ void export_Rotamer() (arg("res"), arg("consider_hydrogens")=false, arg("new_res_name")="")) .def("ApplyOnResidue", WrapRRMApplyOnResAA, (arg("all_atom"), arg("res_idx"))) + .def("ToFrameResidue", &RRMRotamer::ToFrameResidue, (arg("res_idx"))) .def("GetInternalEnergyPrefactor",&RRMRotamer::GetInternalEnergyPrefactor) .def("GetInternalEnergy",&RRMRotamer::GetInternalEnergy) .def("GetFrameEnergy",&RRMRotamer::GetFrameEnergy) @@ -184,6 +185,7 @@ void export_Rotamer() (arg("res"), arg("consider_hydrogens")=false, arg("new_res_name")="")) .def("ApplyOnResidue", WrapFRMApplyOnResAA, (arg("all_atom"), arg("res_idx"))) + .def("ToFrameResidue", &FRMRotamer::ToFrameResidue, (arg("res_idx"))) .def("GetInternalEnergyPrefactor",&FRMRotamer::GetInternalEnergyPrefactor) .def("GetInternalEnergy",&FRMRotamer::GetInternalEnergy) .def("GetFrameEnergy",&GetFRMFrameEnergyOne) diff --git a/sidechain/src/rotamer.cc b/sidechain/src/rotamer.cc index 3cf238f3..4143480d 100644 --- a/sidechain/src/rotamer.cc +++ b/sidechain/src/rotamer.cc @@ -55,6 +55,12 @@ void RRMRotamer::ApplyOnResidue(loop::AllAtomPositions& all_atom, } } +FrameResiduePtr RRMRotamer::ToFrameResidue(uint res_idx) const { + + FrameResiduePtr frame_res(new FrameResidue(particles_, res_idx)); + return frame_res; +} + FRMRotamer::FRMRotamer(const std::vector<Particle>& particles, Real T, Real probability, Real internal_e_prefactor): particles_(particles), n_particles_(particles.size()), @@ -140,4 +146,16 @@ void FRMRotamer::ApplyOnResidue(loop::AllAtomPositions& all_atom, } } + +FrameResiduePtr FRMRotamer::ToFrameResidue(uint res_idx) const { + + const std::vector<int>& sub_def = subrotamer_definitions_[active_subrotamer_]; + std::vector<Particle> particles(sub_def.size()); + for(uint i = 0; i < sub_def.size(); ++i){ + particles[i] = particles_[sub_def[i]]; + } + FrameResiduePtr frame_res(new FrameResidue(particles, res_idx)); + return frame_res; +} + }}//ns diff --git a/sidechain/src/rotamer.hh b/sidechain/src/rotamer.hh index fd984f57..1e7d3297 100644 --- a/sidechain/src/rotamer.hh +++ b/sidechain/src/rotamer.hh @@ -7,6 +7,7 @@ #include <boost/make_shared.hpp> #include <promod3/sidechain/particle.hh> +#include <promod3/sidechain/frame.hh> #include <promod3/loop/all_atom_positions.hh> #include <promod3/core/message.hh> @@ -34,6 +35,8 @@ public: void ApplyOnResidue(loop::AllAtomPositions& all_atom, uint res_idx) const; + FrameResiduePtr ToFrameResidue(uint res_idx) const; + Real GetInternalEnergyPrefactor() const { return internal_e_prefactor_; } Real GetInternalEnergy() const { return internal_energy_; } @@ -97,6 +100,8 @@ public: void ApplyOnResidue(loop::AllAtomPositions& all_atom, uint res_idx) const; + FrameResiduePtr ToFrameResidue(uint res_idx) const; + void AddSubrotamerDefinition(const std::vector<int>& definition); void SetActiveSubrotamer(uint idx); diff --git a/sidechain/src/sidechain_reconstructor.cc b/sidechain/src/sidechain_reconstructor.cc index 92ff3157..b82b7ce6 100644 --- a/sidechain/src/sidechain_reconstructor.cc +++ b/sidechain/src/sidechain_reconstructor.cc @@ -259,23 +259,18 @@ template<typename RotamerGroup> void SidechainReconstructor::BuildDisulfids_( uint idx_two = cys_with_rot_groups[bond_pair.second]; uint global_idx_one = res_indices[idx_one]; uint global_idx_two = res_indices[idx_two]; - std::vector<Particle> particles(1); // update the rotamer groups participating in disulfid bonds is_bonded[bond_pair.first] = 1; is_bonded[bond_pair.second] = 1; // do first disulfid bond partner - particles[0] = *(r_one->begin()); - FrameResiduePtr frame_res_one(new FrameResidue(particles, global_idx_one)); - frame_residues.push_back(frame_res_one); + frame_residues.push_back(r_one->ToFrameResidue(global_idx_one)); r_one->ApplyOnResidue(out_pos, idx_one); has_sidechain[idx_one] = true; // do second disulfid bond partner - particles[0] = *(r_two->begin()); - FrameResiduePtr frame_res_two(new FrameResidue(particles, global_idx_two)); - frame_residues.push_back(frame_res_two); + frame_residues.push_back(r_two->ToFrameResidue(global_idx_two)); r_two->ApplyOnResidue(out_pos, idx_two); has_sidechain[idx_two] = true; -- GitLab