def test_can_draw(self): output_mol = draw_mol("C1CCCCC1") svg_str = ( "<?xml version='1.0' encoding='iso-8859-1'?>\n<svg version='1.1' baseProfile='full'\n xmlns:svg='http://www.w3.org/2000/svg'\n xmlns:rdkit='http://www.rdkit.org/xml'\n xmlns:xlink='http://www.w3.org/1999/xlink'\n xml:space='preserve'\nwidth='200px' height='200px' >\n<path d='M 190.909,100 145.455,178.73' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 190.909,100 145.455,21.2704' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 145.455,178.73 54.5455,178.73' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 54.5455,178.73 9.09091,100' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 9.09091,100 54.5455,21.2704' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 54.5455,21.2704 145.455,21.2704' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 190.909,100 145.455,178.73' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 190.909,100 145.455,21.2704' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 145.455,178.73 54.5455,178.73' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 54.5455,178.73 9.09091,100' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 9.09091,100 54.5455,21.2704' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n<path d='M 54.5455,21.2704 145.455,21.2704' style='fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' />\n</svg>\n" ) self.assertEqual(output_mol, svg_str) self.assertTrue(type(output_mol) == str) none_output_mol = draw_mol("C1CcccC1") self.assertEqual(none_output_mol, "None Mol")
def get_mol_image(self, obj): request = self.context["request"] params = request.query_params if params: return draw_mol( obj.smiles, height=int(float(params["height"])), width=int(float(params["width"])), ) else: return draw_mol(obj.smiles, height=125, width=125)
def get_cmpd_image(self, obj): return draw_mol(obj.smiles, height=125, width=125)