Skip to content

Commit

Permalink
trim_to_alanine(): update het_flag if needed
Browse files Browse the repository at this point in the history
and also move the definition from header to cpp
  • Loading branch information
wojdyr committed Apr 25, 2024
1 parent 5abac30 commit f8aff5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
16 changes: 1 addition & 15 deletions include/gemmi/polyheur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,7 @@ template<> inline void remove_ligands_and_waters(Chain& ch) {
}

// Trim to alanine. Returns true if trimmed, false if it's (likely) not AA.
inline bool trim_to_alanine(Residue& res) {
static const std::pair<std::string, El> ala_atoms[6] = {
{"N", El::N}, {"CA", El::C}, {"C", El::C}, {"O", El::O}, {"CB", El::C},
{"OXT", El::O}
};
if (res.get_ca() == nullptr)
return false;
vector_remove_if(res.atoms, [](const Atom& a) {
for (const auto& name_el : ala_atoms)
if (a.name == name_el.first && a.element == name_el.second)
return false;
return true;
});
return true;
}
GEMMI_DLL bool trim_to_alanine(Residue& res);

inline void trim_to_alanine(Chain& chain) {
for (Residue& res : chain.residues)
Expand Down
19 changes: 19 additions & 0 deletions src/polyheur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,25 @@ char recommended_het_flag(const Residue& res) {
return 'H';
}

bool trim_to_alanine(Residue& res) {
static const std::pair<std::string, El> ala_atoms[6] = {
{"N", El::N}, {"CA", El::C}, {"C", El::C}, {"O", El::O}, {"CB", El::C},
{"OXT", El::O}
};
if (res.get_ca() == nullptr)
return false;
vector_remove_if(res.atoms, [](const Atom& a) {
for (const auto& name_el : ala_atoms)
if (a.name == name_el.first && a.element == name_el.second)
return false;
return true;
});
// if non-standard polymer residue was mutated, update het_flag
if (res.entity_type == EntityType::Polymer && res.het_flag == 'H')
res.het_flag = 'A';
return true;
}

void change_ccd_code(Structure& st, const std::string& old, const std::string& new_) {
auto process = [&](ResidueId& rid) {
if (rid.name == old)
Expand Down

0 comments on commit f8aff5f

Please sign in to comment.