diff --git a/sidechain/src/scwrl_rotamer_constructor.cc b/sidechain/src/scwrl_rotamer_constructor.cc
index ed8d8da2f04790a7c2d7b72f5eb189de82c1a420..39a6e987ac6f87d6a175f192f5a0b491504f4b6a 100644
--- a/sidechain/src/scwrl_rotamer_constructor.cc
+++ b/sidechain/src/scwrl_rotamer_constructor.cc
@@ -1708,6 +1708,20 @@ FrameResiduePtr SCWRLRotamerConstructor::ConstructSidechainFrameResidue(
//set bb hydrogen
if(info.has_hydrogens){
+ // to construct hydrogens, we might also need backbone atoms in the buffer
+ const SCWRLRotamerInfo& bb_info = rotamer_lookup_.GetBackboneInfo(id);
+
+ for(uint i = 0; i < bb_info.particles.size(); ++i){
+ if(!bb_info.particles[i].is_hydrogen){
+ ost::mol::AtomHandle a = res.FindAtom(bb_info.particles[i].name);
+ if(!a.IsValid()){
+ throw promod3::Error("Expected atom " + bb_info.particles[i].name +
+ " to be present in input residue!");
+ }
+ pos_buffer_->SetPos(id, bb_info.particles[i].atom_idx, a.GetPos());
+ }
+ }
+
promod3::loop::ConstructHydrogens(*pos_buffer_, id, *hydrogen_buffer_, true,
promod3::loop::PROT_STATE_HISH);
}
@@ -1739,12 +1753,10 @@ FrameResiduePtr SCWRLRotamerConstructor::ConstructSidechainFrameResidue(
for(uint i = 0; i < info.particles.size(); ++i){
if(!info.particles[i].is_hydrogen){
-
if(!all_atom.IsSet(aa_res_idx, info.particles[i].atom_idx)){
throw promod3::Error("Expected atom " + info.particles[i].name +
" to be set in all_atom");
}
-
pos_buffer_->SetPos(id, info.particles[i].atom_idx,
all_atom.GetPos(aa_res_idx, info.particles[i].atom_idx));
}
@@ -1752,6 +1764,20 @@ FrameResiduePtr SCWRLRotamerConstructor::ConstructSidechainFrameResidue(
//set hydrogens
if(info.has_hydrogens){
+ // to construct hydrogens, we might also need backbone atoms in the buffer
+ const SCWRLRotamerInfo& bb_info = rotamer_lookup_.GetBackboneInfo(id);
+
+ for(uint i = 0; i < bb_info.particles.size(); ++i){
+ if(!bb_info.particles[i].is_hydrogen){
+ if(!all_atom.IsSet(aa_res_idx, bb_info.particles[i].atom_idx)){
+ throw promod3::Error("Expected atom " + bb_info.particles[i].name +
+ " to be set in all_atom");
+ }
+ pos_buffer_->SetPos(id, bb_info.particles[i].atom_idx,
+ all_atom.GetPos(aa_res_idx, bb_info.particles[i].atom_idx));
+ }
+ }
+
promod3::loop::ConstructHydrogens(*pos_buffer_, id, *hydrogen_buffer_, true,
promod3::loop::PROT_STATE_HISH);
}