[Opt] Optimize PR 5086 at function findEnvironmentOfRadiusN
#5162
Replies: 1 comment
-
I suppose the better name of this argument is If you want to achieve both speed-up but not losing the information when the argument def PyWrap_FindAtomEnvironmentOfRadiusN(mol, atomIdx, radius, useHs, *args, **kwargs):
atom = mol.GetAtomWithIdx(atomIdx)
if atom.GetAtomicNum() == 1:
return FindAtomEnvironmentOfRadiusN(mol, atomIdx, radius, useHs, assumeIsolatedHydro=False, *args, **kwargs)
return FindAtomEnvironmentOfRadiusN(mol, atomIdx, radius, useHs, assumeIsolatedHydro=True, *args, **kwargs) Test: FindAtomEnvironmentOfRadiusN(atom='H', radius=1, assumeIsolatedHydro=True) -> [] |
Beta Was this translation helpful? Give feedback.
-
According to OpenSmiles, I found that the bond/edge exploited the valence bond theory for the chemical graph, and the optimization I attempted to done here is to reduce the next looping of algorithm by assuming the hydrogen atom only have 1 single bond attached to it (It would fail if hydrogen can connect two or more atoms: Figure 3: https://en.wikipedia.org/wiki/Hydrogen_bond)
In the PR 5086, the change is to convert from (in line 595)
into something as this:
where
optMode
is the new introduced argument fed by user (default to False to prevent backward incompatibility) (I don't have any name for this argument currently). Description: optMode (bool): Optional argument that assume the hydrogen atom can only have one neighbor (one bond) only. By setting to True, the algorithm can have a visible speed-up if your molecule useAddHs()
function but would fail if the previous hypothesis above is incorrect. Default to False.Why I believe this can work:
AddHs()
function is implemented. The effect of this condition:if (useHs || mol.getAtomWithIdx(bond->getOtherAtomIdx(oAtom))
in line 596 is ignored.bitInfo
applied in ECFP algorithm.Thank you for your reading and response.
Reference: #5086
Beta Was this translation helpful? Give feedback.
All reactions