From c8c57dd922ac1e455523368cb9f2f93f700c41d1 Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 21 Sep 2010 14:32:14 +0000 Subject: [PATCH] fix BZDNG-156 git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2722 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/io/src/mol/pdb_reader.cc | 8 +++++--- modules/mol/base/src/impl/chain_impl.cc | 22 +++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index 5a628c2cc..938fc23f7 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -250,7 +250,8 @@ void PDBReader::AssignSecStructure(mol::EntityHandle ent) // two secondary structure segments to insert one residue of coil // conformation. mol::ResNum start=i->start, end=i->end; - if (helix_list_.end()!=i+1 && (*(i+1)).start.GetNum()<=end.GetNum()+1) { + if (helix_list_.end()!=i+1 && (*(i+1)).start.GetNum()<=end.GetNum()+1 && + (*(i+1)).end.GetNum()>end.GetNum()) { end=mol::ResNum((*(i+1)).start.GetNum()-2); } chain.AssignSecondaryStructure(alpha, start, end); @@ -266,7 +267,8 @@ void PDBReader::AssignSecStructure(mol::EntityHandle ent) mol::SecStructure extended(mol::SecStructure::EXTENDED); mol::ResNum start=i->start, end=i->end; // see comment for helix assignment - if (strand_list_.end()!=i+1 && (*(i+1)).start.GetNum()<=end.GetNum()+1) { + if (strand_list_.end()!=i+1 && (*(i+1)).start.GetNum()<=end.GetNum()+1 && + (*(i+1)).end.GetNum()>end.GetNum()) { end=mol::ResNum((*(i+1)).start.GetNum()-2); } chain.AssignSecondaryStructure(extended, start, end); @@ -612,7 +614,7 @@ void PDBReader::ParseStrandEntry(const StringRef& line) throw IOException(str(format("invalid strand entry on line %d")%line_num_)); } LOG_DEBUG("making strand entry: " << start_num.second << ", " << line[26] - << " " << end_num.second << " " << line[37]); + << " " << end_num.second << " " << line[37] << " chain=" << line[21]); HSEntry hse = {to_res_num(start_num.second, line[26]), to_res_num(end_num.second, line[37]), line.substr(21,1).str()}; diff --git a/modules/mol/base/src/impl/chain_impl.cc b/modules/mol/base/src/impl/chain_impl.cc index 1a2e0e137..c6b3192d3 100644 --- a/modules/mol/base/src/impl/chain_impl.cc +++ b/modules/mol/base/src/impl/chain_impl.cc @@ -341,11 +341,23 @@ void ChainImpl::AssignSecondaryStructure(SecStructure ss, const ResNum& start, const ResNum& end) { - int i=this->GetIndex(start); - int j=this->GetIndex(end); - if (i>=0 && j>=0 && i<=j && j<static_cast<int>(residue_list_.size())) { - std::for_each(residue_list_.begin()+i, residue_list_.begin()+j+1, - bind(&ResidueImpl::SetSecStructure, _1, ss)); + int start_index=this->GetIndex(start); + int i=start_index; + bool found_end=false; + if (i>=0) { + while (i<static_cast<int>(residue_list_.size())) { + if (residue_list_[i]->GetNumber()==end) { + found_end=true; + break; + } + ++i; + } + } + if (!found_end) { + return; + } + for (int end=i, i=start_index; i<=end; ++i) { + residue_list_[i]->SetSecStructure(ss); } } -- GitLab