Fix _smilesAtomOutputOrder parsing for RDKit 2024.03.6 or newer (Issue #7749) #66
+110
−74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #65
RDKit's rdkit/rdkit#7749 fixed an issue with the formatting of
_smilesAtomOutputOrder
: before this bugfix, the code added an extra comma at the end of the list of atom indexes, which required some custom parsing code such as the one inget_atom_order_in_smiles()
.Once that patch was merged, the parsing code broke, as it expects the comma to be there.
After the patch,
_smilesAtomOutputOrder
can be parsed as json, or usingast.literal_eval()
, which is what I'm adding here. For backwards compatibility with RDKit builds that do not include that patch, I added a couple of lines that remove the extra comma before usingast.literal_eval()
to parse the list.