Skip to content

Formal charge correction fails in the presence of bonds to metal ions #80

Closed

Description

@everyday847

In correct_formal_charges_for_specified_atoms, the result of _get_bond_degree_per_atom is treated as a literal bond degree (in that its relation to default_valence yields formal charge). But in fact, it returns the biotite.structure.BondType enum; coordination bonds (those to metal ions) have the improbable bond order of 8.

As a result, there are PDBs that don't parse unless formal charges go uncorrected (9VAR; nitrogen with 'corrected' charge +8" fails some rdkit assertion) as well as PDBs that don't parse unless formal charges are corrected (9DAG; phosphorus with 'uncorrected' charge +2 fails a different rdkit assertion).

I'm not sure if there is a single clean fix available, since whether a coordination bond actually alters formal charge can involve a little bit of understanding of the metal being coordinated.

Activity

  1. nscorley commented on May 15, 2026

    @nscorley
    Collaborator

    Thanks for raising this! It's a hairy problem that we have come across as well... probably best is to just trust the charge in the CIF file for metals, I can make this update

  2. added a commit that references this issue on Jun 2, 2026
  3. nscorley commented on Oct 5, 2026

    @nscorley
    Collaborator

    Fixed in #116. Coordination bonds contribute zero to covalent valence, rather than their enum value of eight. Verified that 9VAR and 9DAG parse with metal coordination enabled. Regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions