Skip to content

Commit

Permalink
add_entity_types(overwrite=True) now ignores old entity_type's
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Nov 16, 2023
1 parent 195343c commit b9fc29c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion include/gemmi/polyheur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace gemmi {
// A simplistic classification. It may change in the future.
// It returns PolymerType which corresponds to _entity_poly.type,
// but here we use only PeptideL, Rna, Dna, DnaRnaHybrid and Unknown.
GEMMI_DLL PolymerType check_polymer_type(const ConstResidueSpan& span);
GEMMI_DLL PolymerType check_polymer_type(const ConstResidueSpan& span,
bool ignore_entity_type=false);

inline PolymerType get_or_check_polymer_type(const Entity* ent,
const ConstResidueSpan& polymer) {
Expand Down
7 changes: 4 additions & 3 deletions src/polyheur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace gemmi {

PolymerType check_polymer_type(const ConstResidueSpan& span) {
PolymerType check_polymer_type(const ConstResidueSpan& span, bool ignore_entity_type) {
if (span.empty())
return PolymerType::Unknown;
size_t counts[(int)ResidueKind::ELS+1] = {0};
Expand All @@ -13,7 +13,8 @@ PolymerType check_polymer_type(const ConstResidueSpan& span) {
size_t total = 0;
bool has_atom_record = false;
for (const Residue& r : span)
if (r.entity_type == EntityType::Unknown ||
if (ignore_entity_type ||
r.entity_type == EntityType::Unknown ||
r.entity_type == EntityType::Polymer) {
if (r.het_flag == 'A')
has_atom_record = true;
Expand Down Expand Up @@ -115,7 +116,7 @@ void add_entity_types(Chain& chain, bool overwrite) {
std::all_of(chain.residues.begin(), chain.residues.end(),
[](const Residue& r) { return r.entity_type != EntityType::Unknown; }))
return;
PolymerType ptype = check_polymer_type(chain.whole());
PolymerType ptype = check_polymer_type(chain.whole(), /*ignore_entity_type=*/overwrite);
auto it = chain.residues.begin();
if (ptype != PolymerType::Unknown) {
auto polymer_end = infer_polymer_end(chain, ptype);
Expand Down

0 comments on commit b9fc29c

Please sign in to comment.