knime-rdkit icon indicating copy to clipboard operation
knime-rdkit copied to clipboard

Trying to understand the RDKit Aromatizer node and the comparison to 0 to determine success

Open TraceLD opened this issue 3 years ago • 4 comments

I'm trying to understand an existing RDKit-based KNIME workflow and having used RDKit in Python previously I can't understand the RDKit Aromatizer node. It calls .setAromaticity(temp) where temp is a RDKit molecule and then compares the result to 0 to determine success but what is happening here? SetAromaticity in the C++ API which the Java KNIME is wrapping returns void and in Python it returns None. What does the comparison to 0 do here?

Line I'm referencing: https://github.com/rdkit/knime-rdkit/blob/d7604170eec455d04e735b11348c7735450b3106/org.rdkit.knime.nodes/src/org/rdkit/knime/nodes/aromatize/RDKitAromatizeNodeModel.java#L242

TraceLD avatar Apr 26 '22 08:04 TraceLD

@TraceLD : the C++ setAromaticity() call which is being used by the KNIME node (the KNIME node actually uses the Java wrapper around this call) is this one: https://github.com/rdkit/rdkit/blob/f0cf0b0f202b469726a4aa86c4b14022f3ac7067/Code/GraphMol/MolOps.h#L552

greglandrum avatar Apr 26 '22 09:04 greglandrum

@TraceLD : the C++ setAromaticity() call which is being used by the KNIME node (the KNIME node actually uses the Java wrapper around this call) is this one: https://github.com/rdkit/rdkit/blob/f0cf0b0f202b469726a4aa86c4b14022f3ac7067/Code/GraphMol/MolOps.h#L552

I see, why does it then seemingly get wrapped in Python into a function that returns None? https://www.rdkit.org/docs/source/rdkit.Chem.rdmolops.html#rdkit.Chem.rdmolops.SetAromaticity

TraceLD avatar Apr 26 '22 09:04 TraceLD

I see, why does it then seemingly get wrapped in Python into a function that returns None? https://www.rdkit.org/docs/source/rdkit.Chem.rdmolops.html#rdkit.Chem.rdmolops.SetAromaticity

The Python wrappers and Java wrappers are created with different technologies and don't have a one-to-one mapping

greglandrum avatar Apr 26 '22 10:04 greglandrum

The Python wrappers and Java wrappers are created with different technologies and don't have a one-to-one mapping

I suppose what I'm asking then is if there's a way to determine if SetAromaticity succeeded in Python akin to how it's done in KNIME, since for the same input in KNIME I get like 200 failures, whereas in Python I don't get anything since SetAromaticity just returns None and modifies the Mol in place (and there's no warning/exception either)

TraceLD avatar Apr 26 '22 12:04 TraceLD