Python rdkit.Chem.MolToMolBlock() Examples
The following are 8
code examples of rdkit.Chem.MolToMolBlock().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rdkit.Chem
, or try the search function
.
Example #1
Source File: plotter.py From ARC with MIT License | 5 votes |
def show_sticks(xyz=None, species=None, project_directory=None): """ Draws the molecule in a "sticks" style according to the supplied xyz coordinates. Returns whether successful of not. If successful, saves the image using draw_3d. Either ``xyz`` or ``species`` must be specified. Args: xyz (str, dict, optional): The coordinates to display. species (ARCSpecies, optional): xyz coordinates will be taken from the species. project_directory (str): ARC's project directory to save a draw_3d image in. Returns: bool: Whether the show_sticks drawing was successful. ``True`` if it was. """ xyz = check_xyz_species_for_drawing(xyz, species) if species is None: s_mol, b_mol = molecules_from_xyz(xyz) mol = b_mol if b_mol is not None else s_mol else: mol = species.mol.copy(deep=True) try: conf, rd_mol = rdkit_conf_from_mol(mol, xyz) except (ValueError, AttributeError): return False if conf is None: return False mb = Chem.MolToMolBlock(rd_mol) p = p3D.view(width=400, height=400) p.addModel(mb, 'sdf') p.setStyle({'stick': {}}) # p.setBackgroundColor('0xeeeeee') p.zoomTo() p.show() if project_directory is not None: draw_3d(xyz=xyz, species=species, project_directory=project_directory, save_only=True) return True
Example #2
Source File: cli.py From MolVS with MIT License | 5 votes |
def _write_mol(mol, args): if args.outtype in {'smi', 'smiles'} or args.outfile.name.endswith('smi') or args.outfile.name.endswith('smiles'): args.outfile.write(Chem.MolToSmiles(mol)) args.outfile.write('\n') elif args.outtype in {'mol', 'sdf'} or args.outfile.name.endswith('mol') or args.outfile.name.endswith('sdf'): args.outfile.write(Chem.MolToMolBlock(mol)) else: args.outfile.write(Chem.MolToSmiles(mol)) args.outfile.write('\n')
Example #3
Source File: chemical.py From thermo with MIT License | 5 votes |
def draw_3d(self, width=300, height=500, style='stick', Hs=True): # pragma: no cover r'''Interface for drawing an interactive 3D view of the molecule. Requires an HTML5 browser, and the libraries RDKit, pymol3D, and IPython. An exception is raised if all three of these libraries are not installed. Parameters ---------- width : int Number of pixels wide for the view height : int Number of pixels tall for the view style : str One of 'stick', 'line', 'cross', or 'sphere' Hs : bool Whether or not to show hydrogen Examples -------- >>> Chemical('cubane').draw_3d() <IPython.core.display.HTML object> ''' try: import py3Dmol from IPython.display import display if Hs: mol = self.rdkitmol_Hs else: mol = self.rdkitmol AllChem.EmbedMultipleConfs(mol) mb = Chem.MolToMolBlock(mol) p = py3Dmol.view(width=width,height=height) p.addModel(mb,'sdf') p.setStyle({style:{}}) p.zoomTo() display(p.show()) except: return 'py3Dmol, RDKit, and IPython are required for this feature.'
Example #4
Source File: chopRDKit03.py From eMolFrag with GNU General Public License v3.0 | 5 votes |
def ReconnectDoubleBond(parentMol, inputFrags): parentMolblock = Chem.MolToMolBlock(parentMol) fragmentMolblocks = [] for i in range(len(inputFrags)): tempFragStr = Chem.MolToMolBlock(inputFrags[i]) fragmentMolblocks.append(tempFragStr) newFragmentMolBlocks = [] dbFragList = [] for i in range(len(inputFrags)): tempValue = FindDoubleBonds(inputFrags[i]) if tempValue >= 0: # Find C.2 = C.2 bond dbFragList.append(fragmentMolblocks[i]) else: newFragmentMolBlocks.append(fragmentMolblocks[i]) reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList) newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags newFragmentMol = [] for i in range(len(newFragmentMolBlocks)): tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i]) newFragmentMol.append(tempFragMol) # return tuple mol-objects return tuple(newFragmentMol)
Example #5
Source File: newFrag02.py From eMolFrag with GNU General Public License v3.0 | 5 votes |
def ReconnectDoubleBond(parentMol, inputFrags): parentMolblock = Chem.MolToMolBlock(parentMol) fragmentMolblocks = [] for i in range(len(inputFrags)): tempFragStr = Chem.MolToMolBlock(inputFrags[i]) fragmentMolblocks.append(tempFragStr) newFragmentMolBlocks = [] dbFragList = [] for i in range(len(inputFrags)): tempValue = FindDoubleBonds(inputFrags[i]) if tempValue >= 0: # Find C.2 = C.2 bond dbFragList.append(fragmentMolblocks[i]) else: newFragmentMolBlocks.append(fragmentMolblocks[i]) reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList) newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags newFragmentMol = [] for i in range(len(newFragmentMolBlocks)): tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i],sanitize=False) newFragmentMol.append(tempFragMol) # return tuple mol-objects return tuple(newFragmentMol)
Example #6
Source File: chopRDKit03.py From eMolFrag with GNU General Public License v3.0 | 5 votes |
def ReconnectDoubleBond(parentMol, inputFrags): parentMolblock = Chem.MolToMolBlock(parentMol,kekulize=False) fragmentMolblocks = [] for i in range(len(inputFrags)): tempFragStr = Chem.MolToMolBlock(inputFrags[i],kekulize=False) fragmentMolblocks.append(tempFragStr) newFragmentMolBlocks = [] dbFragList = [] for i in range(len(inputFrags)): tempValue = FindDoubleBonds(inputFrags[i]) if tempValue >= 0: # Find C.2 = C.2 bond dbFragList.append(fragmentMolblocks[i]) else: newFragmentMolBlocks.append(fragmentMolblocks[i]) reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList) newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags newFragmentMol = [] for i in range(len(newFragmentMolBlocks)): tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i], sanitize=False) newFragmentMol.append(tempFragMol) #print('test') # return tuple mol-objects return tuple(newFragmentMol)
Example #7
Source File: newFrag02.py From eMolFrag with GNU General Public License v3.0 | 5 votes |
def ReconnectDoubleBond(parentMol, inputFrags): parentMolblock = Chem.MolToMolBlock(parentMol) fragmentMolblocks = [] for i in range(len(inputFrags)): tempFragStr = Chem.MolToMolBlock(inputFrags[i]) fragmentMolblocks.append(tempFragStr) newFragmentMolBlocks = [] dbFragList = [] for i in range(len(inputFrags)): tempValue = FindDoubleBonds(inputFrags[i]) if tempValue >= 0: # Find C.2 = C.2 bond dbFragList.append(fragmentMolblocks[i]) else: newFragmentMolBlocks.append(fragmentMolblocks[i]) reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList) newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags newFragmentMol = [] for i in range(len(newFragmentMolBlocks)): tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i],sanitize=False) newFragmentMol.append(tempFragMol) # return tuple mol-objects return tuple(newFragmentMol)
Example #8
Source File: chopRDKit03.py From eMolFrag with GNU General Public License v3.0 | 5 votes |
def ReconnectDoubleBond(parentMol, inputFrags): parentMolblock = Chem.MolToMolBlock(parentMol,kekulize=False) fragmentMolblocks = [] for i in range(len(inputFrags)): tempFragStr = Chem.MolToMolBlock(inputFrags[i],kekulize=False) fragmentMolblocks.append(tempFragStr) newFragmentMolBlocks = [] dbFragList = [] for i in range(len(inputFrags)): tempValue = FindDoubleBonds(inputFrags[i]) if tempValue >= 0: # Find C.2 = C.2 bond dbFragList.append(fragmentMolblocks[i]) else: newFragmentMolBlocks.append(fragmentMolblocks[i]) reconnectedDBFrags = ProcessDoubleBonds(parentMolblock, dbFragList) newFragmentMolBlocks = newFragmentMolBlocks + reconnectedDBFrags newFragmentMol = [] for i in range(len(newFragmentMolBlocks)): tempFragMol = Chem.MolFromMolBlock(newFragmentMolBlocks[i], sanitize=False) newFragmentMol.append(tempFragMol) #print('test') # return tuple mol-objects return tuple(newFragmentMol)