diff --git a/sidechain/doc/rotamer.rst b/sidechain/doc/rotamer.rst index b8dd468e1688689c461efad66601d703a38b810a..de974604e64529446fe667283279be2018d88c48 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 ac41d155fe72ce701872f10305f3b00641b2a9fa..c6b49bf042a9cad852d01ced6a28d37de46d53e2 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 47f99e557de5036c0edb6588800de60d4e05293e..f2bf1e87504e8ceb552c65541c1cb0f1ab1ac156 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 3cf238f345d6132d9d850aa54a227e131af0adad..4143480dbd7b42686dd86bbc8e122391414552f1 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 fd984f570e8e08be8966a87ae42b9bd3ae0742d4..1e7d3297ef564e0c2e715231f50068abca969aee 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 92ff3157cf4f71301ee5d6dac8af8f9d7f612c7a..b82b7ce621848cff410e84701ddaf3624f6ca7ec 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;