Skip to content

Commit

Permalink
Make UnAssignedChemistryInPDBError hints clearer (#1926)
Browse files Browse the repository at this point in the history
* Make UnAssignedChemistryInPDBError hints clearer

* Update changelog

* Simplify diff

* Update pdb cookbook outputs
  • Loading branch information
Yoshanuikabundi authored Aug 10, 2024
1 parent 5cbfe60 commit d91b8f2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
### Bugfixes

- [PR #1923](https://github.com/openforcefield/openff-toolkit/pull/1923): `Topology.add_molecule` and `Topology.add_molecules` now return indices starting at 0. Previously, these indices started at 1, which does not match other indexing in the toolkit.
- [PR #1926](https://github.com/openforcefield/openff-toolkit/pull/1926): Less noisy hints when the chemistry of a PDB file cannot be identified.

## 0.16.2

Expand Down
4 changes: 2 additions & 2 deletions docs/users/pdb_cookbook/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
"outputs": [
{
"ename": "UnassignedChemistryInPDBError",
"evalue": "Some bonds or atoms in the input could not be identified.\n\nHint: The following residue names with unassigned atoms were not found in the substructure library. While the OpenFF Toolkit identifies residues by matching chemical substructures rather than by residue name, it currently only supports the 20 'canonical' amino acids.\n JZ4\n\n\nHint: The following residues were assigned names that do not match the residue name in the input, or could not be assigned residue names at all. This may indicate that atoms are missing from the input or some other error. The OpenFF Toolkit requires all atoms, including hydrogens, to be explicit in the input to avoid ambiguities in protonation state or bond order:\n Input residue X:JZ4#0001 contains atoms matching substructures {'No match'}\n\nError: The following 22 atoms exist in the input but could not be assigned chemical information from the substructure library:\n Atom 2614 (C4) in residue X:JZ4#0001\n Atom 2615 (C7) in residue X:JZ4#0001\n Atom 2616 (C8) in residue X:JZ4#0001\n Atom 2617 (C9) in residue X:JZ4#0001\n Atom 2618 (C10) in residue X:JZ4#0001\n Atom 2619 (C11) in residue X:JZ4#0001\n Atom 2620 (C12) in residue X:JZ4#0001\n Atom 2621 (C13) in residue X:JZ4#0001\n Atom 2622 (C14) in residue X:JZ4#0001\n Atom 2623 (OAB) in residue X:JZ4#0001\n Atom 2624 (H1) in residue X:JZ4#0001\n Atom 2625 (H2) in residue X:JZ4#0001\n Atom 2626 (H3) in residue X:JZ4#0001\n Atom 2627 (H4) in residue X:JZ4#0001\n Atom 2628 (H5) in residue X:JZ4#0001\n Atom 2629 (H6) in residue X:JZ4#0001\n Atom 2630 (H7) in residue X:JZ4#0001\n Atom 2631 (H8) in residue X:JZ4#0001\n Atom 2632 (H9) in residue X:JZ4#0001\n Atom 2633 (H10) in residue X:JZ4#0001\n Atom 2634 (H11) in residue X:JZ4#0001\n Atom 2635 (H12) in residue X:JZ4#0001\n",
"evalue": "Some bonds or atoms in the input could not be identified.\n\nHint: The following residue names with unassigned atoms were not found in the substructure library. While the OpenFF Toolkit identifies residues by matching chemical substructures rather than by residue name, it currently only supports the 20 'canonical' amino acids.\n JZ4\n\n\nHint: The following residues were assigned names that do not match the residue name in the input, or could not be assigned residue names at all. This may indicate that atoms are missing from the input or some other error. The OpenFF Toolkit requires all atoms, including hydrogens, to be explicit in the input to avoid ambiguities in protonation state or bond order:\n Input residue X:JZ4#0001 contains atoms matching substructures {'NO MATCH'}\n\nError: The following 22 atoms exist in the input but could not be assigned chemical information from the substructure library:\n Atom 2614 (C4) in residue X:JZ4#0001\n Atom 2615 (C7) in residue X:JZ4#0001\n Atom 2616 (C8) in residue X:JZ4#0001\n Atom 2617 (C9) in residue X:JZ4#0001\n Atom 2618 (C10) in residue X:JZ4#0001\n Atom 2619 (C11) in residue X:JZ4#0001\n Atom 2620 (C12) in residue X:JZ4#0001\n Atom 2621 (C13) in residue X:JZ4#0001\n Atom 2622 (C14) in residue X:JZ4#0001\n Atom 2623 (OAB) in residue X:JZ4#0001\n Atom 2624 (H1) in residue X:JZ4#0001\n Atom 2625 (H2) in residue X:JZ4#0001\n Atom 2626 (H3) in residue X:JZ4#0001\n Atom 2627 (H4) in residue X:JZ4#0001\n Atom 2628 (H5) in residue X:JZ4#0001\n Atom 2629 (H6) in residue X:JZ4#0001\n Atom 2630 (H7) in residue X:JZ4#0001\n Atom 2631 (H8) in residue X:JZ4#0001\n Atom 2632 (H9) in residue X:JZ4#0001\n Atom 2633 (H10) in residue X:JZ4#0001\n Atom 2634 (H11) in residue X:JZ4#0001\n Atom 2635 (H12) in residue X:JZ4#0001\n",
"output_type": "error",
"traceback": [
"\u001b[0;31mUnassignedChemistryInPDBError\u001b[0m\u001b[0;31m:\u001b[0m Some bonds or atoms in the input could not be identified.\n\nHint: The following residue names with unassigned atoms were not found in the substructure library. While the OpenFF Toolkit identifies residues by matching chemical substructures rather than by residue name, it currently only supports the 20 'canonical' amino acids.\n JZ4\n\n\nHint: The following residues were assigned names that do not match the residue name in the input, or could not be assigned residue names at all. This may indicate that atoms are missing from the input or some other error. The OpenFF Toolkit requires all atoms, including hydrogens, to be explicit in the input to avoid ambiguities in protonation state or bond order:\n Input residue X:JZ4#0001 contains atoms matching substructures {'No match'}\n\nError: The following 22 atoms exist in the input but could not be assigned chemical information from the substructure library:\n Atom 2614 (C4) in residue X:JZ4#0001\n Atom 2615 (C7) in residue X:JZ4#0001\n Atom 2616 (C8) in residue X:JZ4#0001\n Atom 2617 (C9) in residue X:JZ4#0001\n Atom 2618 (C10) in residue X:JZ4#0001\n Atom 2619 (C11) in residue X:JZ4#0001\n Atom 2620 (C12) in residue X:JZ4#0001\n Atom 2621 (C13) in residue X:JZ4#0001\n Atom 2622 (C14) in residue X:JZ4#0001\n Atom 2623 (OAB) in residue X:JZ4#0001\n Atom 2624 (H1) in residue X:JZ4#0001\n Atom 2625 (H2) in residue X:JZ4#0001\n Atom 2626 (H3) in residue X:JZ4#0001\n Atom 2627 (H4) in residue X:JZ4#0001\n Atom 2628 (H5) in residue X:JZ4#0001\n Atom 2629 (H6) in residue X:JZ4#0001\n Atom 2630 (H7) in residue X:JZ4#0001\n Atom 2631 (H8) in residue X:JZ4#0001\n Atom 2632 (H9) in residue X:JZ4#0001\n Atom 2633 (H10) in residue X:JZ4#0001\n Atom 2634 (H11) in residue X:JZ4#0001\n Atom 2635 (H12) in residue X:JZ4#0001\n\n"
"\u001b[0;31mUnassignedChemistryInPDBError\u001b[0m\u001b[0;31m:\u001b[0m Some bonds or atoms in the input could not be identified.\n\nHint: The following residue names with unassigned atoms were not found in the substructure library. While the OpenFF Toolkit identifies residues by matching chemical substructures rather than by residue name, it currently only supports the 20 'canonical' amino acids.\n JZ4\n\n\nHint: The following residues were assigned names that do not match the residue name in the input, or could not be assigned residue names at all. This may indicate that atoms are missing from the input or some other error. The OpenFF Toolkit requires all atoms, including hydrogens, to be explicit in the input to avoid ambiguities in protonation state or bond order:\n Input residue X:JZ4#0001 contains atoms matching substructures {'NO MATCH'}\n\nError: The following 22 atoms exist in the input but could not be assigned chemical information from the substructure library:\n Atom 2614 (C4) in residue X:JZ4#0001\n Atom 2615 (C7) in residue X:JZ4#0001\n Atom 2616 (C8) in residue X:JZ4#0001\n Atom 2617 (C9) in residue X:JZ4#0001\n Atom 2618 (C10) in residue X:JZ4#0001\n Atom 2619 (C11) in residue X:JZ4#0001\n Atom 2620 (C12) in residue X:JZ4#0001\n Atom 2621 (C13) in residue X:JZ4#0001\n Atom 2622 (C14) in residue X:JZ4#0001\n Atom 2623 (OAB) in residue X:JZ4#0001\n Atom 2624 (H1) in residue X:JZ4#0001\n Atom 2625 (H2) in residue X:JZ4#0001\n Atom 2626 (H3) in residue X:JZ4#0001\n Atom 2627 (H4) in residue X:JZ4#0001\n Atom 2628 (H5) in residue X:JZ4#0001\n Atom 2629 (H6) in residue X:JZ4#0001\n Atom 2630 (H7) in residue X:JZ4#0001\n Atom 2631 (H8) in residue X:JZ4#0001\n Atom 2632 (H9) in residue X:JZ4#0001\n Atom 2633 (H10) in residue X:JZ4#0001\n Atom 2634 (H11) in residue X:JZ4#0001\n Atom 2635 (H12) in residue X:JZ4#0001\n\n"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def assigned_residue_name_mismatch_hint(self) -> list[str]:
input_chain: str = atom.residue.chain.id
matched_resnames = self.matches[atom.index]
# Only the first match is assigned, so throw out the others
assigned_resname = next(iter(matched_resnames), "No match")
assigned_resname = next(iter(matched_resnames), "No match").upper()

residues[(input_resname, input_resnum, input_chain)].add(assigned_resname)

Expand Down

0 comments on commit d91b8f2

Please sign in to comment.