Skip to content

Commit

Permalink
gemmi-contents: print warning if atom's occupancy is negative or >1
Browse files Browse the repository at this point in the history
for instance, in 1c5z
  • Loading branch information
wojdyr committed Nov 16, 2023
1 parent b9fc29c commit 36b1e03
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions prog/contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ void print_content_info(const Structure& st, bool /*verbose*/) {
mol_atom_count += atom.occ;
mol_weight += atom.occ * atom.element.weight();
}

// sanity check: occupancies
if (atom.occ > 1.0f || atom.occ < 0.f)
printf("WARNING: Occupancy of %s: %g\n",
atom_str(chain, res, atom).c_str(), atom.occ);
if (atom.altloc && (&atom == &res.atoms[0] || (&atom - 1)->name != atom.name)) {
float occ_sum = atom.occ;
for (const Atom* a = &atom + 1; a < res.atoms.data() + res.atoms.size(); ++a)
if (a->name == atom.name)
occ_sum += a->occ;
if (occ_sum > 1.0f)
printf("WARNING: Sum of altloc occupancies of %s/%s %s/%s: %g\n",
chain.name.c_str(), res.name.c_str(), res.seqid.str().c_str(),
atom.name.c_str(), occ_sum);
}
}
}
}
Expand Down

0 comments on commit 36b1e03

Please sign in to comment.