Highlight a substructure in the depiction

The benzodiazepine data set was generated by doing a PubChem search for the SMARTS query "C2(CN=C(C1=CC(=CC=C1N2[*])[*])C3=CC=CC=C3[*])=[*]" where the [*] are for the R-groups. The query pattern was generated by the PubChem sketcher, and the aromatic form without R-groups is "c1ccc2c(c1)C(=NCCN2)c3ccccc3".

This task will extract a molecule from that data set and depict it with part of the substructure highlighted.

Implementation
Read record 3016 from the benzodiazepine SD file. Find all atoms which match the SMARTS "c1ccc2c(c1)C(=NCCN2)c3ccccc3" and highlight them in red. All other atoms must be drawn in black.

The resulting image should be 200x250 pixels and on a white background. The resulting image file should be in PNG (preferred) or GIF format.

Cactvs/Tcl
set eh [molfile scan [molfile open benzodiazepine.sdf.gz r hydrogens add] "E_NAME = 3016" ens] match ss -atomhighlight 1 -bondhighlight 1 c1ccc2c(c1)C(=NCCN2)c3ccccc3 $eh prop setparam E_GIF height 250 width 200 bgcolor white atomcolor black format png filename 3016.png ens get $eh E_GIF

The rendering uses the original coordinates from the SD file (unlike the OE example).

Btw: What does "Read record 3016" mean? If this is the record number, and not the record name, the script is: set eh [molfile read [molfile open benzodiazepine.sdf.gz r record 3016 hydrogens add]] match ss -atomhighlight 1 -bondhighlight 1 c1ccc2c(c1)C(=NCCN2)c3ccccc3 $eh prop setparam E_GIF height 250 width 200 bgcolor white atomcolor black format png filename 3016.png ens get $eh E_GIF



Cactvs/Python
First version with ID match: e=Molfile('benzodiazepine.sdf.gz','r',{'hydrogens':'add'}).scan('E_NAME = 3016','ens') match('ss','c1ccc2c(c1)C(=NCCN2)c3ccccc3',e,atomhighlight=True,bondhighlight=True) Prop.Setparam('E_GIF','height',250,'width',200,'bgcolor','white','atomcolor','black','format','png','filename','3016.png') e.get('E_GIF')

Second version with record selection: e=Molfile('benzodiazepine.sdf.gz','r',{'record':3016,'hydrogens':'add'}).read match('ss','c1ccc2c(c1)C(=NCCN2)c3ccccc3',e,atomhighlight=True,bondhighlight=True) Prop.Setparam('E_GIF','height',250,'width',200,'bgcolor','white','atomcolor','black','format','png','filename','3016.png') e.get('E_GIF')

The output is again pixel-identical.

CDK/Java


CDK v1.5.12+ provides a new depict API simplifying image generation.