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.
In
correct_formal_charges_for_specified_atoms, the result of_get_bond_degree_per_atomis treated as a literal bond degree (in that its relation todefault_valenceyields formal charge). But in fact, it returns thebiotite.structure.BondTypeenum; 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
rdkitassertion) as well as PDBs that don't parse unless formal charges are corrected (9DAG; phosphorus with 'uncorrected' charge +2 fails a differentrdkitassertion).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.