Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从RDKit验证SVG文件_Svg_Rdkit - Fatal编程技术网

从RDKit验证SVG文件

从RDKit验证SVG文件,svg,rdkit,Svg,Rdkit,我试图从包RDKit生成SVG图像。最小可复制示例: 来自rdkit进口化学品 从rdkit.Chem导入绘图 img=Draw.MolsToGridImage([Chem.MolFromSmiles(x)表示['C','CO','CN']]中的x,useSVG=True) 打印(img) 输出如下,但在我尝试过的任何浏览器或图像查看器中都不会渲染任何图像这是有效的SVG文件,还是程序包生成的格式无效?还是有其他我看不到的错误 <?xml version='1.0' encoding='

我试图从包RDKit生成SVG图像。最小可复制示例:

来自rdkit进口化学品
从rdkit.Chem导入绘图
img=Draw.MolsToGridImage([Chem.MolFromSmiles(x)表示['C','CO','CN']]中的x,useSVG=True)
打印(img)
输出如下,但在我尝试过的任何浏览器或图像查看器中都不会渲染任何图像这是有效的SVG文件,还是程序包生成的格式无效?还是有其他我看不到的错误

<?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='600px' height='200px' >
<!-- END OF HEADER -->
<rect style='opacity:1.0;fill:#FFFFFF;stroke:none' width='600' height='200' x='0' y='0'> </rect>
<text x='0' y='200' style='font-size:0px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#000000' ><tspan>CH</tspan><tspan style='baseline-shift:sub;font-size:0px;'>4</tspan><tspan></tspan></text>
<path class='bond-0' d='M 200,200 200,200' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<path class='bond-0' d='M 200,200 200,200' style='fill:none;fill-rule:evenodd;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<text x='200' y='200' style='font-size:0px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#FF0000' ><tspan>OH</tspan></text>
<path d='M 200,200 200,200 200,200 200,200 200,200' style='fill:none;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<path class='bond-0' d='M 400,200 400,200' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<path class='bond-0' d='M 400,200 400,200' style='fill:none;fill-rule:evenodd;stroke:#0000FF;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
<text x='400' y='200' style='font-size:0px;font-style:normal;font-weight:normal;fill-opacity:1;stroke:none;font-family:sans-serif;text-anchor:start;fill:#0000FF' ><tspan>NH</tspan><tspan style='baseline-shift:sub;font-size:0px;'>2</tspan><tspan></tspan></text>
<path d='M 400,200 400,200 400,200 400,200 400,200' style='fill:none;stroke:#FF0000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />
</svg>

甲烷
哦
氨气

RDKit出于未知原因生成的SVG代码没有显示任何内容。但是,更改分子列表确实会产生SVG代码,从而生成可见图像

这项工作:

from rdkit import Chem
from rdkit.Chem import Draw 
img = Draw.MolsToGridImage([Chem.MolFromSmiles(x) for x in ['C', 'CO', 'CN', 'CCC']], useSVG = True)
print(img)

此处打开了一个错误:

矩形用白色填充,文本的字体大小为0px,路径为长度为0的行:
d='M 200200'