You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from rdkit import Chem
from rdkit.Chem import Draw
import math
from IPython.display import SVG
smi_list = ["*Cl", "CC"]
mols = [Chem.MolFromSmiles(smi) for smi in smi_list]
sub_size = [250,250]
mols_num = len(mols)
columns_num = 5
rows_num = math.ceil(mols_num/5)
grid = [columns_num,rows_num]
aa = grid[0]*sub_size[0]
ab = grid[1]*sub_size[1]
ac = sub_size[0]
ad = sub_size[1]
d = Draw.rdMolDraw2D.MolDraw2DSVG(aa, ab, ac, ad)
opt = d.drawOptions()
opt.legendFontSize=20
d.SetFontSize(1.3*d.FontSize())
d.SetLineWidth(1)
d.DrawMolecules(mols,
highlightAtoms=None,
highlightBonds=None,
highlightAtomColors=None,
highlightBondColors=None,
legends=None)
d.FinishDrawing()
print(d.GetDrawingText())
<?xml version='1.0' encoding='iso-8859-1'?>
<svg version='1.1' baseProfile='full'
xmlns='http://www.w3.org/2000/svg'
xmlns:rdkit='http://www.rdkit.org/xml'
xmlns:xlink='http://www.w3.org/1999/xlink'
xml:space='preserve'
width='1250px' height='250px' viewBox='0 0 1250 250'>
<!-- END OF HEADER -->
<rect style='opacity:1.0;fill:#FFFFFF;stroke:none' width='1250' height='250' x='0' y='0'> </rect>
<path class='bond-0' d='M 0,250 L 0,250' style='fill:none;fill-rule:evenodd;stroke:#7F7F7F;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<path class='bond-0' d='M 0,250 L 0,250' style='fill:none;fill-rule:evenodd;stroke:#00CC00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<text x='0' y='250' style='font-size:0px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#7F7F7F' ><tspan>*</tspan></text>
<text x='0' y='250' style='font-size:0px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#00CC00' ><tspan>Cl</tspan></text>
<path d='M 0,250 L 0,250 L 0,250 L 0,250 Z' style='fill:none;stroke:#FF0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;' />
<path class='bond-0' d='M 250,250 L 250,250' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<path d='M 250,250 L 250,250 L 250,250 L 250,250 Z' style='fill:none;stroke:#FF0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;' />
</svg>
This is caused by MolDraw2D::setScale setting the scale to 0 if the Y range is < 1e-4, as happens with molecules which are constituted by an horizontal bond and nothing more.
The text was updated successfully, but these errors were encountered:
This is caused by
MolDraw2D::setScale
setting the scale to 0 if the Y range is < 1e-4, as happens with molecules which are constituted by an horizontal bond and nothing more.The text was updated successfully, but these errors were encountered: