Problem with subgraph matching in RDkit
In a few cases the porphyrin ring is not picked by rdkit (i.e. HasSubstructMatch() returns false) correctly and the template without the central ion is used instead. This is caused by SMARTS mismatch, need to investigate substructure matches with the use of FMCS algorithm.
Examples:
HEM, HEA, HEC are alright and look like this:
however, e.g. HDE or HEC exhibit:
Need to investigate more, what's happening under the hood