diff --git a/scoring/src/ss_agreement_env_listener.cc b/scoring/src/ss_agreement_env_listener.cc index 0653c629f6bfc850322878b633da9a29d26cf529..19d885f464d9918c66adc52f71e2237736ecf806 100644 --- a/scoring/src/ss_agreement_env_listener.cc +++ b/scoring/src/ss_agreement_env_listener.cc @@ -67,68 +67,7 @@ void SSAgreementEnvListener::SetEnvironment(const BackboneScoreEnv& base_env, env_.Add(&env_data_[*i], ca_pos_data[*i]); } - // additionally, we also set connectivity and ca / h positions - for(std::vector<uint>::const_iterator i = idx.begin(); i != idx.end(); ++i){ - - // set connectivity of the residue itself - if(*i < idx_handler_->GetNumResidues() - 1 && env_set_[*i + 1] && - geom::Length2(env_data_[*i].c_pos - env_data_[*i+1].n_pos) <= 6.25) { - connected_to_next_[*i] = 1; - } else { - connected_to_next_[*i] = 0; - } - - // set connectivity of the residue before - if(*i > 0) { - if(env_set_[*i - 1] && - geom::Length2(env_data_[*i-1].c_pos - env_data_[*i].n_pos) <= 6.25) { - connected_to_next_[*i-1] = 1; - } else { - connected_to_next_[*i-1] = 0; - } - } - - ca_positions_[*i] = env_data_[*i].pos; - - // h_pos of this residue - if(!env_data_[*i].is_proline) { - if(*i > 0 && env_set_[*i-1] && connected_to_next_[*i - 1]) { - geom::Vec3 dir_vec = geom::Normalize(env_data_[*i-1].c_pos - - env_data_[*i-1].o_pos); - env_data_[*i].h_pos = env_data_[*i].n_pos + dir_vec; - env_data_[*i].valid_h_pos = true; - } - else { - env_data_[*i].valid_h_pos = false; - } - } - - // the h_pos of the next residue might have changed - // no check for index validity of idx + 1... this informatin is contained - // in connected_to_next_ - if(connected_to_next_[*i]) { - if(!env_data_[*i+1].is_proline) { - geom::Vec3 dir_vec = geom::Normalize(env_data_[*i].c_pos - - env_data_[*i].o_pos); - env_data_[*i+1].h_pos = env_data_[*i+1].n_pos + dir_vec; - env_data_[*i+1].valid_h_pos = true; - } else { - env_data_[*i+1].valid_h_pos = false; - } - } - } - - // and finally update all donor information in the close environment - std::set<int> stuff_to_update; - for(std::vector<uint>::const_iterator i = idx.begin(); - i != idx.end(); ++i) { - this->AddCloseResidues(*i, stuff_to_update); - } - - for(std::set<int>::iterator i = stuff_to_update.begin(); - i != stuff_to_update.end(); ++i) { - this->FindOptimalDonors(*i); - } + this->Update(idx); } void SSAgreementEnvListener::ResetEnvironment(const BackboneScoreEnv& base_env, @@ -156,71 +95,9 @@ void SSAgreementEnvListener::ResetEnvironment(const BackboneScoreEnv& base_env, env_data_[*i].c_pos = c_pos_data[*i]; env_data_[*i].o_pos = o_pos_data[*i]; env_.Reset(&env_data_[*i], old_pos, ca_pos_data[*i]); - } - // additionally, we also set connectivity and ca / h positions - for(std::vector<uint>::const_iterator i = idx.begin(); i != idx.end(); ++i){ - - // set connectivity of the residue itself - if(*i < idx_handler_->GetNumResidues() - 1 && env_set_[*i + 1] && - geom::Length2(env_data_[*i].c_pos - env_data_[*i+1].n_pos) <= 6.25) { - connected_to_next_[*i] = 1; - } else { - connected_to_next_[*i] = 0; - } - - // set connectivity of the residue before - if(*i > 0) { - if(env_set_[*i - 1] && - geom::Length2(env_data_[*i-1].c_pos - env_data_[*i].n_pos) <= 6.25) { - connected_to_next_[*i-1] = 1; - } else { - connected_to_next_[*i-1] = 0; - } - } - - ca_positions_[*i] = env_data_[*i].pos; - - // h_pos of this residue - if(!env_data_[*i].is_proline) { - if(*i > 0 && env_set_[*i-1] && connected_to_next_[*i - 1]) { - geom::Vec3 dir_vec = geom::Normalize(env_data_[*i-1].c_pos - - env_data_[*i-1].o_pos); - env_data_[*i].h_pos = env_data_[*i].n_pos + dir_vec; - env_data_[*i].valid_h_pos = true; - } - else { - env_data_[*i].valid_h_pos = false; - } - } - - // the h_pos of the next residue might have changed - // no check for index validity of idx + 1... this informatin is contained - // in connected_to_next_ - if(connected_to_next_[*i]) { - if(!env_data_[*i+1].is_proline) { - geom::Vec3 dir_vec = geom::Normalize(env_data_[*i].c_pos - - env_data_[*i].o_pos); - env_data_[*i+1].h_pos = env_data_[*i+1].n_pos + dir_vec; - env_data_[*i+1].valid_h_pos = true; - } else { - env_data_[*i+1].valid_h_pos = false; - } - } - } - - // and finally update all donor information in the close environment - std::set<int> stuff_to_update; - for(std::vector<uint>::const_iterator i = idx.begin(); - i != idx.end(); ++i) { - this->AddCloseResidues(*i, stuff_to_update); - } - - for(std::set<int>::iterator i = stuff_to_update.begin(); - i != stuff_to_update.end(); ++i) { - this->FindOptimalDonors(*i); - } + this->Update(idx); } void SSAgreementEnvListener::ClearEnvironment(const BackboneScoreEnv& base_env, @@ -253,7 +130,7 @@ void SSAgreementEnvListener::ClearEnvironment(const BackboneScoreEnv& base_env, env_data_[*i + 1].valid_h_pos = false; } - // we already call FindOptimalDonors for the deleted residues. + // we call FindOptimalDonors for the deleted residues. // the only thing that will happen: // according donor_for_one_ / donor_for_two_ gets set to -1 FindOptimalDonors(*i); @@ -477,4 +354,71 @@ void SSAgreementEnvListener::FindOptimalDonors(uint idx, bool check_env_set) { } } +void SSAgreementEnvListener::Update(const std::vector<uint>& idx) { + + // assumes env_data_ to be set... + + for(std::vector<uint>::const_iterator i = idx.begin(); i != idx.end(); ++i){ + + ca_positions_[*i] = env_data_[*i].pos; + + // set connectivity of the residue itself + if(*i < idx_handler_->GetNumResidues() - 1 && env_set_[*i + 1] && + geom::Length2(env_data_[*i].c_pos - env_data_[*i+1].n_pos) <= 6.25) { + connected_to_next_[*i] = 1; + } else { + connected_to_next_[*i] = 0; + } + + // set connectivity of the residue before + if(*i > 0) { + if(env_set_[*i - 1] && + geom::Length2(env_data_[*i-1].c_pos - env_data_[*i].n_pos) <= 6.25) { + connected_to_next_[*i-1] = 1; + } else { + connected_to_next_[*i-1] = 0; + } + } + + // h_pos of this residue + if(!env_data_[*i].is_proline) { + if(*i > 0 && env_set_[*i-1] && connected_to_next_[*i - 1]) { + geom::Vec3 dir_vec = geom::Normalize(env_data_[*i-1].c_pos - + env_data_[*i-1].o_pos); + env_data_[*i].h_pos = env_data_[*i].n_pos + dir_vec; + env_data_[*i].valid_h_pos = true; + } + else { + env_data_[*i].valid_h_pos = false; + } + } + + // the h_pos of the next residue might have changed + // no check for index validity of idx + 1... this informatin is contained + // in connected_to_next_ + if(connected_to_next_[*i]) { + if(!env_data_[*i+1].is_proline) { + geom::Vec3 dir_vec = geom::Normalize(env_data_[*i].c_pos - + env_data_[*i].o_pos); + env_data_[*i+1].h_pos = env_data_[*i+1].n_pos + dir_vec; + env_data_[*i+1].valid_h_pos = true; + } else { + env_data_[*i+1].valid_h_pos = false; + } + } + } + + // and finally update all donor information in the close environment + std::set<int> stuff_to_update; + for(std::vector<uint>::const_iterator i = idx.begin(); + i != idx.end(); ++i) { + this->AddCloseResidues(*i, stuff_to_update); + } + + for(std::set<int>::iterator i = stuff_to_update.begin(); + i != stuff_to_update.end(); ++i) { + this->FindOptimalDonors(*i); + } +} + }} // ns diff --git a/scoring/src/ss_agreement_env_listener.hh b/scoring/src/ss_agreement_env_listener.hh index c6578139b633ffd2c10cc63fd662f66948a169de..3d924e23419591bf88567186eaa6f1949cee9687 100644 --- a/scoring/src/ss_agreement_env_listener.hh +++ b/scoring/src/ss_agreement_env_listener.hh @@ -63,6 +63,11 @@ public: private: + // helper function that sets hydrogen positions in env_data_, the ca_positions_, + // donor_for_one_, donor_for_two_, and connected_to_next_ for all residues + // affected by indices in idx + void Update(const std::vector<uint>& idx); + void AddCloseResidues(uint idx, std::set<int>& close_residues) const; void FindOptimalDonors(uint idx, bool check_env_set = true);