Open j-wags opened 3 years ago
I think the root cause of this issue is that the OpenFF toolkit performs canonicalization, but it doesn't have a way to return the atom mapping that got applied. I'll open an issue on the Toolkit repo to have that mapping get returned, and once that's available we can provide it to the user here.
This was the main reason. And as a slight tangent, there is additional code scattered throughout the codebase that basically reapplies the atom map after things like conformer generation or WBO generation because the TK will discard this info.
Currently, as @jthorton mentioned #126, we recommend retrieving the parent molecule from the results object.
There's no direct way to map from 0 to 4 given the information in the result object.
That's not strictly true. @ldamore , If you really do want to re-map the old map indices to the new without waiting for a new TK release, just do an isomorphism check of the old with the new parent and set return atom maps = True and use that to port the indices over. However note that the indices in the fragment correspond to the map indices in the parent of the results object
Summary
Many users probably want to follow specific atoms/bonds through the fragmentation process. However, as a result of performing canonicalization of input molecules, there's no way to map from an atom in the input molecule of a Fragmenter job to an atom in the
result
'sparent_molecule
or any of the output fragments.Reproducing example
mol1
has the following atom map, and the drawing below shows the atom indices (NOT map indices)The result's
parent_molecule
has the following atom map, and the drawing below shows the atom indices (NOT map indices)We see that the Cl switched from being atom index 0 in the input, to atom index 4 in the parent. There's no direct way to map from 0 to 4 given the information in the
result
object.Solutions
I think the root cause of this issue is that the OpenFF toolkit performs canonicalization, but it doesn't have a way to return the atom mapping that got applied. I'll open an issue on the Toolkit repo to have that mapping get returned, and once that's available we can provide it to the user here.