Skip to content

Instantly share code, notes, and snippets.

@jhjensen2
jhjensen2 / graph_edit_distance.py
Last active April 25, 2024 20:41
Compute graph edit distance between two molecules using RDKit and Networkx
'''
Written by Jan H. Jensen, 2020
'''
from rdkit import Chem
import networkx as nx
def get_graph(mol):
Chem.Kekulize(mol)
atoms = [atom.GetAtomicNum() for atom in mol.GetAtoms()]
#!/usr/bin/env python
import copy
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.animation as animation
"""
@jhjensen2
jhjensen2 / noninteracting_particle_md.ipynb
Created October 30, 2018 20:42
noninteracting_particle_MD.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from rdkit import Chem
import itertools
smiles = 'CNCC[NH+](C)CC(F)C'
mol = Chem.MolFromSmiles(smiles)
N_atoms = mol.GetSubstructMatches(Chem.MolFromSmarts('N([*])[*]'))
chiral = Chem.FindMolChiralCenters(mol, includeUnassigned=True)
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
import string
filename_smiles = "/Users/jan/Desktop/diels_alder.smiles"
molecules = []
names = []
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import clear_output
import time
n_particles = 100
for x in range(50):
clear_output(wait=True)
positions_x = [np.random.random() for i in range(n_particles)]
#!/usr/bin/env python
import copy
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.animation as animation
"""
from rdkit import Chem
from rdkit.Chem import AllChem
from itertools import islice
raw_smiles = ['NCCN']
smiles_list = ['NCCN']
rxn_smarts_list = ['[C:1][*:2][C:3]>>[C:1]1[*:2][C:3]1','[C:1][C:2]>>[C:1][C][C:2]']
molecules = []
mol = Chem.MolFromSmiles(smiles_list[0])
from rdkit import Chem
import itertools
atoms = ["C","N","O","F","Si","P","S","Cl","Br","I"]
bonds = ["","=","#"]
raw_smiles = []
mols = []
smiles_list = []
from rdkit import Chem
from rdkit.Chem import AllChem
from itertools import islice
smiles_list = ['C12=CC=CC=CC1CC=C2']
#smiles_list = ['C1=CC2CC=CC2=c2ccccc2=C1']
rxn_smarts_list = ['[CX3,cX3;H1:1]~[CX3,cX3;H1:2]>>[c:1]1[c:2]cccc1']
molecules = []
mol = Chem.MolFromSmiles(smiles_list[0])
molecules.append(mol)