Skip to content
Snippets Groups Projects
Commit 831ceb25 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

Make it possible to select active subrotamer in flexible rotamer model

The active rotamer controls which subrotamer is used when the
ApplyOnResidue function gets called
parent f9c38e9e
Branches
Tags
No related merge requests found
......@@ -437,6 +437,17 @@ Rotamers
:type indices: :class:`list`
.. method:: SetActiveSubrotamer(idx)
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.
:param idx: Index of subrotamer definition applied on residues
:type idx: :class:`int`
.. method:: SetTemperature(temperature)
......
......@@ -179,6 +179,7 @@ void export_Rotamer()
.def("__getitem__",&WrapFRMGetItem,arg("index"))
.def("GetNumSubrotamers",&FRMRotamer::subrotamer_size)
.def("GetSubrotamerDefinition",&WrapGetSubrotamerDefinition, (arg("index")))
.def("SetActiveSubrotamer", &FRMRotamer::SetActiveSubrotamer, (arg("idx")))
.def("ApplyOnResidue", WrapFRMApplyOnRes,
(arg("res"), arg("consider_hydrogens")=false, arg("new_res_name")=""))
.def("ApplyOnResidue", WrapFRMApplyOnResAA,
......
......@@ -58,8 +58,8 @@ void RRMRotamer::ApplyOnResidue(loop::AllAtomPositions& all_atom,
FRMRotamer::FRMRotamer(const std::vector<Particle>& particles, Real T,
Real probability, Real internal_e_prefactor):
particles_(particles), n_particles_(particles.size()),
internal_energy_(0.0),frame_energy_(0.0),
T_(T), probability_(probability),
active_subrotamer_(0), internal_energy_(0.0),
frame_energy_(0.0), T_(T), probability_(probability),
internal_e_prefactor_(internal_e_prefactor){
subrotamer_associations_.resize(n_particles_,std::vector<int>());
}
......@@ -74,6 +74,13 @@ void FRMRotamer::AddSubrotamerDefinition(const std::vector<int>& definition){
frame_energies_.push_back(0.0);
}
void FRMRotamer::SetActiveSubrotamer(uint idx) {
if(idx >= subrotamer_definitions_.size()){
throw promod3::Error("Invalid subrotamer idx provided!");
}
active_subrotamer_ = idx;
}
void FRMRotamer::ApplyOnResidue(ost::mol::ResidueHandle& res,
bool consider_hydrogens,
const String& new_res_name) const {
......@@ -88,7 +95,7 @@ void FRMRotamer::ApplyOnResidue(ost::mol::ResidueHandle& res,
ost::mol::XCSEditor ed = res.GetEntity().EditXCS(ost::mol::BUFFERED_EDIT);
const std::vector<int>& sub_def = subrotamer_definitions_[0];
const std::vector<int>& sub_def = subrotamer_definitions_[active_subrotamer_];
ost::mol::AtomHandle a;
for (uint i = 0; i < sub_def.size(); ++i) {
const Particle& p=particles_[sub_def[i]];
......@@ -123,7 +130,7 @@ void FRMRotamer::ApplyOnResidue(loop::AllAtomPositions& all_atom,
// check res_idx
all_atom.CheckResidueIndex(res_idx);
// reset all heavy atoms
const std::vector<int>& sub_def_ = subrotamer_definitions_[0];
const std::vector<int>& sub_def_ = subrotamer_definitions_[active_subrotamer_];
for (uint i = 0; i < sub_def_.size(); ++i) {
const Particle& p = particles_[sub_def_[i]];
const String& particle_name = p.GetName();
......
......@@ -99,6 +99,8 @@ public:
void AddSubrotamerDefinition(const std::vector<int>& definition);
void SetActiveSubrotamer(uint idx);
Real GetInternalEnergyPrefactor() const { return internal_e_prefactor_; }
Real GetInternalEnergy() const { return internal_energy_; }
......@@ -190,6 +192,7 @@ private:
size_t n_particles_;
std::vector<std::vector<int> > subrotamer_definitions_;
std::vector<std::vector<int> > subrotamer_associations_;
uint active_subrotamer_;
Real internal_energy_;
Real frame_energy_;
std::vector<Real> frame_energies_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment