[docs]defvisualize_mol(mol,size=(300,300),surface=False,opacity=0.5):"""Draw molecule in 3D Args: ---- mol: rdMol, molecule to show size: tuple(int, int), canvas size style: str, type of drawing molecule style can be 'line', 'stick', 'sphere', 'carton' surface, bool, display SAS opacity, float, opacity of surface, range 0.0-1.0 Return: ---- viewer: py3Dmol.view, a class for constructing embedded 3Dmol.js views in ipython notebooks. """# assert style in ('line', 'stick', 'sphere', 'carton')mblock=Chem.MolToMolBlock(mol)viewer=py3Dmol.view(width=size[0],height=size[1])viewer.addModel(mblock,'mol')viewer.setStyle({'stick':{},'sphere':{'radius':0.35}})ifsurface:viewer.addSurface(py3Dmol.SAS,{'opacity':opacity})viewer.zoomTo()returnviewer