From 782ae651001204383fe287c612e2fa6b6cf6165e Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Thu, 29 Apr 2021 20:24:53 +0800 Subject: [PATCH 01/28] add BondOrderSystem --- dpdata/mol/mol.py | 1 + dpdata/rdkit/utils.py | 49 +++++++ dpdata/system.py | 122 +++++++++++++++++- tests/bond_order/CH3OH.mol | 16 +++ tests/bond_order/CH3SO3H.mol | 22 ++++ tests/bond_order/HCN.mol | 10 ++ tests/bond_order/HNC.mol | 17 +++ tests/bond_order/HNC.pdb | 16 +++ tests/bond_order/HNC_out.mol | 17 +++ tests/bond_order/deepmd_raw_test/box.raw | 1 + tests/bond_order/deepmd_raw_test/coord.raw | 1 + tests/bond_order/deepmd_raw_test/type.raw | 52 ++++++++ tests/bond_order/deepmd_raw_test/type_map.raw | 5 + tests/bond_order/formal_charge.mol | 111 ++++++++++++++++ tests/bond_order/test.ipynb | 45 +++++++ tests/test_bond_order_system.py | 25 ++++ 16 files changed, 509 insertions(+), 1 deletion(-) create mode 100644 dpdata/mol/mol.py create mode 100644 dpdata/rdkit/utils.py create mode 100644 tests/bond_order/CH3OH.mol create mode 100644 tests/bond_order/CH3SO3H.mol create mode 100644 tests/bond_order/HCN.mol create mode 100644 tests/bond_order/HNC.mol create mode 100644 tests/bond_order/HNC.pdb create mode 100644 tests/bond_order/HNC_out.mol create mode 100644 tests/bond_order/deepmd_raw_test/box.raw create mode 100644 tests/bond_order/deepmd_raw_test/coord.raw create mode 100644 tests/bond_order/deepmd_raw_test/type.raw create mode 100644 tests/bond_order/deepmd_raw_test/type_map.raw create mode 100644 tests/bond_order/formal_charge.mol create mode 100644 tests/bond_order/test.ipynb create mode 100644 tests/test_bond_order_system.py diff --git a/dpdata/mol/mol.py b/dpdata/mol/mol.py new file mode 100644 index 000000000..a4b649847 --- /dev/null +++ b/dpdata/mol/mol.py @@ -0,0 +1 @@ +def \ No newline at end of file diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py new file mode 100644 index 000000000..7a283261d --- /dev/null +++ b/dpdata/rdkit/utils.py @@ -0,0 +1,49 @@ +from rdkit import Chem +import numpy as np + +def mol_to_system_data(mol): + num_confs = mol.GetNumConformers() + if num_confs: + atom_symbols = [at.GetSymbol() for at in mol.GetAtoms()] + atom_names, atom_types, atom_numbs = np.unique(atom_symbols, return_inverse=True, return_counts=True) + coords = np.array([conf.GetPositions() for conf in mol.GetConformers()]) + bonds = [[bond.GetBeginAtomIdx(), + bond.GetEndAtomIdx(), + bond.GetBondTypeAsDouble()] for bond in mol.GetBonds()] + formal_charges = [at.GetFormalCharge() for at in mol.GetAtoms()] + data = {} + data['atom_numbs'] = atom_numbs + data['atom_names'] = atom_names + data['atom_types'] = atom_types + data['cells'] = np.array([[[100., 0., 0.], + [0., 100., 0.], + [0., 0., 100.]] for _ in range(num_confs)]) + data['coords'] = coords + data['bonds'] = bonds + data['formal_charges'] = formal_charges + data['orig'] = np.array([0., 0., 0.]) + return data + else: + raise ValueError("The moleclue does not contain 3-D conformers") + + +def regularize_formal_charges(mol): + """ + Regularize formal charges of N, O + """ + for atom in mol.GetAtoms(): + if atom.GetSymbol() == "N" and atom.GetExplicitValence() == 4: + atom.SetFormalCharge(1) + elif atom.GetSymbol() == "N" and atom.GetExplicitValence() == 2: + atom.SetFormalCharge(-1) + elif atom.GetSymbol() == "O" and atom.GetExplicitValence() == 3: + atom.SetFormalCharge(1) + elif atom.GetSymbol() == "O" and atom.GetExplicitValence() == 1: + atom.SetFormalCharge(-1) + elif atom.GetSymbol() == "S" and atom.GetExplicitValence() == 3: + atom.SetFormalCharge(1) + elif atom.GetSymbol() == "S" and atom.GetExplicitValence() == 1: + atom.SetFormalCharge(-1) + Chem.SanitizeMol(mol) + return mol + diff --git a/dpdata/system.py b/dpdata/system.py index f5e1ffb3e..82708759a 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1652,5 +1652,125 @@ def elements_index_map(elements,standard=False,inverse=False): return dict(zip(elements,range(len(elements)))) +#%% +# Bond Order System +import rdkit.Chem +import dpdata.rdkit.utils + +def check_BondOrderSystem(data): + check_System(data) + assert ('bonds' in data.keys()) + if 'formal_charges' not in data.keys(): + raise Warning("no formal_charges are given, formal_charges will be assigned automatically.") + else: + assert (len(data['formal_charges']) == len(data['atom_types'])) + +class BondOrderSystem(System): + ''' + The system with chemical bond and formal charges information + + For example, a labeled methane system named `d_example` has one molecule (5 atoms, 4 bonds) and `n_frames` frames. The bond order and formal charge information can be accessed by + - `d_example['bonds']` : a numpy array of size 4 x 3, and + the first column represents the index of begin atom, + the second column represents the index of end atom, + the third columen represents the bond order: + 1 - single bond, 2 - double bond, 3 - triple bond, 1.5 - aromatic bond + - `d_example['formal_charges']` : a numpy array of size 5 x 1 + ''' + def __init__(self, + file_name = None, + fmt = 'auto', + type_map = None, + begin = 0, + step = 1, + data = None, + **kwargs): + """ + Constructor + + Parameters + ---------- + file_name : str + The file to load the system + fmt : str + Format of the file, supported formats are + - ``auto`` : inferred from `file_name`'s extention + - ``mol`` : .mol file + - ``sdf`` : .sdf file + type_map : list of str + Needed by formats deepmd/raw and deepmd/npy. Maps atom type to name. The atom with type `ii` is mapped to `type_map[ii]`. + If not provided the atom names are assigned to `'Type_1'`, `'Type_2'`, `'Type_3'`... + begin : int + The beginning frame when loading MD trajectory. + step : int + The number of skipped frames when loading MD trajectory. + """ + + System.__init__(self) + self.rdkit_mol = None + + if data: + check_BondOrderSystem(data) + self.data = data + if 'formal_charges' not in data.keys(): + self.assign_formal_charges() + return + if file_name is None: + return + self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) + + if type_map is not None: + self.apply_type_map(type_map) + + register_from_funcs = Register() + register_to_funcs = Register() + + def __repr__(self): + return self.__str__() + + def __str__(self): + ret += "Data Summary" + ret += "\nBondOrder System" + ret += "\n-------------------" + ret += f"\nFrame Numbers : {self.get_nframes()}" + ret += f"\nAtom Numbers : {self.get_natoms()}" + ret += f"\nBond Numbers : {self.get_nbonds()}" + ret += "\nElement List :" + ret += "\n-------------------" + ret += "\n"+" ".join(map(str,self.get_atom_names())) + ret += "\n"+" ".join(map(str,self.get_atom_numbs())) + + def get_nbonds(self): + return len(self.data['bonds']) + + def __add__(self, other): + raise RuntimeError("Not supported yet.") + + def assign_formal_charges(self): + self.data['formal_charges'] = [0 for _ in self.get_natoms()] # this function is to be improved + + @register_from_funcs.register_funcs('mol') + def from_mol_file(self, file_name): + mol = rdkit.Chem.MolFromMolFile(file_name, sanitize=False, removeHs=False) + try: + print(f"Try to reading {file_name}...") + rdkit.Chem.SanitizeMol(mol) + except: + print("Regularizing mol because an error occured as shown above...") + mol = dpdata.rdkit.utils.regularize_formal_charges(mol) + print(f'Read {file_name} successfully.') + else: + print(f"Read {file_name} successfully.") + self.data = dpdata.rdkit.utils.mol_to_system_data(mol) + self.rdkit_mol = mol + + @register_to_funcs.register_funcs("mol") + def to_mol_file(self, file_name): + if isinstance(self.rdkit_mol, rdkit.Chem.rdchem.Mol): + rdkit.Chem.MolToMolFile(self.rdkit_mol, file_name) + else: + raise TypeError(f"rdkit.Chem.rdChem.Mol type required, not {type(self.rdkit_mol)}") -# %% + @register_from_funcs.register_funcs('sdf') + def from_sdf_file(self, file_name): + pass \ No newline at end of file diff --git a/tests/bond_order/CH3OH.mol b/tests/bond_order/CH3OH.mol new file mode 100644 index 000000000..ae2647120 --- /dev/null +++ b/tests/bond_order/CH3OH.mol @@ -0,0 +1,16 @@ + + RDKit 3D + + 6 5 0 0 0 0 0 0 0 0999 V2000 + -0.3858 0.0121 -0.0046 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9338 0.3744 -0.2961 O 0 0 0 0 0 0 0 0 0 0 0 0 + -0.4710 -0.6137 0.8940 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.7417 -0.5863 -0.8591 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.9359 0.9788 0.1119 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.6006 -0.1653 0.1539 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 + 2 6 1 0 +M END diff --git a/tests/bond_order/CH3SO3H.mol b/tests/bond_order/CH3SO3H.mol new file mode 100644 index 000000000..c1ea77eee --- /dev/null +++ b/tests/bond_order/CH3SO3H.mol @@ -0,0 +1,22 @@ + + RDKit 2D + + 9 8 0 0 0 0 0 0 0 0999 V2000 + 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.5000 0.0000 0.0000 S 0 0 0 0 0 6 0 0 0 0 0 0 + 3.0000 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.5000 -1.5000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.5000 1.5000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.5000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0000 1.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0000 -1.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2.7990 2.2500 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 2 0 + 2 4 2 0 + 2 5 1 0 + 1 6 1 0 + 1 7 1 0 + 1 8 1 0 + 5 9 1 0 +M END diff --git a/tests/bond_order/HCN.mol b/tests/bond_order/HCN.mol new file mode 100644 index 000000000..24d878a63 --- /dev/null +++ b/tests/bond_order/HCN.mol @@ -0,0 +1,10 @@ + + RDKit 3D + + 3 2 0 0 0 0 0 0 0 0999 V2000 + -0.0357 0.0066 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.1287 -0.0077 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0929 0.0011 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 3 0 + 1 3 1 0 +M END diff --git a/tests/bond_order/HNC.mol b/tests/bond_order/HNC.mol new file mode 100644 index 000000000..8ba06a0b2 --- /dev/null +++ b/tests/bond_order/HNC.mol @@ -0,0 +1,17 @@ + + RDKit 2D + + 6 5 0 0 0 0 0 0 0 0999 V2000 + -0.0000 -3.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0000 -1.5000 0.0000 N 0 0 0 0 0 4 0 0 0 0 0 0 + 0.0000 0.0000 0.0000 C 0 0 0 0 0 3 0 0 0 0 0 0 + -0.0000 -4.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 3 0 + 1 4 1 0 + 1 5 1 0 + 1 6 1 0 +M CHG 2 2 1 3 -1 +M END diff --git a/tests/bond_order/HNC.pdb b/tests/bond_order/HNC.pdb new file mode 100644 index 000000000..2dbb6c8d2 --- /dev/null +++ b/tests/bond_order/HNC.pdb @@ -0,0 +1,16 @@ +COMPND UNNAMED +AUTHOR GENERATED BY OPEN BABEL 3.1.0 +HETATM 1 C UNL 1 0.000 -3.000 0.000 1.00 0.00 C +HETATM 2 N UNL 1 0.000 -1.500 0.000 1.00 0.00 N1+ +HETATM 3 C UNL 1 0.000 0.000 0.000 1.00 0.00 C1- +HETATM 4 H UNL 1 0.000 -4.500 0.000 1.00 0.00 H +HETATM 5 H UNL 1 1.500 -3.000 0.000 1.00 0.00 H +HETATM 6 H UNL 1 -1.500 -3.000 0.000 1.00 0.00 H +CONECT 1 2 4 5 6 +CONECT 2 1 3 3 3 +CONECT 3 2 2 2 +CONECT 4 1 +CONECT 5 1 +CONECT 6 1 +MASTER 0 0 0 0 0 0 0 0 6 0 6 0 +END diff --git a/tests/bond_order/HNC_out.mol b/tests/bond_order/HNC_out.mol new file mode 100644 index 000000000..347736ca7 --- /dev/null +++ b/tests/bond_order/HNC_out.mol @@ -0,0 +1,17 @@ +HNC.pdb + OpenBabel04292118033D + + 6 5 0 0 0 0 0 0 0 0999 V2000 + 0.0000 -3.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0000 -1.5000 0.0000 N 0 3 0 0 0 0 0 0 0 0 0 0 + 0.0000 0.0000 0.0000 C 0 5 0 0 0 0 0 0 0 0 0 0 + 0.0000 -4.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 1 4 1 0 0 0 0 + 1 5 1 0 0 0 0 + 1 6 1 0 0 0 0 + 2 3 3 0 0 0 0 +M CHG 2 2 1 3 -1 +M END diff --git a/tests/bond_order/deepmd_raw_test/box.raw b/tests/bond_order/deepmd_raw_test/box.raw new file mode 100644 index 000000000..43b6dc19a --- /dev/null +++ b/tests/bond_order/deepmd_raw_test/box.raw @@ -0,0 +1 @@ +1.000000000000000000e+02 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+02 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+02 diff --git a/tests/bond_order/deepmd_raw_test/coord.raw b/tests/bond_order/deepmd_raw_test/coord.raw new file mode 100644 index 000000000..3350762e5 --- /dev/null +++ b/tests/bond_order/deepmd_raw_test/coord.raw @@ -0,0 +1 @@ +1.826999999999999957e+01 -1.324000000000000021e+01 2.171000000000000085e+01 1.807000000000000028e+01 -1.193999999999999950e+01 2.103000000000000114e+01 1.739999999999999858e+01 -1.377999999999999936e+01 2.260000000000000142e+01 1.639999999999999858e+01 -1.316999999999999993e+01 2.298000000000000043e+01 1.666000000000000014e+01 -1.175000000000000000e+01 2.041000000000000014e+01 1.616000000000000014e+01 -1.265000000000000036e+01 1.971999999999999886e+01 1.916000000000000014e+01 -1.189000000000000057e+01 1.996000000000000085e+01 1.764999999999999858e+01 -1.517999999999999972e+01 2.319000000000000128e+01 1.603999999999999915e+01 -1.058999999999999986e+01 2.064999999999999858e+01 2.026000000000000156e+01 -1.282000000000000028e+01 2.044999999999999929e+01 1.641000000000000014e+01 -1.597000000000000064e+01 2.310999999999999943e+01 1.814000000000000057e+01 -1.510999999999999943e+01 2.466000000000000014e+01 1.469999999999999929e+01 -1.022000000000000064e+01 2.021999999999999886e+01 1.955000000000000071e+01 -1.383999999999999986e+01 2.132000000000000028e+01 1.955999999999999872e+01 -1.461999999999999922e+01 2.482999999999999829e+01 1.364000000000000057e+01 -1.035999999999999943e+01 2.128999999999999915e+01 1.980000000000000071e+01 -1.331000000000000050e+01 2.528999999999999915e+01 1.290000000000000036e+01 -1.155000000000000071e+01 2.142000000000000171e+01 2.110999999999999943e+01 -1.282000000000000028e+01 2.539999999999999858e+01 1.189000000000000057e+01 -1.166000000000000014e+01 2.239999999999999858e+01 2.219999999999999929e+01 -1.364000000000000057e+01 2.505000000000000071e+01 1.161999999999999922e+01 -1.057000000000000028e+01 2.325000000000000000e+01 2.196999999999999886e+01 -1.496000000000000085e+01 2.462999999999999901e+01 1.236999999999999922e+01 -9.380000000000000782e+00 2.314999999999999858e+01 2.064999999999999858e+01 -1.544999999999999929e+01 2.451000000000000156e+01 1.336999999999999922e+01 -9.279999999999999361e+00 2.216000000000000014e+01 1.825000000000000000e+01 -1.116000000000000014e+01 2.176000000000000156e+01 1.878999999999999915e+01 -1.225000000000000000e+01 1.898999999999999844e+01 1.953999999999999915e+01 -1.089000000000000057e+01 1.980999999999999872e+01 1.837999999999999901e+01 -1.573000000000000043e+01 2.260000000000000142e+01 1.655999999999999872e+01 -9.890000000000000568e+00 2.117999999999999972e+01 2.082999999999999829e+01 -1.326999999999999957e+01 1.962999999999999901e+01 2.096999999999999886e+01 -1.225000000000000000e+01 2.105999999999999872e+01 1.655000000000000071e+01 -1.687999999999999901e+01 2.351000000000000156e+01 1.567999999999999972e+01 -1.548000000000000043e+01 2.362000000000000099e+01 1.612999999999999901e+01 -1.605000000000000071e+01 2.214999999999999858e+01 1.746000000000000085e+01 -1.449000000000000021e+01 2.525000000000000000e+01 1.808999999999999986e+01 -1.610000000000000142e+01 2.510999999999999943e+01 1.474000000000000021e+01 -9.160000000000000142e+00 1.994000000000000128e+01 1.441000000000000014e+01 -1.075999999999999979e+01 1.932000000000000028e+01 2.016000000000000014e+01 -1.409999999999999964e+01 2.217000000000000171e+01 1.935999999999999943e+01 -1.475000000000000000e+01 2.073999999999999844e+01 1.898999999999999844e+01 -1.267999999999999972e+01 2.558999999999999986e+01 1.311999999999999922e+01 -1.239000000000000057e+01 2.076999999999999957e+01 2.126999999999999957e+01 -1.181000000000000050e+01 2.576000000000000156e+01 1.133000000000000007e+01 -1.257000000000000028e+01 2.250000000000000000e+01 2.321000000000000085e+01 -1.326999999999999957e+01 2.514000000000000057e+01 2.280999999999999872e+01 -1.559999999999999964e+01 2.439000000000000057e+01 1.216999999999999993e+01 -8.369999999999999218e+00 2.398999999999999844e+01 2.048999999999999844e+01 -1.646000000000000085e+01 2.417000000000000171e+01 1.394999999999999929e+01 -8.369999999999999218e+00 2.208999999999999986e+01 1.084999999999999964e+01 -1.065000000000000036e+01 2.401000000000000156e+01 diff --git a/tests/bond_order/deepmd_raw_test/type.raw b/tests/bond_order/deepmd_raw_test/type.raw new file mode 100644 index 000000000..1fcd91d9d --- /dev/null +++ b/tests/bond_order/deepmd_raw_test/type.raw @@ -0,0 +1,52 @@ +3 +0 +0 +4 +0 +4 +0 +0 +3 +0 +3 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +1 +2 +2 +2 diff --git a/tests/bond_order/deepmd_raw_test/type_map.raw b/tests/bond_order/deepmd_raw_test/type_map.raw new file mode 100644 index 000000000..52bc03ef6 --- /dev/null +++ b/tests/bond_order/deepmd_raw_test/type_map.raw @@ -0,0 +1,5 @@ +C +F +H +N +O diff --git a/tests/bond_order/formal_charge.mol b/tests/bond_order/formal_charge.mol new file mode 100644 index 000000000..141f5f81d --- /dev/null +++ b/tests/bond_order/formal_charge.mol @@ -0,0 +1,111 @@ +mol_out.pdb + OpenBabel04242116493D + + 52 54 0 0 1 0 0 0 0 0999 V2000 + 18.2700 -13.2400 21.7100 N 0 0 0 0 0 0 0 0 0 0 0 0 + 18.0700 -11.9400 21.0300 C 0 0 2 0 0 0 0 0 0 0 0 0 + 17.4000 -13.7800 22.6000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 16.4000 -13.1700 22.9800 O 0 0 0 0 0 0 0 0 0 0 0 0 + 16.6600 -11.7500 20.4100 C 0 0 0 0 0 0 0 0 0 0 0 0 + 16.1600 -12.6500 19.7200 O 0 0 0 0 0 0 0 0 0 0 0 0 + 19.1600 -11.8900 19.9600 C 0 0 0 0 0 0 0 0 0 0 0 0 + 17.6500 -15.1800 23.1900 C 0 0 2 0 0 0 0 0 0 0 0 0 + 16.0400 -10.5900 20.6500 N 0 0 0 0 0 0 0 0 0 0 0 0 + 20.2600 -12.8200 20.4500 C 0 0 0 0 0 0 0 0 0 0 0 0 + 16.4100 -15.9700 23.1100 N 0 0 0 0 0 4 0 0 0 0 0 0 + 18.1400 -15.1100 24.6600 C 0 0 0 0 0 0 0 0 0 0 0 0 + 14.7000 -10.2200 20.2200 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.5500 -13.8400 21.3200 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.5600 -14.6200 24.8300 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.6400 -10.3600 21.2900 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.8000 -13.3100 25.2900 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.9000 -11.5500 21.4200 C 0 0 0 0 0 0 0 0 0 0 0 0 + 21.1100 -12.8200 25.4000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.8900 -11.6600 22.4000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 22.2000 -13.6400 25.0500 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.6200 -10.5700 23.2500 C 0 0 0 0 0 0 0 0 0 0 0 0 + 21.9700 -14.9600 24.6300 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.3700 -9.3800 23.1500 C 0 0 0 0 0 0 0 0 0 0 0 0 + 20.6500 -15.4500 24.5100 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.3700 -9.2800 22.1600 C 0 0 0 0 0 0 0 0 0 0 0 0 + 18.2500 -11.1600 21.7600 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.7900 -12.2500 18.9900 H 0 0 0 0 0 0 0 0 0 0 0 0 + 19.5400 -10.8900 19.8100 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.3800 -15.7300 22.6000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 16.5600 -9.8900 21.1800 H 0 0 0 0 0 0 0 0 0 0 0 0 + 20.8300 -13.2700 19.6300 H 0 0 0 0 0 0 0 0 0 0 0 0 + 20.9700 -12.2500 21.0600 H 0 0 0 0 0 0 0 0 0 0 0 0 + 16.5500 -16.8800 23.5100 H 0 0 0 0 0 0 0 0 0 0 0 0 + 15.6800 -15.4800 23.6200 H 0 0 0 0 0 0 0 0 0 0 0 0 + 16.1300 -16.0500 22.1500 H 0 0 0 0 0 0 0 0 0 0 0 0 + 17.4600 -14.4900 25.2500 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.0900 -16.1000 25.1100 H 0 0 0 0 0 0 0 0 0 0 0 0 + 14.7400 -9.1600 19.9400 H 0 0 0 0 0 0 0 0 0 0 0 0 + 14.4100 -10.7600 19.3200 H 0 0 0 0 0 0 0 0 0 0 0 0 + 20.1600 -14.1000 22.1700 H 0 0 0 0 0 0 0 0 0 0 0 0 + 19.3600 -14.7500 20.7400 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.9900 -12.6800 25.5900 H 0 0 0 0 0 0 0 0 0 0 0 0 + 13.1200 -12.3900 20.7700 H 0 0 0 0 0 0 0 0 0 0 0 0 + 21.2700 -11.8100 25.7600 H 0 0 0 0 0 0 0 0 0 0 0 0 + 11.3300 -12.5700 22.5000 H 0 0 0 0 0 0 0 0 0 0 0 0 + 23.2100 -13.2700 25.1400 H 0 0 0 0 0 0 0 0 0 0 0 0 + 22.8100 -15.6000 24.3900 H 0 0 0 0 0 0 0 0 0 0 0 0 + 12.1700 -8.3700 23.9900 F 0 0 0 0 0 0 0 0 0 0 0 0 + 20.4900 -16.4600 24.1700 H 0 0 0 0 0 0 0 0 0 0 0 0 + 13.9500 -8.3700 22.0900 H 0 0 0 0 0 0 0 0 0 0 0 0 + 10.8500 -10.6500 24.0100 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 3 1 0 0 0 0 + 2 1 1 0 0 0 0 + 2 27 1 1 0 0 0 + 3 4 2 0 0 0 0 + 3 8 1 0 0 0 0 + 5 9 1 0 0 0 0 + 5 2 1 0 0 0 0 + 6 5 2 0 0 0 0 + 7 10 1 0 0 0 0 + 7 2 1 0 0 0 0 + 8 30 1 6 0 0 0 + 8 12 1 0 0 0 0 + 9 31 1 0 0 0 0 + 10 33 1 0 0 0 0 + 10 14 1 0 0 0 0 + 11 8 1 0 0 0 0 + 11 34 1 0 0 0 0 + 11 35 1 0 0 0 0 + 12 15 1 0 0 0 0 + 12 38 1 0 0 0 0 + 12 37 1 0 0 0 0 + 13 9 1 0 0 0 0 + 13 16 1 0 0 0 0 + 14 1 1 0 0 0 0 + 14 41 1 0 0 0 0 + 15 17 1 0 0 0 0 + 16 18 2 0 0 0 0 + 16 26 1 0 0 0 0 + 17 19 2 0 0 0 0 + 17 43 1 0 0 0 0 + 18 20 1 0 0 0 0 + 19 45 1 0 0 0 0 + 20 46 1 0 0 0 0 + 20 22 2 0 0 0 0 + 21 47 1 0 0 0 0 + 21 19 1 0 0 0 0 + 22 52 1 0 0 0 0 + 23 21 2 0 0 0 0 + 24 22 1 0 0 0 0 + 24 49 1 0 0 0 0 + 25 23 1 0 0 0 0 + 25 15 2 0 0 0 0 + 26 24 2 0 0 0 0 + 28 7 1 0 0 0 0 + 29 7 1 0 0 0 0 + 32 10 1 0 0 0 0 + 36 11 1 0 0 0 0 + 39 13 1 0 0 0 0 + 40 13 1 0 0 0 0 + 42 14 1 0 0 0 0 + 44 18 1 0 0 0 0 + 48 23 1 0 0 0 0 + 50 25 1 0 0 0 0 + 51 26 1 0 0 0 0 +M END diff --git a/tests/bond_order/test.ipynb b/tests/bond_order/test.ipynb new file mode 100644 index 000000000..55d32f1da --- /dev/null +++ b/tests/bond_order/test.ipynb @@ -0,0 +1,45 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from rdkit import Chem\n", + "\n", + "mol = Chem.MolFromSmiles(\"C-S(=O)(=O)-O\")\n", + "mol = Chem.AddHs(mol)\n", + "Chem.MolToMolFile(mol, \"CH3SO3H.mol\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.7.7 64-bit ('deepchem': conda)", + "name": "python377jvsc74a57bd0476193a2e7497fa43a98b486e8839ec0be23b54cba7af8d64a14c393f6473c5f" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.7" + }, + "orig_nbformat": 2 + }, + "nbformat": 4, + "nbformat_minor": 2 +} \ No newline at end of file diff --git a/tests/test_bond_order_system.py b/tests/test_bond_order_system.py new file mode 100644 index 000000000..8f203b0af --- /dev/null +++ b/tests/test_bond_order_system.py @@ -0,0 +1,25 @@ +import os +import unittest +from context import dpdata +from rdkit import Chem + +class TestBondOrderSystem(unittest.TestCase): + + def setUp(self): + pass + + def test_regularize_formal_charges(self): + syst = dpdata.BondOrderSystem("bond_order/formal_charge.mol", fmt="mol") + syst.to_mol_file("bond_order/tmp.mol") + mol = Chem.MolFromMolFile("bond_order/tmp.mol") + self.assertTrue(mol) + + def test_read_other_format(self): + self.assertRaises(RuntimeError, dpdata.BondOrderSystem, "gromacs/1h.gro") + + def test_dump_to_deepmd_raw(self): + syst = dpdata.BondOrderSystem("bond_order/tmp.mol", fmt="mol") + syst.to_deepmd_raw("bond_order/deepmd_raw_test") + + def tearDown(self): + os.remove("bond_order/tmp.mol") \ No newline at end of file From 054e293398177bb10bb0d94237e152acae68b651 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Thu, 29 Apr 2021 20:26:06 +0800 Subject: [PATCH 02/28] add BondOrderSystem --- dpdata/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dpdata/__init__.py b/dpdata/__init__.py index 3923f70e5..eb7b379d8 100644 --- a/dpdata/__init__.py +++ b/dpdata/__init__.py @@ -3,6 +3,7 @@ from . import md from .system import System from .system import LabeledSystem +from .system import BondOrderSystem from .system import MultiSystems try: From 9656645f65d5df827b8097fc882884b0c1248171 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Fri, 30 Apr 2021 00:10:55 +0800 Subject: [PATCH 03/28] add BondOrderSystem --- dpdata/mol/mol.py | 1 - dpdata/rdkit/utils.py | 47 ++++++++++++++++++- dpdata/system.py | 66 +++++++++++++++++--------- tests/bond_order/methane.sdf | 60 ++++++++++++++++++++++++ tests/bond_order/methane_ethane.sdf | 72 +++++++++++++++++++++++++++++ tests/bond_order/test.ipynb | 45 ------------------ tests/context.py | 1 + tests/test_bond_order_system.py | 38 ++++++++++----- 8 files changed, 250 insertions(+), 80 deletions(-) delete mode 100644 dpdata/mol/mol.py create mode 100644 tests/bond_order/methane.sdf create mode 100644 tests/bond_order/methane_ethane.sdf delete mode 100644 tests/bond_order/test.ipynb diff --git a/dpdata/mol/mol.py b/dpdata/mol/mol.py deleted file mode 100644 index a4b649847..000000000 --- a/dpdata/mol/mol.py +++ /dev/null @@ -1 +0,0 @@ -def \ No newline at end of file diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index 7a283261d..68ffa1983 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -2,6 +2,11 @@ import numpy as np def mol_to_system_data(mol): + try: + rdkit.Chem.SanitizeMol(mol) + except: + mol = regularize_formal_charges(mol) + num_confs = mol.GetNumConformers() if num_confs: atom_symbols = [at.GetSymbol() for at in mol.GetAtoms()] @@ -12,8 +17,8 @@ def mol_to_system_data(mol): bond.GetBondTypeAsDouble()] for bond in mol.GetBonds()] formal_charges = [at.GetFormalCharge() for at in mol.GetAtoms()] data = {} - data['atom_numbs'] = atom_numbs - data['atom_names'] = atom_names + data['atom_numbs'] = list(atom_numbs) + data['atom_names'] = list(atom_names) data['atom_types'] = atom_types data['cells'] = np.array([[[100., 0., 0.], [0., 100., 0.], @@ -47,3 +52,41 @@ def regularize_formal_charges(mol): Chem.SanitizeMol(mol) return mol + +def check_same_atom(atom_1, atom_2): + if atom_1.GetIdx() != atom_2.GetIdx(): + return False + elif atom_1.GetSymbol() != atom_2.GetSymbol(): + return False + else: + return True + +def check_same_molecule(mol_1, mol_2): + flag = True + for bond_1, bond_2 in zip(mol_1.GetBonds(), mol_2.GetBonds()): + begin_atom_1, end_atom_1 = bond_1.GetBeginAtom(), bond_1.GetEndAtom() + begin_atom_2, end_atom_2 = bond_2.GetBeginAtom(), bond_2.GetEndAtom() + if not check_same_atom(begin_atom_1, begin_atom_2): + flag = False + break + elif not check_same_atom(end_atom_1, end_atom_2): + flag = False + break + return flag + +def check_molecule_list(mols): + flag = True + for mol in mols[1:]: + if not check_same_molecule(mol, mols[0]): + flag = False + break + return flag + +def combine_molecules(mols): + if check_molecule_list(mols): + for mol in mols[1:]: + for conf in mol.GetConformers(): + mols[0].AddConformer(conf, assignId=True) + return mols[0] + else: + raise ValueError("molecules are not of the same topology.") \ No newline at end of file diff --git a/dpdata/system.py b/dpdata/system.py index 82708759a..e7c169c36 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1684,6 +1684,7 @@ def __init__(self, begin = 0, step = 1, data = None, + rdkit_mol = None, **kwargs): """ Constructor @@ -1704,17 +1705,27 @@ def __init__(self, The beginning frame when loading MD trajectory. step : int The number of skipped frames when loading MD trajectory. + data : dict + System data dict. + rdkit_mol : rdkit.Chem.rdchem.Mol + If use `data` to init a BondOrderSystem, a Mol type object consistent to `data` must be given. + So it is suggested to init directly with a rdkit Mol type. """ System.__init__(self) - self.rdkit_mol = None if data: check_BondOrderSystem(data) self.data = data + assert (isinstance(rdkit_mol, rdkit.Chem.rdchem.Mol)) + self.rdkit_mol = rdkit_mol if 'formal_charges' not in data.keys(): self.assign_formal_charges() return + if rdkit_mol: + assert (isinstance(rdkit_mol, rdkit.Chem.rdchem.Mol)) + self.from_rdkit_mol(rdkit_mol) + return if file_name is None: return self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) @@ -1729,7 +1740,7 @@ def __repr__(self): return self.__str__() def __str__(self): - ret += "Data Summary" + ret = "Data Summary" ret += "\nBondOrder System" ret += "\n-------------------" ret += f"\nFrame Numbers : {self.get_nframes()}" @@ -1739,6 +1750,7 @@ def __str__(self): ret += "\n-------------------" ret += "\n"+" ".join(map(str,self.get_atom_names())) ret += "\n"+" ".join(map(str,self.get_atom_numbs())) + return ret def get_nbonds(self): return len(self.data['bonds']) @@ -1749,28 +1761,40 @@ def __add__(self, other): def assign_formal_charges(self): self.data['formal_charges'] = [0 for _ in self.get_natoms()] # this function is to be improved + def from_rdkit_mol(self, rdkit_mol): + self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol) + self.rdkit_mol = rdkit_mol + @register_from_funcs.register_funcs('mol') def from_mol_file(self, file_name): mol = rdkit.Chem.MolFromMolFile(file_name, sanitize=False, removeHs=False) - try: - print(f"Try to reading {file_name}...") - rdkit.Chem.SanitizeMol(mol) - except: - print("Regularizing mol because an error occured as shown above...") - mol = dpdata.rdkit.utils.regularize_formal_charges(mol) - print(f'Read {file_name} successfully.') - else: - print(f"Read {file_name} successfully.") - self.data = dpdata.rdkit.utils.mol_to_system_data(mol) - self.rdkit_mol = mol + self.from_rdkit_mol(mol) @register_to_funcs.register_funcs("mol") - def to_mol_file(self, file_name): - if isinstance(self.rdkit_mol, rdkit.Chem.rdchem.Mol): - rdkit.Chem.MolToMolFile(self.rdkit_mol, file_name) - else: - raise TypeError(f"rdkit.Chem.rdChem.Mol type required, not {type(self.rdkit_mol)}") - - @register_from_funcs.register_funcs('sdf') + def to_mol_file(self, file_name, frame_idx=0): + assert (frame_idx < self.get_nframes()) + rdkit.Chem.MolToMolFile(self.rdkit_mol, file_name, confId=frame_idx) + + @register_from_funcs.register_funcs("sdf") def from_sdf_file(self, file_name): - pass \ No newline at end of file + ''' + Note that it requires all molecules in .sdf file must be of the same topology + ''' + mols = [m for m in rdkit.Chem.SDMolSupplier(file_name, sanitize=False, removeHs=False)] + if len(mols) > 1: + mol = dpdata.rdkit.utils.combine_molecules(mols) + else: + mol = mols[0] + self.from_rdkit_mol(mol) + + @register_to_funcs.register_funcs("sdf") + def to_sdf_file(self, file_name, frame_idx=-1): + sdf_writer = rdkit.Chem.SDWriter(file_name) + if frame_idx == -1: + for ii in self.get_nframes(): + sdf_writer.write(self.rdkit_mol, confId=ii) + else: + assert (frame_idx < self.get_nframes()) + sdf_writer.write(self.rdkit_mol, confId=frame_idx) + sdf_writer.close() +# %% diff --git a/tests/bond_order/methane.sdf b/tests/bond_order/methane.sdf new file mode 100644 index 000000000..a096aafae --- /dev/null +++ b/tests/bond_order/methane.sdf @@ -0,0 +1,60 @@ + + RDKit 3D + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 0.0059 -0.0002 -0.0049 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6493 -0.7327 -0.4834 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.4899 0.9882 -0.0754 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.1439 -0.2888 1.0478 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9894 0.0336 -0.4842 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 +M END +$$$$ + + RDKit 3D + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 0.0043 0.0012 -0.0253 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6943 -0.7305 -0.4680 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3564 0.2344 0.9931 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0543 0.9582 -0.5765 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9921 -0.4633 0.0767 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 +M END +$$$$ + + RDKit 3D + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 0.0071 -0.0179 -0.0048 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6733 -0.6435 -0.6095 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.1825 1.0482 -0.2270 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.2116 -0.1471 1.0799 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0603 -0.2397 -0.2386 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 +M END +$$$$ + + RDKit 3D + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 0.0032 0.0117 -0.0013 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.5479 -0.8736 -0.3523 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.5265 0.9173 -0.3244 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0523 -0.0248 1.0966 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0189 -0.0306 -0.4186 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 +M END +$$$$ diff --git a/tests/bond_order/methane_ethane.sdf b/tests/bond_order/methane_ethane.sdf new file mode 100644 index 000000000..7d3b91dfa --- /dev/null +++ b/tests/bond_order/methane_ethane.sdf @@ -0,0 +1,72 @@ + + RDKit 3D + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 0.0059 -0.0002 -0.0049 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6493 -0.7327 -0.4834 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.4899 0.9882 -0.0754 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.1439 -0.2888 1.0478 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9894 0.0336 -0.4842 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 +M END +$$$$ + + RDKit 3D + + 5 4 0 0 0 0 0 0 0 0999 V2000 + 0.0043 0.0012 -0.0253 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6943 -0.7305 -0.4680 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3564 0.2344 0.9931 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0543 0.9582 -0.5765 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9921 -0.4633 0.0767 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 +M END +$$$$ + + RDKit 3D + + 8 7 0 0 0 0 0 0 0 0999 V2000 + 0.7590 0.0236 -0.0560 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.7547 0.0313 0.0718 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.2611 -0.2202 0.9033 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.1419 0.9856 -0.3997 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9785 -0.8255 -0.7489 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2457 -0.3097 -0.8758 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0093 -0.7228 0.8325 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1307 1.0378 0.2729 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 + 2 6 1 0 + 2 7 1 0 + 2 8 1 0 +M END +$$$$ + + RDKit 3D + + 8 7 0 0 0 0 0 0 0 0999 V2000 + 0.7754 -0.0463 0.0099 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.7512 -0.0348 -0.0031 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.1943 -1.0095 -0.2808 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0852 0.6964 -0.7578 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0697 0.2302 1.0328 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0271 1.0589 0.0390 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1664 -0.4112 -0.9429 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1799 -0.4837 0.9029 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 + 2 6 1 0 + 2 7 1 0 + 2 8 1 0 +M END +$$$$ diff --git a/tests/bond_order/test.ipynb b/tests/bond_order/test.ipynb deleted file mode 100644 index 55d32f1da..000000000 --- a/tests/bond_order/test.ipynb +++ /dev/null @@ -1,45 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "from rdkit import Chem\n", - "\n", - "mol = Chem.MolFromSmiles(\"C-S(=O)(=O)-O\")\n", - "mol = Chem.AddHs(mol)\n", - "Chem.MolToMolFile(mol, \"CH3SO3H.mol\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.7.7 64-bit ('deepchem': conda)", - "name": "python377jvsc74a57bd0476193a2e7497fa43a98b486e8839ec0be23b54cba7af8d64a14c393f6473c5f" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.7" - }, - "orig_nbformat": 2 - }, - "nbformat": 4, - "nbformat_minor": 2 -} \ No newline at end of file diff --git a/tests/context.py b/tests/context.py index c17ef0ea8..95257e195 100644 --- a/tests/context.py +++ b/tests/context.py @@ -3,3 +3,4 @@ import dpdata import dpdata.md.water import dpdata.md.msd +import dpdata.system diff --git a/tests/test_bond_order_system.py b/tests/test_bond_order_system.py index 8f203b0af..edf2ec7f9 100644 --- a/tests/test_bond_order_system.py +++ b/tests/test_bond_order_system.py @@ -4,22 +4,38 @@ from rdkit import Chem class TestBondOrderSystem(unittest.TestCase): - - def setUp(self): - pass + + def test_from_mol_file(self): + syst = dpdata.BondOrderSystem("bond_order/CH3OH.mol", fmt='mol', type_map=['O','C','H']) + self.assertEqual(syst.get_nframes(), 1) + self.assertEqual(syst.get_nbonds(), 5) + self.assertEqual(syst.get_natoms(), 6) + self.assertEqual(syst['atom_names'], ['O','C','H']) + self.assertAlmostEqual(syst['coords'][0][0][0], -0.3858) def test_regularize_formal_charges(self): - syst = dpdata.BondOrderSystem("bond_order/formal_charge.mol", fmt="mol") - syst.to_mol_file("bond_order/tmp.mol") - mol = Chem.MolFromMolFile("bond_order/tmp.mol") - self.assertTrue(mol) + non_regular = Chem.MolFromMolFile("bond_order/formal_charge.mol", removeHs=False) + regular = dpdata.BondOrderSystem("bond_order/formal_charge.mol", fmt="mol") + self.assertFalse(non_regular) + self.assertTrue(isinstance(regular.rdkit_mol, Chem.rdchem.Mol)) - def test_read_other_format(self): + def test_read_other_format_without_bond_info(self): self.assertRaises(RuntimeError, dpdata.BondOrderSystem, "gromacs/1h.gro") def test_dump_to_deepmd_raw(self): - syst = dpdata.BondOrderSystem("bond_order/tmp.mol", fmt="mol") + syst = dpdata.BondOrderSystem("bond_order/formal_charge.mol", fmt="mol") syst.to_deepmd_raw("bond_order/deepmd_raw_test") - def tearDown(self): - os.remove("bond_order/tmp.mol") \ No newline at end of file + def test_from_sdf_file(self): + syst = dpdata.BondOrderSystem("bond_order/methane.sdf", type_map=['C','H']) + self.assertEqual(syst.get_nframes(), 4) + self.assertEqual(syst.get_nbonds(), 4) + self.assertEqual(syst.get_natoms(), 5) + self.assertEqual(syst['atom_names'], ['C','H']) + self.assertAlmostEqual(syst['coords'][0][0][0], 0.0059) + self.assertAlmostEqual(syst['coords'][1][0][0], 0.0043) + self.assertAlmostEqual(syst['coords'][2][0][0], 0.0071) + self.assertAlmostEqual(syst['coords'][3][0][0], 0.0032) + + def test_from_sdf_file_err(self): + self.assertRaises(ValueError, dpdata.BondOrderSystem, "bond_order/methane_ethane.sdf") From db3f9b90cc24d165cccb7b83837650403465229b Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Fri, 30 Apr 2021 01:42:52 +0800 Subject: [PATCH 04/28] add BondOrderSystem --- dpdata/deepmd/comp.py | 5 +++++ dpdata/deepmd/raw.py | 6 ++++++ dpdata/rdkit/utils.py | 8 ++++---- dpdata/system.py | 18 ++++++++++++++++-- tests/test_bond_order_system.py | 27 +++++++++++++++++++++++++-- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/dpdata/deepmd/comp.py b/dpdata/deepmd/comp.py index 449da62e6..6e849b8a2 100644 --- a/dpdata/deepmd/comp.py +++ b/dpdata/deepmd/comp.py @@ -71,6 +71,11 @@ def dump(folder, # dump raw np.savetxt(os.path.join(folder, 'type.raw'), data['atom_types'], fmt = '%d') np.savetxt(os.path.join(folder, 'type_map.raw'), data['atom_names'], fmt = '%s') + # BondOrder System + if "bonds" in data: + np.savetxt(os.path.join(folder, "bonds.raw"), data['bonds'], header="begin_atom, end_atom, bond_order") + if "formal_charges" in data: + np.savetxt(os.path.join(folder, "formal_charges.raw"), data['formal_charges']) # reshape frame properties and convert prec nframes = data['cells'].shape[0] cells = np.reshape(data['cells'], [nframes, 9]).astype(comp_prec) diff --git a/dpdata/deepmd/raw.py b/dpdata/deepmd/raw.py index 039b3b787..c0c76e7e6 100644 --- a/dpdata/deepmd/raw.py +++ b/dpdata/deepmd/raw.py @@ -63,6 +63,12 @@ def dump (folder, data) : np.savetxt(os.path.join(folder, 'type_map.raw'), data['atom_names'], fmt = '%s') np.savetxt(os.path.join(folder, 'box.raw'), np.reshape(data['cells'], [nframes, 9])) np.savetxt(os.path.join(folder, 'coord.raw'), np.reshape(data['coords'], [nframes, -1])) + # BondOrder System + if "bonds" in data: + np.savetxt(os.path.join(folder, "bonds.raw"), data['bonds'], header="begin_atom, end_atom, bond_order") + if "formal_charges" in data: + np.savetxt(os.path.join(folder, "formal_charges.raw"), data['formal_charges']) + # Labeled System if 'energies' in data : np.savetxt(os.path.join(folder, 'energy.raw'), np.reshape(data['energies'], [nframes, 1])) if 'forces' in data : diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index 68ffa1983..480f639ce 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -12,10 +12,10 @@ def mol_to_system_data(mol): atom_symbols = [at.GetSymbol() for at in mol.GetAtoms()] atom_names, atom_types, atom_numbs = np.unique(atom_symbols, return_inverse=True, return_counts=True) coords = np.array([conf.GetPositions() for conf in mol.GetConformers()]) - bonds = [[bond.GetBeginAtomIdx(), - bond.GetEndAtomIdx(), - bond.GetBondTypeAsDouble()] for bond in mol.GetBonds()] - formal_charges = [at.GetFormalCharge() for at in mol.GetAtoms()] + bonds = np.array([[bond.GetBeginAtomIdx(), + bond.GetEndAtomIdx(), + bond.GetBondTypeAsDouble()] for bond in mol.GetBonds()]) + formal_charges = np.array([at.GetFormalCharge() for at in mol.GetAtoms()], dtype=np.int32) data = {} data['atom_numbs'] = list(atom_numbs) data['atom_names'] = list(atom_names) diff --git a/dpdata/system.py b/dpdata/system.py index e7c169c36..07297de07 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1755,8 +1755,22 @@ def __str__(self): def get_nbonds(self): return len(self.data['bonds']) - def __add__(self, other): - raise RuntimeError("Not supported yet.") + def copy(self): + new_mol = deepcopy(self.rdkit_mol) + self.__class__(data=deepcopy(self.data), + rdkit_mol=new_mol) + + # def __add__(self, other): + # ''' + # magic method "+" operation + # ''' + # if isinstance(other, BondOrderSystem): + # if dpdata.rdkit.utils.check_same_molecule(self.rdkit_mol, other.rdkit_mol): + # self.__class__(self, data=other.data) + # else: + # raise RuntimeError("The two systems are not of the same topology.") + # else: + # raise RuntimeError(f"Unsupported data structure: {type(other)}") def assign_formal_charges(self): self.data['formal_charges'] = [0 for _ in self.get_natoms()] # this function is to be improved diff --git a/tests/test_bond_order_system.py b/tests/test_bond_order_system.py index edf2ec7f9..317b0c6f8 100644 --- a/tests/test_bond_order_system.py +++ b/tests/test_bond_order_system.py @@ -2,6 +2,8 @@ import unittest from context import dpdata from rdkit import Chem +import shutil +import numpy as np class TestBondOrderSystem(unittest.TestCase): @@ -23,8 +25,26 @@ def test_read_other_format_without_bond_info(self): self.assertRaises(RuntimeError, dpdata.BondOrderSystem, "gromacs/1h.gro") def test_dump_to_deepmd_raw(self): - syst = dpdata.BondOrderSystem("bond_order/formal_charge.mol", fmt="mol") - syst.to_deepmd_raw("bond_order/deepmd_raw_test") + syst = dpdata.BondOrderSystem("bond_order/methane.sdf", fmt="sdf") + syst.to_deepmd_raw("bond_order/methane") + formal_charges = list(np.loadtxt("bond_order/methane/formal_charges.raw")) + self.assertTrue(formal_charges, [0 for _ in range(5)]) + bonds = np.loadtxt("bond_order/methane/bonds.raw") + for bond_idx in range(4): + for ii in range(3): + self.assertEqual(syst['bonds'][bond_idx][ii], bonds[bond_idx][ii]) + shutil.rmtree("bond_order/methane") + + def test_dump_to_deepmd_npy(self): + syst = dpdata.BondOrderSystem("bond_order/methane.sdf", fmt="sdf") + syst.to_deepmd_npy("bond_order/methane") + formal_charges = list(np.loadtxt("bond_order/methane/formal_charges.raw")) + self.assertTrue(formal_charges, [0 for _ in range(5)]) + bonds = np.loadtxt("bond_order/methane/bonds.raw") + for bond_idx in range(4): + for ii in range(3): + self.assertEqual(syst['bonds'][bond_idx][ii], bonds[bond_idx][ii]) + shutil.rmtree("bond_order/methane") def test_from_sdf_file(self): syst = dpdata.BondOrderSystem("bond_order/methane.sdf", type_map=['C','H']) @@ -39,3 +59,6 @@ def test_from_sdf_file(self): def test_from_sdf_file_err(self): self.assertRaises(ValueError, dpdata.BondOrderSystem, "bond_order/methane_ethane.sdf") + + def test_magic_add(self): + pass \ No newline at end of file From 571fa82747805ef33e83ada435cc53375f9bab8e Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Fri, 30 Apr 2021 03:04:15 +0800 Subject: [PATCH 05/28] add BondOrderSystem --- dpdata/rdkit/utils.py | 41 ++++++++++++++++++++++++++++------------- dpdata/system.py | 43 ++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index 480f639ce..f9b9828cb 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -6,6 +6,9 @@ def mol_to_system_data(mol): rdkit.Chem.SanitizeMol(mol) except: mol = regularize_formal_charges(mol) + + if not mol: + raise RuntimeError("Sanitize Failed, please check your input file") num_confs = mol.GetNumConformers() if num_confs: @@ -34,25 +37,37 @@ def mol_to_system_data(mol): def regularize_formal_charges(mol): """ - Regularize formal charges of N, O + Regularize formal charges of atoms """ for atom in mol.GetAtoms(): - if atom.GetSymbol() == "N" and atom.GetExplicitValence() == 4: - atom.SetFormalCharge(1) - elif atom.GetSymbol() == "N" and atom.GetExplicitValence() == 2: - atom.SetFormalCharge(-1) - elif atom.GetSymbol() == "O" and atom.GetExplicitValence() == 3: - atom.SetFormalCharge(1) - elif atom.GetSymbol() == "O" and atom.GetExplicitValence() == 1: - atom.SetFormalCharge(-1) - elif atom.GetSymbol() == "S" and atom.GetExplicitValence() == 3: - atom.SetFormalCharge(1) - elif atom.GetSymbol() == "S" and atom.GetExplicitValence() == 1: - atom.SetFormalCharge(-1) + assign_formal_charge_for_atom(atom) Chem.SanitizeMol(mol) return mol +def assign_formal_charge_for_atom(atom): + if atom.GetSymbol() == "B": + atom.SetFormalCharge(3 - atom.GetExplicitValence()) + elif atom.GetSymbol() == "C" or atom.GetSymbol() == "Si": + atom.SetFormalCharge(atom.GetExplicitValence() - 4) + elif atom.GetSymbol() == "N": + atom.SetFormalCharge(atom.GetExplicitValence() - 3) + elif atom.GetSymbol() == "O": + atom.SetFormalCharge(atom.GetExplicitValence() - 2) + elif atom.GetSymbol() == "S": + if atom.GetExplicitValence() == 1: + atom.SetFormalCharge(-1) + elif atom.GetExplicitValence() == 3: + atom.SetFormalCharge(1) + else: + atom.SetFormalCharge(0) + elif atom.GetSymbol() == "P" or atom.GetSymbol() == "As": + if atom.GetExplicitValence() == 5: + atom.SetFormalCharge(0) + else: + atom.SetFormalCharge(atom.GetExplicitValence() - 3) + + def check_same_atom(atom_1, atom_2): if atom_1.GetIdx() != atom_2.GetIdx(): return False diff --git a/dpdata/system.py b/dpdata/system.py index 07297de07..2ea067f36 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1660,10 +1660,6 @@ def elements_index_map(elements,standard=False,inverse=False): def check_BondOrderSystem(data): check_System(data) assert ('bonds' in data.keys()) - if 'formal_charges' not in data.keys(): - raise Warning("no formal_charges are given, formal_charges will be assigned automatically.") - else: - assert (len(data['formal_charges']) == len(data['atom_types'])) class BondOrderSystem(System): ''' @@ -1708,33 +1704,23 @@ def __init__(self, data : dict System data dict. rdkit_mol : rdkit.Chem.rdchem.Mol - If use `data` to init a BondOrderSystem, a Mol type object consistent to `data` must be given. - So it is suggested to init directly with a rdkit Mol type. + If `file_name` is None, you must init with a rdkit Mol type. """ System.__init__(self) - if data: - check_BondOrderSystem(data) - self.data = data - assert (isinstance(rdkit_mol, rdkit.Chem.rdchem.Mol)) - self.rdkit_mol = rdkit_mol - if 'formal_charges' not in data.keys(): - self.assign_formal_charges() - return - if rdkit_mol: - assert (isinstance(rdkit_mol, rdkit.Chem.rdchem.Mol)) + if file_name: + self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) + elif rdkit_mol: self.from_rdkit_mol(rdkit_mol) - return - if file_name is None: - return - self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) + else: + raise ValueError("Please specify a mol/sdf file or a rdkit Mol object") - if type_map is not None: + if type_map: self.apply_type_map(type_map) register_from_funcs = Register() - register_to_funcs = Register() + register_to_funcs = System.register_to_funcs + Register() def __repr__(self): return self.__str__() @@ -1755,6 +1741,15 @@ def __str__(self): def get_nbonds(self): return len(self.data['bonds']) + def get_charge(self): + return sum(self.data['formal_charges']) + + def get_bond_order(self, begin_atom_idx, end_atom_idx): + return self.data['bond_dict'][f'{int(begin_atom_idx)}-{int(end_atom_idx)}'] + + def get_formal_charges(self): + return self.data['formal_charges'] + def copy(self): new_mol = deepcopy(self.rdkit_mol) self.__class__(data=deepcopy(self.data), @@ -1771,12 +1766,10 @@ def copy(self): # raise RuntimeError("The two systems are not of the same topology.") # else: # raise RuntimeError(f"Unsupported data structure: {type(other)}") - - def assign_formal_charges(self): - self.data['formal_charges'] = [0 for _ in self.get_natoms()] # this function is to be improved def from_rdkit_mol(self, rdkit_mol): self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol) + self.data['bond_dict'] = dict([(f'{int(bond[0])}-{int(bond[1])}', bond[2]) for bond in self.data['bonds']]) self.rdkit_mol = rdkit_mol @register_from_funcs.register_funcs('mol') From 39051fabaa26fbe76a439f1bdbfd6231ab87914f Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Fri, 30 Apr 2021 15:51:30 +0800 Subject: [PATCH 06/28] Update BondOrderSystem --- dpdata/rdkit/utils.py | 20 ++++--- tests/bond_order/BOH4-.mol | 22 ++++++++ tests/bond_order/C5H5-.mol | 25 +++++++++ tests/bond_order/CH3CC-.mol | 16 ++++++ tests/bond_order/CH3NC.mol | 16 ++++++ tests/bond_order/CH3NH3+.mol | 20 +++++++ tests/bond_order/CH3NO2.mol | 18 +++++++ tests/bond_order/CH3OAsO3_2-.mol | 22 ++++++++ tests/bond_order/CH3OPO3_2-.mol | 22 ++++++++ tests/bond_order/CH3PH3+.mol | 20 +++++++ tests/bond_order/CH3SH.mol | 16 ++++++ tests/bond_order/CH3SO3-.mol | 20 +++++++ tests/bond_order/CH3SO3H.mol | 22 -------- tests/bond_order/CH3_2SO.mol | 24 +++++++++ tests/bond_order/CH3_2SO2.mol | 26 ++++++++++ tests/bond_order/HCN.mol | 10 ---- tests/bond_order/HNC.mol | 17 ------ tests/bond_order/HNC.pdb | 16 ------ tests/bond_order/HNC_out.mol | 17 ------ tests/bond_order/OCH3+.mol | 30 +++++++++++ tests/bond_order/arg.mol | 30 +++++++++++ tests/bond_order/deepmd_raw_test/box.raw | 1 - tests/bond_order/deepmd_raw_test/coord.raw | 1 - tests/bond_order/deepmd_raw_test/type.raw | 52 ------------------- tests/bond_order/deepmd_raw_test/type_map.raw | 5 -- tests/bond_order/gly.mol | 24 +++++++++ tests/bond_order/oxpy.mol | 29 +++++++++++ tests/test_bond_order_system.py | 50 +++++++++++------- 28 files changed, 424 insertions(+), 167 deletions(-) create mode 100644 tests/bond_order/BOH4-.mol create mode 100644 tests/bond_order/C5H5-.mol create mode 100644 tests/bond_order/CH3CC-.mol create mode 100644 tests/bond_order/CH3NC.mol create mode 100644 tests/bond_order/CH3NH3+.mol create mode 100644 tests/bond_order/CH3NO2.mol create mode 100644 tests/bond_order/CH3OAsO3_2-.mol create mode 100644 tests/bond_order/CH3OPO3_2-.mol create mode 100644 tests/bond_order/CH3PH3+.mol create mode 100644 tests/bond_order/CH3SH.mol create mode 100644 tests/bond_order/CH3SO3-.mol delete mode 100644 tests/bond_order/CH3SO3H.mol create mode 100644 tests/bond_order/CH3_2SO.mol create mode 100644 tests/bond_order/CH3_2SO2.mol delete mode 100644 tests/bond_order/HCN.mol delete mode 100644 tests/bond_order/HNC.mol delete mode 100644 tests/bond_order/HNC.pdb delete mode 100644 tests/bond_order/HNC_out.mol create mode 100644 tests/bond_order/OCH3+.mol create mode 100644 tests/bond_order/arg.mol delete mode 100644 tests/bond_order/deepmd_raw_test/box.raw delete mode 100644 tests/bond_order/deepmd_raw_test/coord.raw delete mode 100644 tests/bond_order/deepmd_raw_test/type.raw delete mode 100644 tests/bond_order/deepmd_raw_test/type_map.raw create mode 100644 tests/bond_order/gly.mol create mode 100644 tests/bond_order/oxpy.mol diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index f9b9828cb..aeff99416 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -2,11 +2,7 @@ import numpy as np def mol_to_system_data(mol): - try: - rdkit.Chem.SanitizeMol(mol) - except: - mol = regularize_formal_charges(mol) - + mol = regularize_formal_charges(mol) if not mol: raise RuntimeError("Sanitize Failed, please check your input file") @@ -41,15 +37,23 @@ def regularize_formal_charges(mol): """ for atom in mol.GetAtoms(): assign_formal_charge_for_atom(atom) - Chem.SanitizeMol(mol) - return mol + try: + Chem.SanitizeMol(mol) + return mol + except: + return None def assign_formal_charge_for_atom(atom): + """ + assigen formal charge according to 8-electron rule for element B,C,N,O,S,P,As + """ if atom.GetSymbol() == "B": atom.SetFormalCharge(3 - atom.GetExplicitValence()) - elif atom.GetSymbol() == "C" or atom.GetSymbol() == "Si": + elif atom.GetSymbol() == "C": atom.SetFormalCharge(atom.GetExplicitValence() - 4) + if atom.GetExplicitValence() == 3: + print(f"Detect a valence of 3 on carbon #{atom.GetIdx()}, the formal charge of this atom will be assigned to -1") elif atom.GetSymbol() == "N": atom.SetFormalCharge(atom.GetExplicitValence() - 3) elif atom.GetSymbol() == "O": diff --git a/tests/bond_order/BOH4-.mol b/tests/bond_order/BOH4-.mol new file mode 100644 index 000000000..714b24173 --- /dev/null +++ b/tests/bond_order/BOH4-.mol @@ -0,0 +1,22 @@ + + RDKit 3D + + 9 8 0 0 0 0 0 0 0 0999 V2000 + -0.3467 -1.1124 -1.0725 O 0 0 0 0 0 0 0 0 0 0 0 0 + 0.1774 -0.0704 -0.1870 B 0 0 0 0 0 4 0 0 0 0 0 0 + -0.0524 1.2169 -0.8307 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.6395 -0.2656 -0.1144 O 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3605 -0.1491 1.1664 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1946 -1.4561 -0.7105 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.5414 1.8645 -0.2943 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.9678 -0.2364 0.8123 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2892 0.2085 1.2308 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 1 0 + 2 4 1 0 + 2 5 1 0 + 1 6 1 0 + 3 7 1 0 + 4 8 1 0 + 5 9 1 0 +M END diff --git a/tests/bond_order/C5H5-.mol b/tests/bond_order/C5H5-.mol new file mode 100644 index 000000000..4a9640062 --- /dev/null +++ b/tests/bond_order/C5H5-.mol @@ -0,0 +1,25 @@ + + RDKit 3D + + 10 10 0 0 0 0 0 0 0 0999 V2000 + 1.1589 0.0289 0.0218 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.3434 1.1375 0.0950 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.9573 0.6854 0.0376 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.9237 -0.6963 -0.0702 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.3941 -1.1202 -0.0812 C 0 0 0 0 0 3 0 0 0 0 0 0 + 2.2384 0.0086 0.0384 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.6427 2.1738 0.1813 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.8629 1.2749 0.0686 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.7894 -1.3506 -0.1361 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.7559 -2.1420 -0.1553 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 3 4 2 0 + 4 5 1 0 + 5 1 1 0 + 1 6 1 0 + 2 7 1 0 + 3 8 1 0 + 4 9 1 0 + 5 10 1 0 +M END diff --git a/tests/bond_order/CH3CC-.mol b/tests/bond_order/CH3CC-.mol new file mode 100644 index 000000000..494c8331f --- /dev/null +++ b/tests/bond_order/CH3CC-.mol @@ -0,0 +1,16 @@ + + RDKit 3D + + 6 5 0 0 0 0 0 0 0 0999 V2000 + -0.4942 0.0244 -0.0265 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9626 -0.0132 0.0194 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1608 -0.0420 0.0394 C 0 0 0 0 0 3 0 0 0 0 0 0 + -0.9042 -0.0082 1.0068 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8567 0.9445 -0.5170 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8683 -0.9055 -0.5221 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 3 0 + 1 4 1 0 + 1 5 1 0 + 1 6 1 0 +M END diff --git a/tests/bond_order/CH3NC.mol b/tests/bond_order/CH3NC.mol new file mode 100644 index 000000000..7a042a3df --- /dev/null +++ b/tests/bond_order/CH3NC.mol @@ -0,0 +1,16 @@ + + RDKit 3D + + 6 5 0 0 0 0 0 0 0 0999 V2000 + 2.1029 -0.0145 0.0170 C 0 0 0 0 0 3 0 0 0 0 0 0 + 0.9414 -0.0028 0.0122 N 0 0 0 0 0 4 0 0 0 0 0 0 + -0.4788 -0.0102 0.0055 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8341 -0.6533 -0.8220 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8681 -0.3314 0.9923 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8632 1.0123 -0.2052 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 3 0 + 2 3 1 0 + 3 4 1 0 + 3 5 1 0 + 3 6 1 0 +M END diff --git a/tests/bond_order/CH3NH3+.mol b/tests/bond_order/CH3NH3+.mol new file mode 100644 index 000000000..5dc06ed99 --- /dev/null +++ b/tests/bond_order/CH3NH3+.mol @@ -0,0 +1,20 @@ + + RDKit 3D + + 8 7 0 0 0 0 0 0 0 0999 V2000 + -0.7380 -0.0104 0.0504 N 0 0 0 0 0 4 0 0 0 0 0 0 + 0.7029 -0.0301 -0.0070 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0863 -0.1569 -0.9255 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0283 0.9546 0.3163 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1542 -0.7528 0.6281 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0120 0.9177 -0.5299 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.1838 0.0069 0.9852 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.1082 -0.9290 -0.5177 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 + 2 6 1 0 + 2 7 1 0 + 2 8 1 0 +M END diff --git a/tests/bond_order/CH3NO2.mol b/tests/bond_order/CH3NO2.mol new file mode 100644 index 000000000..dd2d49115 --- /dev/null +++ b/tests/bond_order/CH3NO2.mol @@ -0,0 +1,18 @@ + + RDKit 3D + + 7 6 0 0 0 0 0 0 0 0999 V2000 + 1.4472 -1.1105 -0.0946 O 0 0 0 0 0 0 0 0 0 0 0 0 + 0.7839 -0.0803 -0.0649 N 0 0 0 0 0 4 0 0 0 0 0 0 + -0.6616 -0.0203 0.0443 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.4357 1.1273 -0.1393 O 0 0 0 0 0 1 0 0 0 0 0 0 + -1.1321 -1.0057 -0.1374 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.9987 0.7548 -0.6870 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8746 0.3346 1.0787 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 2 4 1 0 + 3 5 1 0 + 3 6 1 0 + 3 7 1 0 +M END diff --git a/tests/bond_order/CH3OAsO3_2-.mol b/tests/bond_order/CH3OAsO3_2-.mol new file mode 100644 index 000000000..7be918e67 --- /dev/null +++ b/tests/bond_order/CH3OAsO3_2-.mol @@ -0,0 +1,22 @@ + + RDKit 3D + + 9 8 0 0 0 0 0 0 0 0999 V2000 + -1.3508 1.6206 -1.1478 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2517 0.2899 -0.2069 As 0 0 0 0 0 5 0 0 0 0 0 0 + 0.4866 0.0891 0.3296 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3447 -0.2336 -0.6923 C 0 0 0 0 0 0 0 0 0 0 0 0 + -2.3455 0.4600 1.2300 O 0 0 0 0 0 1 0 0 0 0 0 0 + -1.7369 -1.2000 -1.1526 O 0 0 0 0 0 1 0 0 0 0 0 0 + 2.3628 0.1527 -0.4480 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.4364 -1.3299 -0.7847 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0544 0.1512 -1.6814 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 3 4 1 0 + 2 5 1 0 + 2 6 1 0 + 4 7 1 0 + 4 8 1 0 + 4 9 1 0 +M END diff --git a/tests/bond_order/CH3OPO3_2-.mol b/tests/bond_order/CH3OPO3_2-.mol new file mode 100644 index 000000000..f80862180 --- /dev/null +++ b/tests/bond_order/CH3OPO3_2-.mol @@ -0,0 +1,22 @@ + + RDKit 3D + + 9 8 0 0 0 0 0 0 0 0999 V2000 + -2.2229 0.2615 -1.3314 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2337 0.0923 -0.1748 P 0 0 0 0 0 5 0 0 0 0 0 0 + 0.2863 -0.0815 -0.8472 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3111 -0.1138 0.0645 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3507 1.4785 0.8042 O 0 0 0 0 0 1 0 0 0 0 0 0 + -1.7333 -1.2840 0.6728 O 0 0 0 0 0 1 0 0 0 0 0 0 + 2.1323 0.5613 -0.3070 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.7653 -1.1367 0.0446 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0456 0.2224 1.0743 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 3 4 1 0 + 2 5 1 0 + 2 6 1 0 + 4 7 1 0 + 4 8 1 0 + 4 9 1 0 +M END diff --git a/tests/bond_order/CH3PH3+.mol b/tests/bond_order/CH3PH3+.mol new file mode 100644 index 000000000..066e9d454 --- /dev/null +++ b/tests/bond_order/CH3PH3+.mol @@ -0,0 +1,20 @@ + + RDKit 3D + + 8 7 0 0 0 0 0 0 0 0999 V2000 + -0.8578 -0.0293 -0.0449 P 0 0 0 0 0 4 0 0 0 0 0 0 + 0.9352 0.0046 0.0341 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.4524 0.0183 1.2378 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2784 1.1437 -0.7263 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3642 -1.1648 -0.6883 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.2618 0.2543 1.0718 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3669 0.7534 -0.6600 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3888 -0.9801 -0.2243 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 1 4 1 0 + 1 5 1 0 + 2 6 1 0 + 2 7 1 0 + 2 8 1 0 +M END diff --git a/tests/bond_order/CH3SH.mol b/tests/bond_order/CH3SH.mol new file mode 100644 index 000000000..5a566c758 --- /dev/null +++ b/tests/bond_order/CH3SH.mol @@ -0,0 +1,16 @@ + + RDKit 3D + + 6 5 0 0 0 0 0 0 0 0999 V2000 + 1.1424 -0.6383 0.0431 S 0 0 0 0 0 0 0 0 0 0 0 0 + -0.5408 -0.0026 0.0071 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1173 0.3454 -0.0258 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6579 0.9242 -0.5705 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8896 0.1440 1.0547 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1714 -0.7726 -0.5086 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 1 3 1 0 + 2 4 1 0 + 2 5 1 0 + 2 6 1 0 +M END diff --git a/tests/bond_order/CH3SO3-.mol b/tests/bond_order/CH3SO3-.mol new file mode 100644 index 000000000..2b5fd7bf8 --- /dev/null +++ b/tests/bond_order/CH3SO3-.mol @@ -0,0 +1,20 @@ + + RDKit 3D + + 8 7 0 0 0 0 0 0 0 0999 V2000 + 1.4321 1.3255 -0.4098 O 0 0 0 0 0 0 0 0 0 0 0 0 + 0.8261 0.0077 -0.0287 S 0 0 0 0 0 6 0 0 0 0 0 0 + 1.3088 -0.4204 1.5374 O 0 0 0 0 0 1 0 0 0 0 0 0 + -0.9333 0.0335 -0.0477 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3553 -1.0234 -0.9669 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3825 -0.3011 0.9278 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3108 1.0652 -0.2123 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2956 -0.6870 -0.7997 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 2 4 1 0 + 2 5 2 0 + 4 6 1 0 + 4 7 1 0 + 4 8 1 0 +M END diff --git a/tests/bond_order/CH3SO3H.mol b/tests/bond_order/CH3SO3H.mol deleted file mode 100644 index c1ea77eee..000000000 --- a/tests/bond_order/CH3SO3H.mol +++ /dev/null @@ -1,22 +0,0 @@ - - RDKit 2D - - 9 8 0 0 0 0 0 0 0 0999 V2000 - 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 1.5000 0.0000 0.0000 S 0 0 0 0 0 6 0 0 0 0 0 0 - 3.0000 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 - 1.5000 -1.5000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 - 1.5000 1.5000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 - -1.5000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 0.0000 1.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - -0.0000 -1.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 2.7990 2.2500 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 1 2 1 0 - 2 3 2 0 - 2 4 2 0 - 2 5 1 0 - 1 6 1 0 - 1 7 1 0 - 1 8 1 0 - 5 9 1 0 -M END diff --git a/tests/bond_order/CH3_2SO.mol b/tests/bond_order/CH3_2SO.mol new file mode 100644 index 000000000..fd8d12a3d --- /dev/null +++ b/tests/bond_order/CH3_2SO.mol @@ -0,0 +1,24 @@ + + RDKit 3D + + 10 9 0 0 0 0 0 0 0 0999 V2000 + 0.2866 1.9779 -0.6973 O 0 0 0 0 0 0 0 0 0 0 0 0 + 0.0703 0.4987 -0.7307 S 0 0 0 0 0 4 0 0 0 0 0 0 + 1.4229 -0.4130 0.0628 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.4564 -0.0024 0.0871 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0523 -1.4559 0.1804 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2.2894 -0.3300 -0.6116 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.6169 0.0805 1.0281 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.8822 0.8766 0.5753 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.1116 -0.4236 -0.7225 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2881 -0.8089 0.8284 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 2 4 1 0 + 3 5 1 0 + 3 6 1 0 + 3 7 1 0 + 4 8 1 0 + 4 9 1 0 + 4 10 1 0 +M END diff --git a/tests/bond_order/CH3_2SO2.mol b/tests/bond_order/CH3_2SO2.mol new file mode 100644 index 000000000..09bda6b70 --- /dev/null +++ b/tests/bond_order/CH3_2SO2.mol @@ -0,0 +1,26 @@ + + RDKit 3D + + 11 10 0 0 0 0 0 0 0 0999 V2000 + -0.4169 -1.9651 0.2983 O 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0781 -0.5218 0.5089 S 0 0 0 0 0 6 0 0 0 0 0 0 + 1.4331 -0.0565 -0.2873 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3725 0.5048 -0.1633 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0126 -0.2590 2.0001 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.8089 -0.9591 -0.8194 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1718 0.3520 0.4222 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.2792 0.7203 -1.0738 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3271 1.4626 0.3915 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.3687 0.0661 -0.0383 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1171 0.6559 -1.2388 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 + 2 3 1 0 + 2 4 1 0 + 2 5 2 0 + 3 6 1 0 + 3 7 1 0 + 3 8 1 0 + 4 9 1 0 + 4 10 1 0 + 4 11 1 0 +M END diff --git a/tests/bond_order/HCN.mol b/tests/bond_order/HCN.mol deleted file mode 100644 index 24d878a63..000000000 --- a/tests/bond_order/HCN.mol +++ /dev/null @@ -1,10 +0,0 @@ - - RDKit 3D - - 3 2 0 0 0 0 0 0 0 0999 V2000 - -0.0357 0.0066 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 1.1287 -0.0077 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 - -1.0929 0.0011 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 1 2 3 0 - 1 3 1 0 -M END diff --git a/tests/bond_order/HNC.mol b/tests/bond_order/HNC.mol deleted file mode 100644 index 8ba06a0b2..000000000 --- a/tests/bond_order/HNC.mol +++ /dev/null @@ -1,17 +0,0 @@ - - RDKit 2D - - 6 5 0 0 0 0 0 0 0 0999 V2000 - -0.0000 -3.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - -0.0000 -1.5000 0.0000 N 0 0 0 0 0 4 0 0 0 0 0 0 - 0.0000 0.0000 0.0000 C 0 0 0 0 0 3 0 0 0 0 0 0 - -0.0000 -4.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - -1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 1 2 1 0 - 2 3 3 0 - 1 4 1 0 - 1 5 1 0 - 1 6 1 0 -M CHG 2 2 1 3 -1 -M END diff --git a/tests/bond_order/HNC.pdb b/tests/bond_order/HNC.pdb deleted file mode 100644 index 2dbb6c8d2..000000000 --- a/tests/bond_order/HNC.pdb +++ /dev/null @@ -1,16 +0,0 @@ -COMPND UNNAMED -AUTHOR GENERATED BY OPEN BABEL 3.1.0 -HETATM 1 C UNL 1 0.000 -3.000 0.000 1.00 0.00 C -HETATM 2 N UNL 1 0.000 -1.500 0.000 1.00 0.00 N1+ -HETATM 3 C UNL 1 0.000 0.000 0.000 1.00 0.00 C1- -HETATM 4 H UNL 1 0.000 -4.500 0.000 1.00 0.00 H -HETATM 5 H UNL 1 1.500 -3.000 0.000 1.00 0.00 H -HETATM 6 H UNL 1 -1.500 -3.000 0.000 1.00 0.00 H -CONECT 1 2 4 5 6 -CONECT 2 1 3 3 3 -CONECT 3 2 2 2 -CONECT 4 1 -CONECT 5 1 -CONECT 6 1 -MASTER 0 0 0 0 0 0 0 0 6 0 6 0 -END diff --git a/tests/bond_order/HNC_out.mol b/tests/bond_order/HNC_out.mol deleted file mode 100644 index 347736ca7..000000000 --- a/tests/bond_order/HNC_out.mol +++ /dev/null @@ -1,17 +0,0 @@ -HNC.pdb - OpenBabel04292118033D - - 6 5 0 0 0 0 0 0 0 0999 V2000 - 0.0000 -3.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 0.0000 -1.5000 0.0000 N 0 3 0 0 0 0 0 0 0 0 0 0 - 0.0000 0.0000 0.0000 C 0 5 0 0 0 0 0 0 0 0 0 0 - 0.0000 -4.5000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - -1.5000 -3.0000 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0 - 1 2 1 0 0 0 0 - 1 4 1 0 0 0 0 - 1 5 1 0 0 0 0 - 1 6 1 0 0 0 0 - 2 3 3 0 0 0 0 -M CHG 2 2 1 3 -1 -M END diff --git a/tests/bond_order/OCH3+.mol b/tests/bond_order/OCH3+.mol new file mode 100644 index 000000000..29c5ce1d5 --- /dev/null +++ b/tests/bond_order/OCH3+.mol @@ -0,0 +1,30 @@ + + RDKit 3D + + 13 12 0 0 0 0 0 0 0 0999 V2000 + -1.1322 -0.7171 -0.0206 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0146 0.0405 -0.1046 O 0 0 0 0 0 3 0 0 0 0 0 0 + 1.1620 -0.5595 -0.3257 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0457 1.3058 0.3346 C 0 0 0 0 0 0 0 0 0 0 0 0 + -2.0394 -0.1094 0.1638 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0528 -1.4883 0.7665 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.2721 -1.2379 -1.0137 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.9683 0.2012 -0.3660 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.2311 -1.1384 -1.2773 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3892 -1.2845 0.5047 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8189 1.8780 -0.2449 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.2936 1.3099 1.4347 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.9185 1.7997 0.1483 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 1 0 + 2 4 1 0 + 1 5 1 0 + 1 6 1 0 + 1 7 1 0 + 3 8 1 0 + 3 9 1 0 + 3 10 1 0 + 4 11 1 0 + 4 12 1 0 + 4 13 1 0 +M END diff --git a/tests/bond_order/arg.mol b/tests/bond_order/arg.mol new file mode 100644 index 000000000..ff7649600 --- /dev/null +++ b/tests/bond_order/arg.mol @@ -0,0 +1,30 @@ + + RDKit 3D + + 13 12 0 0 0 0 0 0 0 0999 V2000 + -1.7836 -0.9288 0.3017 N 0 0 0 0 0 0 0 0 0 0 0 0 + -0.6586 -0.0997 0.0202 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.6329 -0.6378 0.2496 N 0 0 0 0 0 0 0 0 0 0 0 0 + 1.7764 0.1989 -0.0343 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8216 1.0935 -0.4260 N 0 0 0 0 0 4 0 0 0 0 0 0 + -1.6984 -1.7527 0.9457 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.6816 -0.7029 -0.1397 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.8153 -1.5960 0.6091 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2.7162 -0.2115 0.3879 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.8991 0.2226 -1.1385 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1.6530 1.2237 0.3439 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.7944 1.4533 -0.5818 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0546 1.7375 -0.6471 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 1 0 + 3 4 1 0 + 2 5 2 3 + 1 6 1 0 + 1 7 1 0 + 3 8 1 0 + 4 9 1 0 + 4 10 1 0 + 4 11 1 0 + 5 12 1 0 + 5 13 1 0 +M END diff --git a/tests/bond_order/deepmd_raw_test/box.raw b/tests/bond_order/deepmd_raw_test/box.raw deleted file mode 100644 index 43b6dc19a..000000000 --- a/tests/bond_order/deepmd_raw_test/box.raw +++ /dev/null @@ -1 +0,0 @@ -1.000000000000000000e+02 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+02 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+02 diff --git a/tests/bond_order/deepmd_raw_test/coord.raw b/tests/bond_order/deepmd_raw_test/coord.raw deleted file mode 100644 index 3350762e5..000000000 --- a/tests/bond_order/deepmd_raw_test/coord.raw +++ /dev/null @@ -1 +0,0 @@ -1.826999999999999957e+01 -1.324000000000000021e+01 2.171000000000000085e+01 1.807000000000000028e+01 -1.193999999999999950e+01 2.103000000000000114e+01 1.739999999999999858e+01 -1.377999999999999936e+01 2.260000000000000142e+01 1.639999999999999858e+01 -1.316999999999999993e+01 2.298000000000000043e+01 1.666000000000000014e+01 -1.175000000000000000e+01 2.041000000000000014e+01 1.616000000000000014e+01 -1.265000000000000036e+01 1.971999999999999886e+01 1.916000000000000014e+01 -1.189000000000000057e+01 1.996000000000000085e+01 1.764999999999999858e+01 -1.517999999999999972e+01 2.319000000000000128e+01 1.603999999999999915e+01 -1.058999999999999986e+01 2.064999999999999858e+01 2.026000000000000156e+01 -1.282000000000000028e+01 2.044999999999999929e+01 1.641000000000000014e+01 -1.597000000000000064e+01 2.310999999999999943e+01 1.814000000000000057e+01 -1.510999999999999943e+01 2.466000000000000014e+01 1.469999999999999929e+01 -1.022000000000000064e+01 2.021999999999999886e+01 1.955000000000000071e+01 -1.383999999999999986e+01 2.132000000000000028e+01 1.955999999999999872e+01 -1.461999999999999922e+01 2.482999999999999829e+01 1.364000000000000057e+01 -1.035999999999999943e+01 2.128999999999999915e+01 1.980000000000000071e+01 -1.331000000000000050e+01 2.528999999999999915e+01 1.290000000000000036e+01 -1.155000000000000071e+01 2.142000000000000171e+01 2.110999999999999943e+01 -1.282000000000000028e+01 2.539999999999999858e+01 1.189000000000000057e+01 -1.166000000000000014e+01 2.239999999999999858e+01 2.219999999999999929e+01 -1.364000000000000057e+01 2.505000000000000071e+01 1.161999999999999922e+01 -1.057000000000000028e+01 2.325000000000000000e+01 2.196999999999999886e+01 -1.496000000000000085e+01 2.462999999999999901e+01 1.236999999999999922e+01 -9.380000000000000782e+00 2.314999999999999858e+01 2.064999999999999858e+01 -1.544999999999999929e+01 2.451000000000000156e+01 1.336999999999999922e+01 -9.279999999999999361e+00 2.216000000000000014e+01 1.825000000000000000e+01 -1.116000000000000014e+01 2.176000000000000156e+01 1.878999999999999915e+01 -1.225000000000000000e+01 1.898999999999999844e+01 1.953999999999999915e+01 -1.089000000000000057e+01 1.980999999999999872e+01 1.837999999999999901e+01 -1.573000000000000043e+01 2.260000000000000142e+01 1.655999999999999872e+01 -9.890000000000000568e+00 2.117999999999999972e+01 2.082999999999999829e+01 -1.326999999999999957e+01 1.962999999999999901e+01 2.096999999999999886e+01 -1.225000000000000000e+01 2.105999999999999872e+01 1.655000000000000071e+01 -1.687999999999999901e+01 2.351000000000000156e+01 1.567999999999999972e+01 -1.548000000000000043e+01 2.362000000000000099e+01 1.612999999999999901e+01 -1.605000000000000071e+01 2.214999999999999858e+01 1.746000000000000085e+01 -1.449000000000000021e+01 2.525000000000000000e+01 1.808999999999999986e+01 -1.610000000000000142e+01 2.510999999999999943e+01 1.474000000000000021e+01 -9.160000000000000142e+00 1.994000000000000128e+01 1.441000000000000014e+01 -1.075999999999999979e+01 1.932000000000000028e+01 2.016000000000000014e+01 -1.409999999999999964e+01 2.217000000000000171e+01 1.935999999999999943e+01 -1.475000000000000000e+01 2.073999999999999844e+01 1.898999999999999844e+01 -1.267999999999999972e+01 2.558999999999999986e+01 1.311999999999999922e+01 -1.239000000000000057e+01 2.076999999999999957e+01 2.126999999999999957e+01 -1.181000000000000050e+01 2.576000000000000156e+01 1.133000000000000007e+01 -1.257000000000000028e+01 2.250000000000000000e+01 2.321000000000000085e+01 -1.326999999999999957e+01 2.514000000000000057e+01 2.280999999999999872e+01 -1.559999999999999964e+01 2.439000000000000057e+01 1.216999999999999993e+01 -8.369999999999999218e+00 2.398999999999999844e+01 2.048999999999999844e+01 -1.646000000000000085e+01 2.417000000000000171e+01 1.394999999999999929e+01 -8.369999999999999218e+00 2.208999999999999986e+01 1.084999999999999964e+01 -1.065000000000000036e+01 2.401000000000000156e+01 diff --git a/tests/bond_order/deepmd_raw_test/type.raw b/tests/bond_order/deepmd_raw_test/type.raw deleted file mode 100644 index 1fcd91d9d..000000000 --- a/tests/bond_order/deepmd_raw_test/type.raw +++ /dev/null @@ -1,52 +0,0 @@ -3 -0 -0 -4 -0 -4 -0 -0 -3 -0 -3 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -1 -2 -2 -2 diff --git a/tests/bond_order/deepmd_raw_test/type_map.raw b/tests/bond_order/deepmd_raw_test/type_map.raw deleted file mode 100644 index 52bc03ef6..000000000 --- a/tests/bond_order/deepmd_raw_test/type_map.raw +++ /dev/null @@ -1,5 +0,0 @@ -C -F -H -N -O diff --git a/tests/bond_order/gly.mol b/tests/bond_order/gly.mol new file mode 100644 index 000000000..2a47b76b3 --- /dev/null +++ b/tests/bond_order/gly.mol @@ -0,0 +1,24 @@ + + RDKit 3D + + 10 9 0 0 0 0 0 0 0 0999 V2000 + -0.8847 -0.5545 -0.2953 N 0 0 0 0 0 4 0 0 0 0 0 0 + -0.1362 0.5745 0.1710 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.2865 0.2167 0.2432 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.6871 -1.0450 -0.1141 O 0 0 0 0 0 1 0 0 0 0 0 0 + 2.1175 1.0591 0.6274 O 0 0 0 0 0 0 0 0 0 0 0 0 + -1.1118 -0.5249 -1.3170 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.7699 -0.6403 0.2808 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3737 -1.4584 -0.1502 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.3181 1.3969 -0.5839 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.4968 0.9759 1.1382 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 1 0 + 3 4 1 0 + 3 5 2 0 + 1 6 1 0 + 1 7 1 0 + 1 8 1 0 + 2 9 1 0 + 2 10 1 0 +M END diff --git a/tests/bond_order/oxpy.mol b/tests/bond_order/oxpy.mol new file mode 100644 index 000000000..e6ef61022 --- /dev/null +++ b/tests/bond_order/oxpy.mol @@ -0,0 +1,29 @@ + + RDKit 3D + + 12 12 0 0 0 0 0 0 0 0999 V2000 + 2.5787 0.8944 -0.0838 O 0 0 0 0 0 1 0 0 0 0 0 0 + 1.2766 0.4568 -0.0416 N 0 0 0 0 0 4 0 0 0 0 0 0 + 0.9973 -0.8577 -0.0244 C 0 0 0 0 0 0 0 0 0 0 0 0 + -0.2653 -1.3716 0.0171 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.3298 -0.4903 0.0434 C 0 0 0 0 0 0 0 0 0 0 0 0 + -1.0482 0.8780 0.0258 C 0 0 0 0 0 0 0 0 0 0 0 0 + 0.2499 1.3409 -0.0165 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.8285 -1.5681 -0.0448 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.4663 -2.4346 0.0302 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.3694 -0.8240 0.0770 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.8826 1.5654 0.0465 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.4307 2.4107 -0.0290 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 + 2 3 2 0 + 3 4 1 0 + 4 5 2 0 + 5 6 1 0 + 6 7 2 0 + 7 2 1 0 + 3 8 1 0 + 4 9 1 0 + 5 10 1 0 + 6 11 1 0 + 7 12 1 0 +M END diff --git a/tests/test_bond_order_system.py b/tests/test_bond_order_system.py index 317b0c6f8..7fbad6c28 100644 --- a/tests/test_bond_order_system.py +++ b/tests/test_bond_order_system.py @@ -2,11 +2,20 @@ import unittest from context import dpdata from rdkit import Chem +from rdkit.Chem import AllChem import shutil import numpy as np class TestBondOrderSystem(unittest.TestCase): + def test_from_rdkit_mol(self): + mol = Chem.MolFromSmiles("CC") + mol = Chem.AddHs(mol) + AllChem.EmbedMultipleConfs(mol, 10) + system = dpdata.BondOrderSystem(rdkit_mol=mol) + self.assertEqual(system.get_nframes(), 10) + self.assertEqual(system.get_nbonds(), 7) + def test_from_mol_file(self): syst = dpdata.BondOrderSystem("bond_order/CH3OH.mol", fmt='mol', type_map=['O','C','H']) self.assertEqual(syst.get_nframes(), 1) @@ -14,12 +23,34 @@ def test_from_mol_file(self): self.assertEqual(syst.get_natoms(), 6) self.assertEqual(syst['atom_names'], ['O','C','H']) self.assertAlmostEqual(syst['coords'][0][0][0], -0.3858) + + def test_from_sdf_file(self): + syst = dpdata.BondOrderSystem("bond_order/methane.sdf", type_map=['C','H']) + self.assertEqual(syst.get_nframes(), 4) + self.assertEqual(syst.get_nbonds(), 4) + self.assertEqual(syst.get_natoms(), 5) + self.assertEqual(syst['atom_names'], ['C','H']) + self.assertAlmostEqual(syst['coords'][0][0][0], 0.0059) + self.assertAlmostEqual(syst['coords'][1][0][0], 0.0043) + self.assertAlmostEqual(syst['coords'][2][0][0], 0.0071) + self.assertAlmostEqual(syst['coords'][3][0][0], 0.0032) + + def test_from_sdf_file_err(self): + self.assertRaises(ValueError, dpdata.BondOrderSystem, "bond_order/methane_ethane.sdf") def test_regularize_formal_charges(self): non_regular = Chem.MolFromMolFile("bond_order/formal_charge.mol", removeHs=False) regular = dpdata.BondOrderSystem("bond_order/formal_charge.mol", fmt="mol") self.assertFalse(non_regular) self.assertTrue(isinstance(regular.rdkit_mol, Chem.rdchem.Mol)) + + def test_formal_charge(self): + names = ["C5H5-", "CH3CC-", "CH3NC", "CH3NH3+", "CH3NO2", "OCH3+", + "gly", "arg", "oxpy", "CH3OPO3_2-", "CH3PH3+", "CH3OAsO3_2-", + "CH3SH", "CH3_2SO", "CH3_2SO2", "CH3SO3-", "BOH4-"] + charges = [-1, -1, 0, 1, 0, 1, 0, 1, 0, -2, 1, -2, 0, 0, 0, -1, -1] + mols = [dpdata.BondOrderSystem(f"bond_order/{name}.mol") for name in names] + self.assertEqual(charges, [mol.get_charge() for mol in mols]) def test_read_other_format_without_bond_info(self): self.assertRaises(RuntimeError, dpdata.BondOrderSystem, "gromacs/1h.gro") @@ -44,21 +75,4 @@ def test_dump_to_deepmd_npy(self): for bond_idx in range(4): for ii in range(3): self.assertEqual(syst['bonds'][bond_idx][ii], bonds[bond_idx][ii]) - shutil.rmtree("bond_order/methane") - - def test_from_sdf_file(self): - syst = dpdata.BondOrderSystem("bond_order/methane.sdf", type_map=['C','H']) - self.assertEqual(syst.get_nframes(), 4) - self.assertEqual(syst.get_nbonds(), 4) - self.assertEqual(syst.get_natoms(), 5) - self.assertEqual(syst['atom_names'], ['C','H']) - self.assertAlmostEqual(syst['coords'][0][0][0], 0.0059) - self.assertAlmostEqual(syst['coords'][1][0][0], 0.0043) - self.assertAlmostEqual(syst['coords'][2][0][0], 0.0071) - self.assertAlmostEqual(syst['coords'][3][0][0], 0.0032) - - def test_from_sdf_file_err(self): - self.assertRaises(ValueError, dpdata.BondOrderSystem, "bond_order/methane_ethane.sdf") - - def test_magic_add(self): - pass \ No newline at end of file + shutil.rmtree("bond_order/methane") \ No newline at end of file From 26b60855a912bf768ddc4bfb896146662b83d41b Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Sat, 1 May 2021 09:29:05 +0800 Subject: [PATCH 07/28] solve oveall dependency on rdkit --- dpdata/__init__.py | 14 +++- dpdata/bond_order_system.py | 153 +++++++++++++++++++++++++++++++++++ dpdata/rdkit/__init__.py | 0 dpdata/system.py | 154 ------------------------------------ 4 files changed, 166 insertions(+), 155 deletions(-) create mode 100644 dpdata/bond_order_system.py create mode 100644 dpdata/rdkit/__init__.py diff --git a/dpdata/__init__.py b/dpdata/__init__.py index eb7b379d8..92ba1b835 100644 --- a/dpdata/__init__.py +++ b/dpdata/__init__.py @@ -3,10 +3,22 @@ from . import md from .system import System from .system import LabeledSystem -from .system import BondOrderSystem from .system import MultiSystems try: from ._version import version as __version__ except ImportError: from .__about__ import __version__ + +# BondOrder System has dependency on rdkit +try: + import rdkit + USE_RDKIT = True +except ModuleNotFoundError: + USE_RDKIT = False + print("WARNING: No rdkit is installed, 'BondOrderSystem' cannot be used") + +if USE_RDKIT: + from .bond_order_system import BondOrderSystem + + diff --git a/dpdata/bond_order_system.py b/dpdata/bond_order_system.py new file mode 100644 index 000000000..2962a1d28 --- /dev/null +++ b/dpdata/bond_order_system.py @@ -0,0 +1,153 @@ +#%% +# Bond Order System +from dpdata.system import Register, System, LabeledSystem, check_System +import rdkit.Chem +import dpdata.rdkit.utils + +def check_BondOrderSystem(data): + check_System(data) + assert ('bonds' in data.keys()) + +class BondOrderSystem(System): + ''' + The system with chemical bond and formal charges information + + For example, a labeled methane system named `d_example` has one molecule (5 atoms, 4 bonds) and `n_frames` frames. The bond order and formal charge information can be accessed by + - `d_example['bonds']` : a numpy array of size 4 x 3, and + the first column represents the index of begin atom, + the second column represents the index of end atom, + the third columen represents the bond order: + 1 - single bond, 2 - double bond, 3 - triple bond, 1.5 - aromatic bond + - `d_example['formal_charges']` : a numpy array of size 5 x 1 + ''' + def __init__(self, + file_name = None, + fmt = 'auto', + type_map = None, + begin = 0, + step = 1, + data = None, + rdkit_mol = None, + **kwargs): + """ + Constructor + + Parameters + ---------- + file_name : str + The file to load the system + fmt : str + Format of the file, supported formats are + - ``auto`` : inferred from `file_name`'s extention + - ``mol`` : .mol file + - ``sdf`` : .sdf file + type_map : list of str + Needed by formats deepmd/raw and deepmd/npy. Maps atom type to name. The atom with type `ii` is mapped to `type_map[ii]`. + If not provided the atom names are assigned to `'Type_1'`, `'Type_2'`, `'Type_3'`... + begin : int + The beginning frame when loading MD trajectory. + step : int + The number of skipped frames when loading MD trajectory. + data : dict + System data dict. + rdkit_mol : rdkit.Chem.rdchem.Mol + If `file_name` is None, you must init with a rdkit Mol type. + """ + + System.__init__(self) + + if file_name: + self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) + elif rdkit_mol: + self.from_rdkit_mol(rdkit_mol) + else: + raise ValueError("Please specify a mol/sdf file or a rdkit Mol object") + + if type_map: + self.apply_type_map(type_map) + + register_from_funcs = Register() + register_to_funcs = System.register_to_funcs + Register() + + def __repr__(self): + return self.__str__() + + def __str__(self): + ret = "Data Summary" + ret += "\nBondOrder System" + ret += "\n-------------------" + ret += f"\nFrame Numbers : {self.get_nframes()}" + ret += f"\nAtom Numbers : {self.get_natoms()}" + ret += f"\nBond Numbers : {self.get_nbonds()}" + ret += "\nElement List :" + ret += "\n-------------------" + ret += "\n"+" ".join(map(str,self.get_atom_names())) + ret += "\n"+" ".join(map(str,self.get_atom_numbs())) + return ret + + def get_nbonds(self): + return len(self.data['bonds']) + + def get_charge(self): + return sum(self.data['formal_charges']) + + def get_bond_order(self, begin_atom_idx, end_atom_idx): + return self.data['bond_dict'][f'{int(begin_atom_idx)}-{int(end_atom_idx)}'] + + def get_formal_charges(self): + return self.data['formal_charges'] + + def copy(self): + new_mol = deepcopy(self.rdkit_mol) + self.__class__(data=deepcopy(self.data), + rdkit_mol=new_mol) + + # def __add__(self, other): + # ''' + # magic method "+" operation + # ''' + # if isinstance(other, BondOrderSystem): + # if dpdata.rdkit.utils.check_same_molecule(self.rdkit_mol, other.rdkit_mol): + # self.__class__(self, data=other.data) + # else: + # raise RuntimeError("The two systems are not of the same topology.") + # else: + # raise RuntimeError(f"Unsupported data structure: {type(other)}") + + def from_rdkit_mol(self, rdkit_mol): + self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol) + self.data['bond_dict'] = dict([(f'{int(bond[0])}-{int(bond[1])}', bond[2]) for bond in self.data['bonds']]) + self.rdkit_mol = rdkit_mol + + @register_from_funcs.register_funcs('mol') + def from_mol_file(self, file_name): + mol = rdkit.Chem.MolFromMolFile(file_name, sanitize=False, removeHs=False) + self.from_rdkit_mol(mol) + + @register_to_funcs.register_funcs("mol") + def to_mol_file(self, file_name, frame_idx=0): + assert (frame_idx < self.get_nframes()) + rdkit.Chem.MolToMolFile(self.rdkit_mol, file_name, confId=frame_idx) + + @register_from_funcs.register_funcs("sdf") + def from_sdf_file(self, file_name): + ''' + Note that it requires all molecules in .sdf file must be of the same topology + ''' + mols = [m for m in rdkit.Chem.SDMolSupplier(file_name, sanitize=False, removeHs=False)] + if len(mols) > 1: + mol = dpdata.rdkit.utils.combine_molecules(mols) + else: + mol = mols[0] + self.from_rdkit_mol(mol) + + @register_to_funcs.register_funcs("sdf") + def to_sdf_file(self, file_name, frame_idx=-1): + sdf_writer = rdkit.Chem.SDWriter(file_name) + if frame_idx == -1: + for ii in self.get_nframes(): + sdf_writer.write(self.rdkit_mol, confId=ii) + else: + assert (frame_idx < self.get_nframes()) + sdf_writer.write(self.rdkit_mol, confId=frame_idx) + sdf_writer.close() \ No newline at end of file diff --git a/dpdata/rdkit/__init__.py b/dpdata/rdkit/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/dpdata/system.py b/dpdata/system.py index 2ea067f36..3dc2c516b 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -1650,158 +1650,4 @@ def elements_index_map(elements,standard=False,inverse=False): return dict(zip(range(len(elements)),elements)) else: return dict(zip(elements,range(len(elements)))) - - -#%% -# Bond Order System -import rdkit.Chem -import dpdata.rdkit.utils - -def check_BondOrderSystem(data): - check_System(data) - assert ('bonds' in data.keys()) - -class BondOrderSystem(System): - ''' - The system with chemical bond and formal charges information - - For example, a labeled methane system named `d_example` has one molecule (5 atoms, 4 bonds) and `n_frames` frames. The bond order and formal charge information can be accessed by - - `d_example['bonds']` : a numpy array of size 4 x 3, and - the first column represents the index of begin atom, - the second column represents the index of end atom, - the third columen represents the bond order: - 1 - single bond, 2 - double bond, 3 - triple bond, 1.5 - aromatic bond - - `d_example['formal_charges']` : a numpy array of size 5 x 1 - ''' - def __init__(self, - file_name = None, - fmt = 'auto', - type_map = None, - begin = 0, - step = 1, - data = None, - rdkit_mol = None, - **kwargs): - """ - Constructor - - Parameters - ---------- - file_name : str - The file to load the system - fmt : str - Format of the file, supported formats are - - ``auto`` : inferred from `file_name`'s extention - - ``mol`` : .mol file - - ``sdf`` : .sdf file - type_map : list of str - Needed by formats deepmd/raw and deepmd/npy. Maps atom type to name. The atom with type `ii` is mapped to `type_map[ii]`. - If not provided the atom names are assigned to `'Type_1'`, `'Type_2'`, `'Type_3'`... - begin : int - The beginning frame when loading MD trajectory. - step : int - The number of skipped frames when loading MD trajectory. - data : dict - System data dict. - rdkit_mol : rdkit.Chem.rdchem.Mol - If `file_name` is None, you must init with a rdkit Mol type. - """ - - System.__init__(self) - - if file_name: - self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) - elif rdkit_mol: - self.from_rdkit_mol(rdkit_mol) - else: - raise ValueError("Please specify a mol/sdf file or a rdkit Mol object") - - if type_map: - self.apply_type_map(type_map) - - register_from_funcs = Register() - register_to_funcs = System.register_to_funcs + Register() - - def __repr__(self): - return self.__str__() - - def __str__(self): - ret = "Data Summary" - ret += "\nBondOrder System" - ret += "\n-------------------" - ret += f"\nFrame Numbers : {self.get_nframes()}" - ret += f"\nAtom Numbers : {self.get_natoms()}" - ret += f"\nBond Numbers : {self.get_nbonds()}" - ret += "\nElement List :" - ret += "\n-------------------" - ret += "\n"+" ".join(map(str,self.get_atom_names())) - ret += "\n"+" ".join(map(str,self.get_atom_numbs())) - return ret - - def get_nbonds(self): - return len(self.data['bonds']) - - def get_charge(self): - return sum(self.data['formal_charges']) - - def get_bond_order(self, begin_atom_idx, end_atom_idx): - return self.data['bond_dict'][f'{int(begin_atom_idx)}-{int(end_atom_idx)}'] - - def get_formal_charges(self): - return self.data['formal_charges'] - - def copy(self): - new_mol = deepcopy(self.rdkit_mol) - self.__class__(data=deepcopy(self.data), - rdkit_mol=new_mol) - - # def __add__(self, other): - # ''' - # magic method "+" operation - # ''' - # if isinstance(other, BondOrderSystem): - # if dpdata.rdkit.utils.check_same_molecule(self.rdkit_mol, other.rdkit_mol): - # self.__class__(self, data=other.data) - # else: - # raise RuntimeError("The two systems are not of the same topology.") - # else: - # raise RuntimeError(f"Unsupported data structure: {type(other)}") - - def from_rdkit_mol(self, rdkit_mol): - self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol) - self.data['bond_dict'] = dict([(f'{int(bond[0])}-{int(bond[1])}', bond[2]) for bond in self.data['bonds']]) - self.rdkit_mol = rdkit_mol - - @register_from_funcs.register_funcs('mol') - def from_mol_file(self, file_name): - mol = rdkit.Chem.MolFromMolFile(file_name, sanitize=False, removeHs=False) - self.from_rdkit_mol(mol) - - @register_to_funcs.register_funcs("mol") - def to_mol_file(self, file_name, frame_idx=0): - assert (frame_idx < self.get_nframes()) - rdkit.Chem.MolToMolFile(self.rdkit_mol, file_name, confId=frame_idx) - - @register_from_funcs.register_funcs("sdf") - def from_sdf_file(self, file_name): - ''' - Note that it requires all molecules in .sdf file must be of the same topology - ''' - mols = [m for m in rdkit.Chem.SDMolSupplier(file_name, sanitize=False, removeHs=False)] - if len(mols) > 1: - mol = dpdata.rdkit.utils.combine_molecules(mols) - else: - mol = mols[0] - self.from_rdkit_mol(mol) - - @register_to_funcs.register_funcs("sdf") - def to_sdf_file(self, file_name, frame_idx=-1): - sdf_writer = rdkit.Chem.SDWriter(file_name) - if frame_idx == -1: - for ii in self.get_nframes(): - sdf_writer.write(self.rdkit_mol, confId=ii) - else: - assert (frame_idx < self.get_nframes()) - sdf_writer.write(self.rdkit_mol, confId=frame_idx) - sdf_writer.close() # %% From e98205947fe6b344c0f6b805b6bb397f7d5dd9ba Mon Sep 17 00:00:00 2001 From: Ericwang6 <63655850+Ericwang6@users.noreply.github.com> Date: Sun, 9 May 2021 12:26:09 +0800 Subject: [PATCH 08/28] Add dpdata/rdkit package --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8819cda49..daf553afb 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,8 @@ 'dpdata/pwmat', 'dpdata/amber', 'dpdata/fhi_aims', - 'dpdata/gromacs' + 'dpdata/gromacs', + 'dpdata/rdkit' ], package_data={'dpdata':['*.json']}, classifiers=[ From baee72578f75e5573c1b778cfc7b0e4cdc74b50a Mon Sep 17 00:00:00 2001 From: Ericwang6 <63655850+Ericwang6@users.noreply.github.com> Date: Sun, 9 May 2021 12:31:15 +0800 Subject: [PATCH 09/28] Add information on functions --- dpdata/bond_order_system.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dpdata/bond_order_system.py b/dpdata/bond_order_system.py index 2962a1d28..e60ac32ac 100644 --- a/dpdata/bond_order_system.py +++ b/dpdata/bond_order_system.py @@ -73,6 +73,9 @@ def __repr__(self): return self.__str__() def __str__(self): + ''' + A brief summary of the system + ''' ret = "Data Summary" ret += "\nBondOrder System" ret += "\n-------------------" @@ -86,15 +89,27 @@ def __str__(self): return ret def get_nbonds(self): + ''' + Return the number of bonds + ''' return len(self.data['bonds']) def get_charge(self): + ''' + Return the total formal charge of the moleclue + ''' return sum(self.data['formal_charges']) def get_bond_order(self, begin_atom_idx, end_atom_idx): + ''' + Return the bond order between given atoms + ''' return self.data['bond_dict'][f'{int(begin_atom_idx)}-{int(end_atom_idx)}'] def get_formal_charges(self): + ''' + Return the formal charges on each atom + ''' return self.data['formal_charges'] def copy(self): @@ -115,6 +130,9 @@ def copy(self): # raise RuntimeError(f"Unsupported data structure: {type(other)}") def from_rdkit_mol(self, rdkit_mol): + ''' + Initialize from a rdkit.Chem.rdchem.Mol object + ''' self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol) self.data['bond_dict'] = dict([(f'{int(bond[0])}-{int(bond[1])}', bond[2]) for bond in self.data['bonds']]) self.rdkit_mol = rdkit_mol @@ -150,4 +168,4 @@ def to_sdf_file(self, file_name, frame_idx=-1): else: assert (frame_idx < self.get_nframes()) sdf_writer.write(self.rdkit_mol, confId=frame_idx) - sdf_writer.close() \ No newline at end of file + sdf_writer.close() From f981fe7568fe6ba6e2331f34de82f41b6ac19cbc Mon Sep 17 00:00:00 2001 From: Ericwang6 <63655850+Ericwang6@users.noreply.github.com> Date: Sun, 9 May 2021 12:32:01 +0800 Subject: [PATCH 10/28] Spelling correction --- dpdata/rdkit/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index aeff99416..1e9748629 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -46,7 +46,7 @@ def regularize_formal_charges(mol): def assign_formal_charge_for_atom(atom): """ - assigen formal charge according to 8-electron rule for element B,C,N,O,S,P,As + assign formal charge according to 8-electron rule for element B,C,N,O,S,P,As """ if atom.GetSymbol() == "B": atom.SetFormalCharge(3 - atom.GetExplicitValence()) @@ -108,4 +108,4 @@ def combine_molecules(mols): mols[0].AddConformer(conf, assignId=True) return mols[0] else: - raise ValueError("molecules are not of the same topology.") \ No newline at end of file + raise ValueError("molecules are not of the same topology.") From cb07074a8576f2974b83970f2a6fa8d97111d32f Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:20:46 +0800 Subject: [PATCH 11/28] Add bond order assignment --- dpdata/rdkit/sanitize.py | 568 +++++++++++++++++++++++++++++++++++++++ dpdata/rdkit/utils.py | 85 +++--- 2 files changed, 609 insertions(+), 44 deletions(-) create mode 100644 dpdata/rdkit/sanitize.py diff --git a/dpdata/rdkit/sanitize.py b/dpdata/rdkit/sanitize.py new file mode 100644 index 000000000..23cfaaaa1 --- /dev/null +++ b/dpdata/rdkit/sanitize.py @@ -0,0 +1,568 @@ +from copy import deepcopy +from rdkit import Chem +from rdkit.Chem.rdchem import Atom, Bond, Mol, BondType +import os +import time + +USE_OBABEL = False +for path in os.environ['PATH'].split(":"): + if os.path.exists(os.path.join(path, "obabel")): + USE_OBABEL = True + break + +def get_explicit_valence(atom, verbose=False): + exp_val_calculated_from_bonds = int(sum([bond.GetBondTypeAsDouble() for bond in atom.GetBonds()])) + try: + exp_val = atom.GetExplicitValence() + if exp_val != exp_val_calculated_from_bonds: + if verbose: + print(f"Explicit valence given by GetExplicitValence() and sum of bond order are inconsistent on {atom.GetSymbol()}{atom.GetIdx()+1}, using sum of bond order.") + return exp_val_calculated_from_bonds + except: + return exp_val_calculated_from_bonds + +def regularize_formal_charges(mol, sanitize=True, verbose=False): + """ + Regularize formal charges of atoms + """ + assert isinstance(mol, Chem.rdchem.Mol) + for atom in mol.GetAtoms(): + assign_formal_charge_for_atom(atom, verbose) + if sanitize: + try: + Chem.SanitizeMol(mol) + return mol + except: + return None + else: + return mol + +def assign_formal_charge_for_atom(atom, verbose=False): + """ + assigen formal charge according to 8-electron rule for element B,C,N,O,S,P,As + """ + assert isinstance(atom, Chem.rdchem.Atom) + valence = get_explicit_valence(atom, verbose) + if atom.GetSymbol() == "B": + atom.SetFormalCharge(3 - valence) + elif atom.GetSymbol() == "C": + atom.SetFormalCharge(valence - 4) + if valence == 3: + print(f"Detect a valence of 3 on #C{atom.GetIdx()+1}, the formal charge of this atom will be assigned to -1") + elif valence > 4: + raise ValueError(f"#C{atom.GetIdx()+1} has a valence larger than 4") + elif atom.GetSymbol() == "N": + if valence > 4: + raise ValueError(f"#N{atom.GetIdx()+1} has a valence larger than 4") + else: + atom.SetFormalCharge(valence - 3) + elif atom.GetSymbol() == "O": + atom.SetFormalCharge(valence - 2) + elif atom.GetSymbol() == "S": + if valence == 1: + atom.SetFormalCharge(-1) + elif valence == 3: + atom.SetFormalCharge(1) + elif valence > 6: + raise ValueError(f"#S{atom.GetIdx()+1} has a valence larger than 6") + else: + atom.SetFormalCharge(0) + elif atom.GetSymbol() == "P" or atom.GetSymbol() == "As": + if valence == 5: + atom.SetFormalCharge(0) + elif valence > 5: + raise ValueError(f"#{atom.GetSymbol()}{atom.GetIdx()+1} has a valence larger than 5") + else: + atom.SetFormalCharge(valence - 3) + +# print bond and atom information (for debugger) +def print_bonds(mol): + for bond in mol.GetBonds(): + begin_atom = bond.GetBeginAtom() + end_atom = bond.GetEndAtom() + print(f'{begin_atom.GetSymbol()}{begin_atom.GetIdx()+1} {end_atom.GetSymbol()}{end_atom.GetIdx()+1} {bond.GetBondType()}') + +def print_atoms(mol): + for atom in mol.GetAtoms(): + print(f'{atom.GetSymbol()}{atom.GetIdx()+1} {atom.GetFormalCharge()} {get_explicit_valence(atom)}') + + +def is_terminal_oxygen(O_atom): + if len(O_atom.GetNeighbors()) == 1: + return True + else: + return False + +def get_terminal_oxygens(atom): + terminal_oxygens = [] + for nei in atom.GetNeighbors(): + if nei.GetSymbol() == "O" or nei.GetSymbol() == "S": + if is_terminal_oxygen(nei): + terminal_oxygens.append(nei) + return terminal_oxygens + +def sanitize_phosphate_Patom(P_atom, verbose=True): + if P_atom.GetSymbol() == "P": + terminal_oxygens = get_terminal_oxygens(P_atom) + mol = P_atom.GetOwningMol() + if len(terminal_oxygens) > 1: + if verbose: + print("Phospate group detected, sanitizing it...") + # set one P=O and two P-O + bond1 = mol.GetBondBetweenAtoms(P_atom.GetIdx(), terminal_oxygens[0].GetIdx()) + bond1.SetBondType(Chem.rdchem.BondType.DOUBLE) + for ii in range(1, len(terminal_oxygens)): + bond = mol.GetBondBetweenAtoms(P_atom.GetIdx(), terminal_oxygens[ii].GetIdx()) + bond.SetBondType(Chem.rdchem.BondType.SINGLE) + terminal_oxygens[ii].SetFormalCharge(-1) + +def sanitize_phosphate(mol): + for atom in mol.GetAtoms(): + sanitize_phosphate_Patom(atom) + return mol + +def sanitize_sulfate_Satom(S_atom, verbose=True): + if S_atom.GetSymbol() == "S": + terminal_oxygens = get_terminal_oxygens(S_atom) + mol = S_atom.GetOwningMol() + if len(terminal_oxygens) == 3: + if verbose: + print("Sulfate group detected, sanitizing it...") + # set one S-O and two S=O + bond1 = mol.GetBondBetweenAtoms(S_atom.GetIdx(), terminal_oxygens[0].GetIdx()) + bond1.SetBondType(Chem.rdchem.BondType.SINGLE) + terminal_oxygens[0].SetFormalCharge(-1) + for ii in range(1, len(terminal_oxygens)): + bond = mol.GetBondBetweenAtoms(S_atom.GetIdx(), terminal_oxygens[ii].GetIdx()) + bond.SetBondType(Chem.rdchem.BondType.DOUBLE) + +def sanitize_sulfate(mol): + for atom in mol.GetAtoms(): + sanitize_sulfate_Satom(atom) + return mol + +def sanitize_carboxyl_Catom(C_atom, verbose=True): + if C_atom.GetSymbol() == "C": + terminal_oxygens = get_terminal_oxygens(C_atom) + mol = C_atom.GetOwningMol() + if len(terminal_oxygens) == 2: + if verbose: + print("Carbonxyl group detected, sanitizing it...") + # set one C-O and one C=O + bond1 = mol.GetBondBetweenAtoms(C_atom.GetIdx(), terminal_oxygens[0].GetIdx()) + bond1.SetBondType(Chem.rdchem.BondType.SINGLE) + terminal_oxygens[0].SetFormalCharge(-1) + + bond2 = mol.GetBondBetweenAtoms(C_atom.GetIdx(), terminal_oxygens[1].GetIdx()) + bond2.SetBondType(Chem.rdchem.BondType.DOUBLE) + terminal_oxygens[1].SetFormalCharge(0) + +def sanitize_carboxyl(mol): + for atom in mol.GetAtoms(): + sanitize_carboxyl_Catom(atom) + return mol + +def sanitize_nitro_Natom(N_atom, verbose=True): + if N_atom.GetSymbol() == "N": + terminal_oxygens = get_terminal_oxygens(N_atom) + mol = N_atom.GetOwningMol() + if len(terminal_oxygens) == 2: + if verbose: + print("Nitro group detected, sanitizing it...") + # set one N-O and one N=O + bond1 = mol.GetBondBetweenAtoms(N_atom.GetIdx(), terminal_oxygens[0].GetIdx()) + bond1.SetBondType(Chem.rdchem.BondType.SINGLE) + terminal_oxygens[0].SetFormalCharge(-1) + + bond2 = mol.GetBondBetweenAtoms(N_atom.GetIdx(), terminal_oxygens[1].GetIdx()) + bond2.SetBondType(Chem.rdchem.BondType.DOUBLE) + terminal_oxygens[1].SetFormalCharge(0) + +def sanitize_nitro(mol): + for atom in mol.GetAtoms(): + sanitize_nitro_Natom(atom) + return mol + +def is_terminal_nitrogen(N_atom): + if N_atom.GetSymbol() == 'N' and len(N_atom.GetNeighbors()) == 1: + return True + else: + return False + +def sanitize_nitrine_Natom(atom, verbose=True): + if atom.GetSymbol() == "N" and len(atom.GetNeighbors()) == 2: + mol = atom.GetOwningMol() + nei1, nei2 = atom.GetNeighbors()[0], atom.GetNeighbors()[1] + if nei1.GetSymbol() == "N" and nei2.GetSymbol() == "N": + if is_terminal_nitrogen(nei1): + N_terminal = nei1 + N_non_terminal = nei2 + elif is_terminal_nitrogen(nei2): + N_terminal = nei2 + N_non_terminal = nei1 + else: + N_terminal = None + N_non_terminal = None + if (N_terminal is not None) and (N_non_terminal is not None): + # set X-N=[N+]=[N-] + if verbose: + print("Detecting nitrine group, fixing it...") + bond = mol.GetBondBetweenAtoms(atom.GetIdx(), N_terminal.GetIdx()) + bond.SetBondType(Chem.rdchem.BondType.DOUBLE) + N_terminal.SetFormalCharge(-1) + + bond = mol.GetBondBetweenAtoms(atom.GetIdx(), N_non_terminal.GetIdx()) + bond.SetBondType(Chem.rdchem.BondType.DOUBLE) + atom.SetFormalCharge(1) + +def contain_hetero_aromatic(mol): + flag = False + for atom in mol.GetAtoms(): + if atom.GetSymbol() != "C" and atom.GetIsAromatic(): + flag = True + break + return flag + +# for carbon with explicit valence > 4 +def regularize_carbon_bond_order(atom, verbose=True): + if atom.GetSymbol() == "C" and get_explicit_valence(atom) > 4: + if verbose: + print("Detecting carbon with explicit valence > 4, fixing it...") + mol = atom.GetOwningMol() + double_bond_idx = -1 + for nei in atom.GetNeighbors(): + bond = mol.GetBondBetweenAtoms(atom.GetIdx(), nei.GetIdx()) + if bond.GetBondTypeAsDouble() == 2: + double_bond_idx = bond.GetIdx() + break + if double_bond_idx != -1: + for bond in atom.GetBonds(): + if bond.GetIdx() != double_bond_idx: + bond.SetBondType(Chem.rdchem.BondType.SINGLE) + +# for nitrogen with explicit valence > 4 +def regularize_nitrogen_bond_order(atom, verbose=True): + mol = atom.GetOwningMol() + if atom.GetSymbol() == "N" and get_explicit_valence(atom) > 4: + O_atoms = get_terminal_oxygens(atom) + for O_atom in O_atoms: + bond = mol.GetBondBetweenAtoms(atom.GetIdx(), O_atom.GetIdx()) + if bond.GetBondTypeAsDouble() == 2: + bond.SetBondType(Chem.rdchem.BondType.SINGLE) + O_atom.SetFormalCharge(-1) + + +def sanitize_mol(mol, verbose=False): + for atom in mol.GetAtoms(): + sanitize_carboxyl_Catom(atom, verbose) + sanitize_phosphate_Patom(atom, verbose) + sanitize_sulfate_Satom(atom, verbose) + sanitize_nitro_Natom(atom, verbose) + sanitize_nitrine_Natom(atom, verbose) + regularize_carbon_bond_order(atom, verbose) + regularize_nitrogen_bond_order(atom, verbose) + return mol + + +# copy from FEprep +def mol_edit_log(mol, i, j): + if not mol.HasProp("edit"): + mol.SetProp("edit", "%d_%d" % (i, j)) + else: + edited = mol.GetProp("edit") + mol.SetProp("edit", edited + ",%d_%d" % (i, j)) + +def kekulize_aromatic_heterocycles(mol_in, assign_formal_charge=True, sanitize=True): + mol = Chem.RWMol(mol_in) + rings = Chem.rdmolops.GetSymmSSSR(mol) + rings = [list(i) for i in list(rings)] + rings.sort(key=lambda r: len(r)) + + def search_and_assign_ring(mol, ring, hetero, start, forward=True, start_switch=True): + j = start + switch = start_switch + lring = len(ring) + delta = 1 if forward else -1 + n_edit = 0 + n_double = 0 + while not ((j in hetero) & (not switch)): + btype = BondType.SINGLE if switch else BondType.DOUBLE + bond = mol.GetBondBetweenAtoms(ring[j], ring[(j + delta) % lring]) + if bond.GetBondType() == BondType.AROMATIC: + bond.SetBondType(btype) + mol_edit_log(mol, ring[j], ring[(j + delta) % lring]) + # print(ring[j], ring[(j + delta) % lring], bond.GetBondType()) + if btype == BondType.DOUBLE: + n_double += 1 + n_edit += 1 + else: + break + j = (j + delta) % lring + switch = not switch + return n_edit, n_double + + def print_bondtypes(mol, rings): + for ring in rings: + lring = len(ring) + btype = [] + for i in range(lring): + btype.append(mol.GetBondBetweenAtoms(ring[i], ring[(i + 1) % lring]).GetBondType()) + atoms = [mol.GetAtomWithIdx(i).GetSymbol() for i in ring] + print(ring) + print(atoms) + print(btype) + + def hetero_priority(idx, mol): + atom = mol.GetAtomWithIdx(idx) + sym = atom.GetSymbol() + valence = len(atom.GetBonds()) + + if (sym in ['O', 'S']) & (valence == 2): + return 0 + elif (sym in ['N', 'P', 'As', 'B']): + if valence == 3: + return 1 + elif valence == 2: + return 2 + + # save carbon/hetero aromatic rings + CAr = [] + HAr = [] + for ring in rings: + lring = len(ring) + bAllAr = True + bAllC = True + for i in range(lring): + atom = mol.GetAtomWithIdx(ring[i]) + if atom.GetSymbol() != 'C': + bAllC = False + + bond = mol.GetBondBetweenAtoms(ring[i], ring[(i + 1) % lring]) + if bond.GetBondType() != BondType.AROMATIC: + bAllAr = False + if bAllAr and bAllC: + CAr.append(ring) + elif bAllAr and not bAllC: + HAr.append(ring) + + if len(HAr) == 0: + # no hetrerocycles + return mol_in + else: + # edit heterocycles + for ring in HAr: + lring = len(ring) + cring = len(CAr) + hetero = [] + hasDouble = [] + fuseCAr = [] + fuseDouble = [] + for i in range(lring): + fuseCAr.append(-1) + for j in range(cring): + if ring[i] in CAr[j]: + fuseCAr[i] = j + break + if i > 1: + if (fuseCAr[i] == fuseCAr[i-1]) & (fuseCAr[i] >= 0): + fuseDouble.append(i) + atom = mol.GetAtomWithIdx(ring[i]) + if atom.GetSymbol() != 'C': + hetero.append(i) + atom_bonds = atom.GetBonds() + btype = [bond.GetBondType() for bond in atom_bonds] + # print(btype) + if BondType.DOUBLE in btype: + hasDouble.append(i) + bond = mol.GetBondBetweenAtoms(ring[i], ring[(i + 1) % lring]) + + if (fuseCAr[0] == fuseCAr[lring-1]) & (fuseCAr[0] >= 0): + fuseDouble.append(0) + + if (len(hetero) > 0) | (len(hasDouble) > 0): + n_targetDouble = lring // 2 + n_targetEdit = lring + hetero_prior = {i: hetero_priority(ring[i], mol) for i in hetero} + hetero.sort(key=lambda i: hetero_prior[i]) + for i in hasDouble: + d1, e1 = search_and_assign_ring(mol, ring, hetero, i, forward=True) + d2, e2 = search_and_assign_ring(mol, ring, hetero, i, forward=False) + n_targetDouble -= (d1 + d2 + 1) + n_targetEdit -= (e1 + e2) + for i in fuseDouble: + bond = mol.GetBondBetweenAtoms(ring[i], ring[(i - 1) % lring]) + if bond.GetBondType() == BondType.AROMATIC: + bond.SetBondType(BondType.DOUBLE) + mol_edit_log(mol, ring[i], ring[(i - 1) % lring]) + d1, e1 = search_and_assign_ring(mol, ring, hetero, i, forward=True) + d2, e2 = search_and_assign_ring(mol, ring, hetero, (i - 1) % lring, forward=False) + n_targetDouble -= (d1 + d2 + 1) + n_targetEdit -= (e1 + e2 + 1) + for i in hetero: + atom = mol.GetAtomWithIdx(ring[i]) + if (hetero_prior[i] == 2) | (n_targetDouble * 2 >= n_targetEdit): + forward_btype = mol.GetBondBetweenAtoms(ring[i], ring[(i + 1) % lring]).GetBondType() + backward_btype = mol.GetBondBetweenAtoms(ring[i], ring[(i - 1) % lring]).GetBondType() + if forward_btype != BondType.AROMATIC: + switch = forward_btype == BondType.DOUBLE + d1, e1 = search_and_assign_ring(mol, ring, hetero, i, forward=False, start_switch=switch) + d2 = e2 = 0 + elif backward_btype != BondType.AROMATIC: + switch = backward_btype == BondType.DOUBLE + d1, e1 = search_and_assign_ring(mol, ring, hetero, i, forward=True, start_switch=switch) + d2 = e2 = 0 + else: + d1, e1 = search_and_assign_ring(mol, ring, hetero, i, forward=True, start_switch=True) + d2, e2 = search_and_assign_ring(mol, ring, hetero, i, forward=False, start_switch=False) + n_targetDouble -= (d1 + d2) + n_targetEdit -= (e1 + e2) + else: + d1, e1 = search_and_assign_ring(mol, ring, hetero, i, forward=True, start_switch=True) + d2, e2 = search_and_assign_ring(mol, ring, hetero, i, forward=False, start_switch=True) + n_targetDouble -= (d1 + d2) + n_targetEdit -= (e1 + e2) + + for ring in CAr: + lring = len(ring) + for i in range(lring): + bond = mol.GetBondBetweenAtoms(ring[i], ring[(i + 1) % lring]) + bond.SetBondType(BondType.AROMATIC) + print("Manual kekulization for aromatic heterocycles:") + print_bondtypes(mol, rings) + + atoms = mol.GetAtoms() + for i in range(len(atoms)): + mol.ReplaceAtom(i, Chem.Atom(atoms[i].GetSymbol())) + mol_edited = mol.GetMol() + # charge assignment + if assign_formal_charge: + mol_edited = regularize_formal_charges(mol_edited, sanitize=False) + if not sanitize: + return mol_edited + else: + try: + Chem.SanitizeMol(mol_edited) + return mol_edited + except Exception as e: + raise RuntimeError(f"Manual kekulization for aromatic heterocycles failed, below are errors:\n\t {e}") + +def convert_by_obabel(mol, cache_dir=os.path.join(os.getcwd(), '.cache'), obabel_path="obabel"): + if not os.path.exists(cache_dir): + os.mkdir(cache_dir) + if mol.HasProp("_Name"): + name = mol.GetProp("_Name") + else: + name = f"mol{int(time.time())}" + mol_file_in = os.path.join(cache_dir, f'{name}.mol') + mol_file_out = os.path.join(cache_dir, f'{name}_obabel.mol') + Chem.MolToMolFile(mol, mol_file_in, kekulize=False) + out = os.popen(f"obabel {mol_file_in} -O {mol_file_out}").read() + mol_obabel = Chem.MolFromMolFile(mol_file_out, removeHs=False, sanitize=False) + return mol_obabel + +def super_sanitize_mol(mol, name=None, verbose=True): + if name is None: + if mol.HasProp("_Name"): + name = mol.GetProp("_Name") + else: + name = "mol" + try: + if verbose: + print("=====Stage 1: use Hermite procedure=====") + # use our procedure + mol = sanitize_mol(mol, verbose) + mol = regularize_formal_charges(mol, sanitize=False) + mol_copy = deepcopy(mol) + Chem.SanitizeMol(mol_copy) + if verbose: + print(name, "Success.") + return mol_copy + except Exception as e: + try: + if verbose: + print("Hermite procedure failed, maybe due to unsupported representation of hetero aromatic rings, re-try with obabel") + print("=====Stage 2: re-try with obabel=====") + mol = convert_by_obabel(mol) + mol = sanitize_mol(mol, verbose) + mol = kekulize_aromatic_heterocycles(mol, assign_formal_charge=False, sanitize=False) # aromatic heterocycles + mol = regularize_formal_charges(mol, sanitize=False) + mol_copy = deepcopy(mol) + Chem.SanitizeMol(mol_copy) + if verbose: + print(name, "Success.") + return mol_copy + except Exception as e: + if verbose: + print(e) + print(name, "Failed!") + return None + +class Sanitizer(object): + def __init__(self, level='medium', raise_errors=True, verbose=False): + ''' + Set up sanitizer. + -------- + Parameters: + level : 'low', 'medium' or 'high'. + `low` - use rdkit.Chem.SanitizeMol() to sanitize + `medium` - before using rdkit, assign formal charges of each atom first, which requires + the rightness of bond order information + `high` - try to regularize bond order of nitro, phosphate, sulfate, nitrine, guanidine, + pyridine-oxide function groups and aromatic heterocycles. If failed, the program + will call obabel to pre-process the mol object and re-try the procedure. + ''' + self._check_level(level) + self.level = level + self.raise_errors = raise_errors + self.verbose = verbose + + def _check_level(self, level): + if level not in ['low', 'medium', 'high']: + raise ValueError(f"Invalid level '{level}', please set to 'low', 'medium' or 'high'") + else: + if level == 'high' and not USE_OBABEL: + raise OSError("obabel not installed, high level sanitizer cannot work") + + def _handle_exception(self, error_info): + if self.raise_errors: + raise SanitizeError(error_info) + elif self.verbose: + print(error_info) + + def sanitize(self, mol): + ''' + Sanitize mol according to `self.level`. If failed, return None. + ''' + if self.level == "low": + try: + Chem.SanitizeMol(mol) + return mol + except Exception as e: + error_info = f"Sanitization Failed, please use more strict sanitizer by setting 'level' to 'medium' or 'high'. The error occurs:\n\t{e}" + self._handle_exception(error_info) + return None + elif self.level == "medium": + try: + mol = regularize_formal_charges(mol, sanitize=False) + Chem.SanitizeMol(mol) + return mol + except Exception as e: + error_info = f"Sanitization Failed, please use more strict sanitizer by setting 'level' to 'high'. The error occurs:\n\t{e}" + self._handle_exception(error_info) + return None + elif self.level == "high": + mol = super_sanitize_mol(mol, verbose=self.verbose) + error_info = "Sanitization Failed. Please check your molecule file." + if mol is None: + self._handle_exception(error_info) + return mol + +class SanitizeError(Exception): + def __init__(self, content="Sanitization Failed."): + self.content = content + + def __str__(self): + return self.content + + def __repr__(self): + return self.__str__() \ No newline at end of file diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index 1e9748629..a8a52be86 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -1,10 +1,10 @@ from rdkit import Chem +from rdkit.Chem import AllChem import numpy as np def mol_to_system_data(mol): - mol = regularize_formal_charges(mol) - if not mol: - raise RuntimeError("Sanitize Failed, please check your input file") + if not isinstance(mol, Chem.rdchem.Mol): + raise TypeError(f"rdkit.Chem.Mol required, not {type(mol)}") num_confs = mol.GetNumConformers() if num_confs: @@ -26,50 +26,47 @@ def mol_to_system_data(mol): data['bonds'] = bonds data['formal_charges'] = formal_charges data['orig'] = np.array([0., 0., 0.]) + # other properties + if mol.HasProp("_Name"): + data['_name'] = mol.GetProp('_Name') return data else: raise ValueError("The moleclue does not contain 3-D conformers") - -def regularize_formal_charges(mol): - """ - Regularize formal charges of atoms - """ - for atom in mol.GetAtoms(): - assign_formal_charge_for_atom(atom) - try: - Chem.SanitizeMol(mol) - return mol - except: - return None - - -def assign_formal_charge_for_atom(atom): - """ - assign formal charge according to 8-electron rule for element B,C,N,O,S,P,As - """ - if atom.GetSymbol() == "B": - atom.SetFormalCharge(3 - atom.GetExplicitValence()) - elif atom.GetSymbol() == "C": - atom.SetFormalCharge(atom.GetExplicitValence() - 4) - if atom.GetExplicitValence() == 3: - print(f"Detect a valence of 3 on carbon #{atom.GetIdx()}, the formal charge of this atom will be assigned to -1") - elif atom.GetSymbol() == "N": - atom.SetFormalCharge(atom.GetExplicitValence() - 3) - elif atom.GetSymbol() == "O": - atom.SetFormalCharge(atom.GetExplicitValence() - 2) - elif atom.GetSymbol() == "S": - if atom.GetExplicitValence() == 1: - atom.SetFormalCharge(-1) - elif atom.GetExplicitValence() == 3: - atom.SetFormalCharge(1) - else: - atom.SetFormalCharge(0) - elif atom.GetSymbol() == "P" or atom.GetSymbol() == "As": - if atom.GetExplicitValence() == 5: - atom.SetFormalCharge(0) - else: - atom.SetFormalCharge(atom.GetExplicitValence() - 3) +def system_data_to_mol(data): + mol_ed = Chem.RWMol() + atom_symbols = [data['atom_names'][i] for i in data['atom_types']] + # add atoms + for atom_type in data['atom_types']: + symbol = data['atom_names'][atom_type] + atom = Chem.Atom(symbol) + mol_ed.AddAtom(atom) + # add bonds + for bond_info in data['bonds']: + if bond_info[2] == 1: + mol_ed.AddBond(int(bond_info[0]), int(bond_info[1]), Chem.BondType.SINGLE) + elif bond_info[2] == 2: + mol_ed.AddBond(int(bond_info[0]), int(bond_info[1]), Chem.BondType.DOUBLE) + elif bond_info[2] == 3: + mol_ed.AddBond(int(bond_info[0]), int(bond_info[1]), Chem.BondType.TRIPLE) + elif bond_info[2] == 1.5: + mol_ed.AddBond(int(bond_info[0]), int(bond_info[1]), Chem.BondType.AROMATIC) + # set conformers + for frame_idx in range(data['coords'].shape[0]): + conf = Chem.rdchem.Conformer(len(data['atom_types'])) + for atom_idx in range(len(data['atom_types'])): + conf.SetAtomPosition(atom_idx, data['coords'][frame_idx][atom_idx]) + mol_ed.AddConformer(conf, assignId=True) + mol = mol_ed.GetMol() + # set formal charges + for idx, atom in enumerate(mol.GetAtoms()): + atom.SetFormalCharge(data['formal_charges'][idx]) + # set mol name + if '_name' in list(data.keys()): + mol.SetProp("_Name", data['_name']) + # sanitize + Chem.SanitizeMol(mol_ed) + return mol def check_same_atom(atom_1, atom_2): @@ -108,4 +105,4 @@ def combine_molecules(mols): mols[0].AddConformer(conf, assignId=True) return mols[0] else: - raise ValueError("molecules are not of the same topology.") + raise ValueError("molecules are not of the same topology.") \ No newline at end of file From 95883e7b6a9b741e932a2bb66588a394ffa3b9ef Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:21:34 +0800 Subject: [PATCH 12/28] Add test cases for bond order assignment --- .../obabel/1a4r_ligand_obabel.sdf | 107 ++++++++++++ .../obabel/1ai5_ligand_obabel.sdf | 60 +++++++ .../obabel/1f5l_ligand_obabel.sdf | 70 ++++++++ .../obabel/1m1b_ligand_obabel.sdf | 45 +++++ .../obabel/1mue_ligand_obabel.sdf | 121 +++++++++++++ .../obabel/1w4q_ligand_obabel.sdf | 84 +++++++++ .../obabel/2e94_ligand_obabel.sdf | 113 ++++++++++++ .../obabel/4xaq_ligand_obabel.sdf | 69 ++++++++ .../obabel/4xtw_ligand_obabel.sdf | 161 ++++++++++++++++++ .../origin/1a4r_ligand.sdf | 107 ++++++++++++ .../origin/1ai5_ligand.sdf | 59 +++++++ .../origin/1f5l_ligand.sdf | 69 ++++++++ .../origin/1m1b_ligand.sdf | 44 +++++ .../origin/1mue_ligand.sdf | 121 +++++++++++++ .../origin/1w4q_ligand.sdf | 84 +++++++++ .../origin/2e94_ligand.sdf | 113 ++++++++++++ .../origin/4xaq_ligand.sdf | 68 ++++++++ .../origin/4xtw_ligand.sdf | 161 ++++++++++++++++++ tests/test_bond_order_system.py | 23 ++- 19 files changed, 1678 insertions(+), 1 deletion(-) create mode 100644 tests/bond_order/refined-set-ligands/obabel/1a4r_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/1ai5_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/1f5l_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/1m1b_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/1mue_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/1w4q_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/2e94_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/4xaq_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/obabel/4xtw_ligand_obabel.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/1a4r_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/1ai5_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/1f5l_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/1m1b_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/1mue_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/1w4q_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/2e94_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/4xaq_ligand.sdf create mode 100644 tests/bond_order/refined-set-ligands/origin/4xtw_ligand.sdf diff --git a/tests/bond_order/refined-set-ligands/obabel/1a4r_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/1a4r_ligand_obabel.sdf new file mode 100644 index 000000000..efbacb0fc --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/1a4r_ligand_obabel.sdf @@ -0,0 +1,107 @@ +1a4r_ligand + OpenBabel05112116033D +Created by X-TOOL on Fri Nov 18 12:31:18 2016 + 42 44 0 0 0 0 0 0 0 0999 V2000 + 102.4860 24.8700 -2.9090 N 0 0 0 0 0 0 0 0 0 0 0 0 + 101.5220 25.8860 -2.4280 P 0 0 0 0 0 0 0 0 0 0 0 0 + 100.9830 25.4700 -1.0790 O 0 0 0 0 0 0 0 0 0 0 0 0 + 100.3500 26.2500 -3.2730 O 0 0 0 0 0 0 0 0 0 0 0 0 + 102.4090 27.1490 -2.1360 O 0 0 0 0 0 0 0 0 0 0 0 0 + 102.9800 27.8190 -0.7750 P 0 0 0 0 0 0 0 0 0 0 0 0 + 103.9320 26.8730 -0.1570 O 0 0 0 0 0 0 0 0 0 0 0 0 + 101.8500 28.3180 0.0570 O 0 0 0 0 0 0 0 0 0 0 0 0 + 103.7180 29.0170 -1.4980 O 0 0 0 0 0 0 0 0 0 0 0 0 + 104.8640 28.8490 -2.3670 C 0 0 0 0 0 0 0 0 0 0 0 0 + 105.9930 29.8990 -2.1000 C 0 0 1 0 0 0 0 0 0 0 0 0 + 105.4820 31.1830 -2.4390 O 0 0 0 0 0 0 0 0 0 0 0 0 + 106.4630 30.0620 -0.6570 C 0 0 1 0 0 0 0 0 0 0 0 0 + 107.8730 30.1930 -0.5940 O 0 0 0 0 0 0 0 0 0 0 0 0 + 105.7350 31.2660 -0.0960 C 0 0 1 0 0 0 0 0 0 0 0 0 + 106.2980 31.8890 1.0590 O 0 0 0 0 0 0 0 0 0 0 0 0 + 105.5820 32.1390 -1.3490 C 0 0 2 0 0 0 0 0 0 0 0 0 + 104.3150 32.9430 -1.5100 N 0 0 0 0 0 0 0 0 0 0 0 0 + 103.0000 32.5360 -1.3540 C 0 0 0 0 0 0 0 0 0 0 0 0 + 102.0730 33.4460 -1.5560 N 0 0 0 0 0 0 0 0 0 0 0 0 + 102.8070 34.5960 -1.8890 C 0 0 0 0 0 0 0 0 0 0 0 0 + 102.3660 35.9710 -2.2360 C 0 0 0 0 0 0 0 0 0 0 0 0 + 101.2060 36.3850 -2.3060 O 0 0 0 0 0 0 0 0 0 0 0 0 + 103.4480 36.8880 -2.5220 N 0 0 0 0 0 0 0 0 0 0 0 0 + 104.8390 36.5560 -2.4810 C 0 0 0 0 0 0 0 0 0 0 0 0 + 105.7330 37.5170 -2.7670 N 0 0 0 0 0 0 0 0 0 0 0 0 + 105.2800 35.2710 -2.1570 N 0 0 0 0 0 0 0 0 0 0 0 0 + 104.2050 34.3230 -1.8660 C 0 0 0 0 0 0 0 0 0 0 0 0 + 102.1650 23.9586 -3.1665 H 0 0 0 0 0 0 0 0 0 0 0 0 + 103.4580 25.0953 -2.9763 H 0 0 0 0 0 0 0 0 0 0 0 0 + 104.5306 28.9505 -3.4103 H 0 0 0 0 0 0 0 0 0 0 0 0 + 105.2779 27.8419 -2.2106 H 0 0 0 0 0 0 0 0 0 0 0 0 + 106.8572 29.6421 -2.7302 H 0 0 0 0 0 0 0 0 0 0 0 0 + 106.1769 29.1711 -0.0788 H 0 0 0 0 0 0 0 0 0 0 0 0 + 108.1405 30.2929 0.3121 H 0 0 0 0 0 0 0 0 0 0 0 0 + 104.7318 30.9403 0.2163 H 0 0 0 0 0 0 0 0 0 0 0 0 + 107.1751 32.1932 0.8575 H 0 0 0 0 0 0 0 0 0 0 0 0 + 106.4561 32.8002 -1.4424 H 0 0 0 0 0 0 0 0 0 0 0 0 + 102.7469 31.5134 -1.0779 H 0 0 0 0 0 0 0 0 0 0 0 0 + 103.2047 37.8264 -2.7673 H 0 0 0 0 0 0 0 0 0 0 0 0 + 106.7409 37.3058 -2.7451 H 0 0 0 0 0 0 0 0 0 0 0 0 + 105.4106 38.4650 -3.0082 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 29 1 0 0 0 0 + 1 30 1 0 0 0 0 + 2 1 1 0 0 0 0 + 2 3 2 0 0 0 0 + 2 4 2 0 0 0 0 + 2 5 1 0 0 0 0 + 5 6 1 0 0 0 0 + 6 7 2 0 0 0 0 + 6 8 2 0 0 0 0 + 6 9 1 0 0 0 0 + 9 10 1 0 0 0 0 + 10 11 1 0 0 0 0 + 10 31 1 0 0 0 0 + 10 32 1 0 0 0 0 + 11 12 1 0 0 0 0 + 11 13 1 0 0 0 0 + 11 33 1 6 0 0 0 + 12 17 1 0 0 0 0 + 13 14 1 0 0 0 0 + 13 15 1 0 0 0 0 + 13 34 1 1 0 0 0 + 14 35 1 0 0 0 0 + 15 16 1 0 0 0 0 + 15 36 1 1 0 0 0 + 16 37 1 0 0 0 0 + 17 15 1 0 0 0 0 + 17 18 1 0 0 0 0 + 17 38 1 6 0 0 0 + 18 19 1 0 0 0 0 + 18 28 1 0 0 0 0 + 19 20 2 0 0 0 0 + 19 39 1 0 0 0 0 + 20 21 1 0 0 0 0 + 21 22 1 0 0 0 0 + 21 28 2 0 0 0 0 + 22 23 2 0 0 0 0 + 22 24 1 0 0 0 0 + 24 25 1 0 0 0 0 + 24 40 1 0 0 0 0 + 25 26 1 0 0 0 0 + 25 27 2 0 0 0 0 + 26 41 1 0 0 0 0 + 26 42 1 0 0 0 0 + 27 28 1 0 0 0 0 +M END +> +C10H14N6O10P2 + +> +440.1 + +> +16 + +> +6 + +> +-4.52 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/1ai5_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/1ai5_ligand_obabel.sdf new file mode 100644 index 000000000..1c195a771 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/1ai5_ligand_obabel.sdf @@ -0,0 +1,60 @@ +1ai5_ligand + OpenBabel05112116033D +Created by X-TOOL on Fri Nov 18 12:05:44 2016 + 19 19 0 0 0 0 0 0 0 0999 V2000 + 14.0160 37.7680 36.3700 C 0 5 0 0 0 0 0 0 0 0 0 0 + 13.9490 36.3240 35.8790 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.6700 35.9080 35.2370 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.4280 36.4610 34.0030 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.2590 36.0710 33.4050 C 0 0 0 0 0 0 0 0 0 0 0 0 + 10.9480 36.5440 32.1190 N 0 0 0 0 0 0 0 0 0 0 0 0 + 9.7150 35.9000 31.8610 O 0 0 0 0 0 0 0 0 0 0 0 0 + 11.6460 37.4310 31.3120 O 0 0 0 0 0 0 0 0 0 0 0 0 + 10.3140 35.1870 33.8960 C 0 0 0 0 0 0 0 0 0 0 0 0 + 10.5900 34.6320 35.1090 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.7540 35.0150 35.7910 C 0 0 0 0 0 0 0 0 0 0 0 0 + 14.5840 37.9400 37.4320 O 0 0 0 0 0 0 0 0 0 0 0 0 + 13.5320 38.7810 35.9290 O 0 0 0 0 0 0 0 0 0 0 0 0 + 14.1200 35.6666 36.7442 H 0 0 0 0 0 0 0 0 0 0 0 0 + 14.7555 36.1810 35.1448 H 0 0 0 0 0 0 0 0 0 0 0 0 + 13.1143 37.1575 33.5351 H 0 0 0 0 0 0 0 0 0 0 0 0 + 9.4089 34.9506 33.3483 H 0 0 0 0 0 0 0 0 0 0 0 0 + 9.9166 33.9016 35.5428 H 0 0 0 0 0 0 0 0 0 0 0 0 + 11.9468 34.6054 36.7760 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 13 2 0 0 0 0 + 1 12 2 0 0 0 0 + 1 2 1 0 0 0 0 + 2 3 1 0 0 0 0 + 2 14 1 0 0 0 0 + 2 15 1 0 0 0 0 + 3 11 2 0 0 0 0 + 3 4 1 0 0 0 0 + 4 5 2 0 0 0 0 + 4 16 1 0 0 0 0 + 5 9 1 0 0 0 0 + 5 6 1 0 0 0 0 + 6 8 2 0 0 0 0 + 6 7 2 0 0 0 0 + 9 10 2 0 0 0 0 + 9 17 1 0 0 0 0 + 10 11 1 0 0 0 0 + 10 18 1 0 0 0 0 + 11 19 1 0 0 0 0 +M CHG 1 1 -1 +M END +> +C8H6NO4 + +> +180.1 + +> +4 + +> +1 + +> +1.08 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/1f5l_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/1f5l_ligand_obabel.sdf new file mode 100644 index 000000000..aae7d264c --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/1f5l_ligand_obabel.sdf @@ -0,0 +1,70 @@ +1f5l_ligand + OpenBabel05112116043D +Created by X-TOOL on Fri Nov 18 12:50:13 2016 + 24 24 0 0 0 0 0 0 0 0999 V2000 + 31.1120 7.6690 27.6830 N 0 0 0 0 0 0 0 0 0 0 0 0 + 30.5020 6.7410 28.4320 C 0 0 0 0 0 0 0 0 0 0 0 0 + 31.2400 5.3550 28.6010 C 0 0 0 0 0 0 0 0 0 0 0 0 + 32.5550 5.2790 28.1310 N 0 0 0 0 0 4 0 0 0 0 0 0 + 33.2510 4.1770 28.0800 C 0 3 0 0 0 0 0 0 0 0 0 0 + 32.7670 3.0180 28.4620 N 0 0 0 0 0 4 0 0 0 0 0 0 + 34.4700 4.2400 27.6300 N 0 0 0 0 0 4 0 0 0 0 0 0 + 30.6520 4.3960 29.1150 O 0 0 0 0 0 0 0 0 0 0 0 0 + 29.2610 7.0260 29.0190 C 0 0 0 0 0 0 0 0 0 0 0 0 + 28.5730 6.0860 29.8140 N 0 0 0 0 0 0 0 0 0 0 0 0 + 28.6930 8.2380 28.8250 N 0 0 0 0 0 0 0 0 0 0 0 0 + 29.3140 9.1790 28.0650 C 0 0 0 0 0 0 0 0 0 0 0 0 + 28.6660 10.4360 27.8950 N 0 0 0 0 0 0 0 0 0 0 0 0 + 30.5610 8.8800 27.4780 C 0 0 0 0 0 0 0 0 0 0 0 0 + 31.4320 10.0160 26.4870 Cl 0 0 0 0 0 0 0 0 0 0 0 0 + 32.9889 6.1224 27.8142 H 0 0 0 0 0 0 0 0 0 0 0 0 + 33.3514 2.1718 28.4049 H 0 0 0 0 0 0 0 0 0 0 0 0 + 31.8028 2.9549 28.8188 H 0 0 0 0 0 0 0 0 0 0 0 0 + 34.8612 5.1435 27.3272 H 0 0 0 0 0 0 0 0 0 0 0 0 + 35.0440 3.3864 27.5765 H 0 0 0 0 0 0 0 0 0 0 0 0 + 27.6628 6.3308 30.2293 H 0 0 0 0 0 0 0 0 0 0 0 0 + 28.9808 5.1547 29.9793 H 0 0 0 0 0 0 0 0 0 0 0 0 + 29.1091 11.1710 27.3254 H 0 0 0 0 0 0 0 0 0 0 0 0 + 27.7543 10.6100 28.3417 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 2 9 2 0 0 0 0 + 2 3 1 0 0 0 0 + 3 8 2 0 0 0 0 + 3 4 1 0 0 0 0 + 4 5 2 0 0 0 0 + 4 16 1 0 0 0 0 + 5 7 2 0 0 0 0 + 5 6 2 0 0 0 0 + 6 17 1 0 0 0 0 + 6 18 1 0 0 0 0 + 7 19 1 0 0 0 0 + 7 20 1 0 0 0 0 + 9 11 1 0 0 0 0 + 9 10 1 0 0 0 0 + 10 21 1 0 0 0 0 + 10 22 1 0 0 0 0 + 11 12 2 0 0 0 0 + 12 14 1 0 0 0 0 + 12 13 1 0 0 0 0 + 13 23 1 0 0 0 0 + 13 24 1 0 0 0 0 + 14 1 2 0 0 0 0 + 14 15 1 0 0 0 0 +M CHG 1 5 1 +M END +> +C6H9N7OCl + +> +230.6 + +> +8 + +> +0 + +> +-1.11 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/1m1b_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/1m1b_ligand_obabel.sdf new file mode 100644 index 000000000..3df7b55c6 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/1m1b_ligand_obabel.sdf @@ -0,0 +1,45 @@ +1m1b_ligand + OpenBabel05112116043D +Created by X-TOOL on Fri Nov 18 12:58:40 2016 + 12 11 0 0 0 0 0 0 0 0999 V2000 + 30.3110 69.4470 73.1140 C 0 5 0 0 0 0 0 0 0 0 0 0 + 30.8240 68.4790 72.4320 O 0 0 0 0 0 0 0 0 0 0 0 0 + 30.9770 70.3480 73.5750 O 0 0 0 0 0 0 0 0 0 0 0 0 + 28.7920 69.3220 73.2920 C 0 0 0 0 0 0 0 0 0 0 0 0 + 28.0660 68.2870 73.7790 C 0 0 0 0 0 0 0 0 0 0 0 0 + 28.1120 70.3400 72.9260 O 0 0 0 0 0 0 0 0 0 0 0 0 + 28.4660 67.9240 75.5260 S 0 0 0 0 0 0 0 0 0 0 0 0 + 28.2630 69.1270 76.2210 O 0 0 0 0 0 0 0 0 0 0 0 0 + 29.8230 67.4780 75.5040 O 0 0 0 0 0 0 0 0 0 0 0 0 + 27.5120 67.0010 75.9560 O 0 0 0 0 0 0 0 0 0 0 0 0 + 28.2752 67.3921 73.1745 H 0 0 0 0 0 0 0 0 0 0 0 0 + 26.9976 68.5380 73.7051 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 4 1 0 0 0 0 + 1 3 2 0 0 0 0 + 1 2 2 0 0 0 0 + 4 6 2 0 0 0 0 + 4 5 1 0 0 0 0 + 5 7 1 0 0 0 0 + 5 11 1 0 0 0 0 + 5 12 1 0 0 0 0 + 7 10 2 0 0 0 0 + 7 9 2 0 0 0 0 + 7 8 2 0 0 0 0 +M CHG 1 1 -1 +M END +> +C3H2O6S + +> +166.1 + +> +6 + +> +1 + +> +-1.66 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/1mue_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/1mue_ligand_obabel.sdf new file mode 100644 index 000000000..883df756e --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/1mue_ligand_obabel.sdf @@ -0,0 +1,121 @@ +1mue_ligand + OpenBabel05112116053D +Created by X-TOOL on Fri Nov 18 13:41:51 2016 + 49 51 0 0 0 0 0 0 0 0999 V2000 + 22.0800 -15.7580 25.0900 C 0 0 0 0 0 0 0 0 0 0 0 0 + 20.9530 -16.4530 25.2050 N 0 0 0 0 0 0 0 0 0 0 0 0 + 19.8510 -15.8890 25.7250 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.8360 -14.5630 26.1210 C 0 0 0 0 0 0 0 0 0 0 0 0 + 20.9710 -13.8180 25.9770 C 0 0 0 0 0 0 0 0 0 0 0 0 + 22.1230 -14.4260 25.4800 C 0 0 0 0 0 0 0 0 0 0 0 0 + 18.6030 -16.7060 25.9480 C 0 0 0 0 0 0 0 0 0 0 0 0 + 17.9180 -17.0720 24.6620 C 0 0 0 0 0 0 0 0 0 0 0 0 + 18.9660 -17.8240 26.5990 F 0 0 0 0 0 0 0 0 0 0 0 0 + 17.7360 -16.0050 26.7280 F 0 0 0 0 0 0 0 0 0 0 0 0 + 17.1580 -15.9350 24.1360 N 0 0 0 0 0 0 0 0 0 0 0 0 + 17.9180 -15.2540 23.1780 C 0 0 0 0 0 0 0 0 0 0 0 0 + 17.2740 -14.0320 22.4940 C 0 0 0 0 0 0 0 0 0 0 0 0 + 18.0090 -13.4450 21.5160 N 0 0 0 0 0 0 0 0 0 0 0 0 + 19.3550 -13.9470 21.1720 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.9300 -15.0380 21.9380 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.1980 -15.6190 22.9100 N 0 0 0 0 0 0 0 0 0 0 0 0 + 17.5460 -12.2610 20.7780 C 0 0 0 0 0 0 0 0 0 0 0 0 + 16.0670 -12.3310 20.4100 C 0 0 0 0 0 0 0 0 0 0 0 0 + 15.2870 -11.4840 21.1270 N 0 0 0 0 0 0 0 0 0 0 0 0 + 13.8690 -11.4110 20.7680 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.9150 -11.4250 21.9620 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.9000 -10.3750 22.8950 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.0190 -10.4350 24.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.1120 -11.4930 24.1370 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.1250 -12.5320 23.2100 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.0370 -12.4940 22.1420 C 0 0 0 0 0 0 0 0 0 0 0 0 + 16.1420 -13.6640 22.8260 O 0 0 0 0 0 0 0 0 0 0 0 0 + 20.2420 -13.2370 19.8930 Cl 0 0 0 0 0 0 0 0 0 0 0 0 + 15.6570 -13.1090 19.5420 O 0 0 0 0 0 0 0 0 0 0 0 0 + 12.1890 -13.5200 21.2880 F 0 0 0 0 0 0 0 0 0 0 0 0 + 20.9520 -17.7700 24.8070 O 0 0 0 0 0 0 0 0 0 0 0 0 + 22.9688 -16.2327 24.6903 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.9377 -14.1230 26.5387 H 0 0 0 0 0 0 0 0 0 0 0 0 + 20.9764 -12.7678 26.2455 H 0 0 0 0 0 0 0 0 0 0 0 0 + 23.0457 -13.8629 25.3986 H 0 0 0 0 0 0 0 0 0 0 0 0 + 17.2309 -17.9112 24.8454 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.6751 -17.3727 23.9229 H 0 0 0 0 0 0 0 0 0 0 0 0 + 16.2051 -15.6752 24.4281 H 0 0 0 0 0 0 0 0 0 0 0 0 + 20.9416 -15.3834 21.7298 H 0 0 0 0 0 0 0 0 0 0 0 0 + 18.1340 -12.1722 19.8526 H 0 0 0 0 0 0 0 0 0 0 0 0 + 17.7102 -11.3712 21.4036 H 0 0 0 0 0 0 0 0 0 0 0 0 + 15.6647 -10.9320 21.8704 H 0 0 0 0 0 0 0 0 0 0 0 0 + 13.6313 -12.2730 20.1274 H 0 0 0 0 0 0 0 0 0 0 0 0 + 13.7036 -10.4799 20.2062 H 0 0 0 0 0 0 0 0 0 0 0 0 + 13.5595 -9.5240 22.7689 H 0 0 0 0 0 0 0 0 0 0 0 0 + 12.0463 -9.6526 24.7498 H 0 0 0 0 0 0 0 0 0 0 0 0 + 10.4050 -11.5031 24.9586 H 0 0 0 0 0 0 0 0 0 0 0 0 + 10.4370 -13.3635 23.3116 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 0 0 0 + 1 6 1 0 0 0 0 + 1 33 1 0 0 0 0 + 2 3 1 0 0 0 0 + 2 32 2 0 0 0 0 + 3 4 2 0 0 0 0 + 3 7 1 0 0 0 0 + 4 5 1 0 0 0 0 + 4 34 1 0 0 0 0 + 5 6 2 0 0 0 0 + 5 35 1 0 0 0 0 + 6 36 1 0 0 0 0 + 7 8 1 0 0 0 0 + 7 9 1 0 0 0 0 + 7 10 1 0 0 0 0 + 8 11 1 0 0 0 0 + 8 37 1 0 0 0 0 + 8 38 1 0 0 0 0 + 11 12 1 0 0 0 0 + 11 39 1 0 0 0 0 + 12 13 1 0 0 0 0 + 12 17 2 0 0 0 0 + 13 14 1 0 0 0 0 + 13 28 2 0 0 0 0 + 14 15 1 0 0 0 0 + 14 18 1 0 0 0 0 + 15 16 2 0 0 0 0 + 15 29 1 0 0 0 0 + 16 17 1 0 0 0 0 + 16 40 1 0 0 0 0 + 18 19 1 0 0 0 0 + 18 41 1 0 0 0 0 + 18 42 1 0 0 0 0 + 19 20 1 0 0 0 0 + 19 30 2 0 0 0 0 + 20 21 1 0 0 0 0 + 20 43 1 0 0 0 0 + 21 22 1 0 0 0 0 + 21 44 1 0 0 0 0 + 21 45 1 0 0 0 0 + 22 23 2 0 0 0 0 + 22 27 1 0 0 0 0 + 23 24 1 0 0 0 0 + 23 46 1 0 0 0 0 + 24 25 2 0 0 0 0 + 24 47 1 0 0 0 0 + 25 26 1 0 0 0 0 + 25 48 1 0 0 0 0 + 26 27 2 0 0 0 0 + 26 49 1 0 0 0 0 + 27 31 1 0 0 0 0 +M END +> +C20H17N5O3F3Cl + +> +467.7 + +> +6 + +> +7 + +> +2.89 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/1w4q_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/1w4q_ligand_obabel.sdf new file mode 100644 index 000000000..8e2aacc2a --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/1w4q_ligand_obabel.sdf @@ -0,0 +1,84 @@ +1w4q_ligand + OpenBabel05112116053D +Created by X-TOOL on Fri Nov 18 14:04:08 2016 + 31 32 0 0 0 0 0 0 0 0999 V2000 + 36.2250 -2.3660 12.1580 N 0 0 0 0 0 0 0 0 0 0 0 0 + 35.0290 -2.5550 11.4210 C 0 0 0 0 0 0 0 0 0 0 0 0 + 34.7000 -1.7980 10.5870 O 0 0 0 0 0 0 0 0 0 0 0 0 + 34.3270 -3.7120 11.7940 N 0 0 0 0 0 0 0 0 0 0 0 0 + 34.6750 -4.6670 12.7960 C 0 0 0 0 0 0 0 0 0 0 0 0 + 33.9250 -5.6050 12.9580 O 0 0 0 0 0 0 0 0 0 0 0 0 + 35.9240 -4.3900 13.5180 C 0 0 0 0 0 0 0 0 0 0 0 0 + 36.6450 -3.2830 13.1940 C 0 0 0 0 0 0 0 0 0 0 0 0 + 39.2530 -0.4990 15.5460 O 0 0 0 0 0 0 0 0 0 0 0 0 + 40.0020 -0.1650 14.2100 C 0 0 0 0 0 0 0 0 0 0 0 0 + 38.7750 0.1200 13.3080 C 0 0 1 0 0 0 0 0 0 0 0 0 + 38.4020 -1.1420 12.9600 O 0 0 0 0 0 0 0 0 0 0 0 0 + 37.6410 1.0610 13.2010 C 0 0 1 0 0 0 0 0 0 0 0 0 + 37.5420 2.5320 12.9110 O 0 0 0 0 0 0 0 0 0 0 0 0 + 36.5030 0.3120 12.3010 C 0 0 1 0 0 0 0 0 0 0 0 0 + 36.2460 1.3130 11.5430 F 0 0 0 0 0 0 0 0 0 0 0 0 + 37.1740 -1.1150 11.8700 C 0 0 2 0 0 0 0 0 0 0 0 0 + 35.4680 3.1250 13.5200 O 0 0 0 0 0 0 0 0 0 0 0 0 + 37.0160 3.5030 13.6300 P 0 0 0 0 0 0 0 0 0 0 0 0 + 37.3410 3.6810 15.0910 O 0 0 0 0 0 0 0 0 0 0 0 0 + 37.4710 4.6660 12.8340 O 0 0 0 0 0 0 0 0 0 0 0 0 + 33.4780 -3.8890 11.2961 H 0 0 0 0 0 0 0 0 0 0 0 0 + 36.2682 -5.0623 14.3025 H 0 0 0 0 0 0 0 0 0 0 0 0 + 37.5694 -3.0806 13.7329 H 0 0 0 0 0 0 0 0 0 0 0 0 + 38.6832 -1.2469 15.4099 H 0 0 0 0 0 0 0 0 0 0 0 0 + 40.5932 -1.0175 13.8445 H 0 0 0 0 0 0 0 0 0 0 0 0 + 40.6528 0.7160 14.3113 H 0 0 0 0 0 0 0 0 0 0 0 0 + 39.3186 0.4879 12.4253 H 0 0 0 0 0 0 0 0 0 0 0 0 + 37.2659 1.0391 14.2348 H 0 0 0 0 0 0 0 0 0 0 0 0 + 35.5930 0.0715 12.8703 H 0 0 0 0 0 0 0 0 0 0 0 0 + 37.5145 -1.1206 10.8241 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 1 0 0 0 0 + 1 8 1 0 0 0 0 + 2 3 2 0 0 0 0 + 2 4 1 0 0 0 0 + 4 5 1 0 0 0 0 + 4 22 1 0 0 0 0 + 5 6 2 0 0 0 0 + 7 5 1 0 0 0 0 + 7 23 1 0 0 0 0 + 8 7 2 0 0 0 0 + 8 24 1 0 0 0 0 + 9 25 1 0 0 0 0 + 10 9 1 0 0 0 0 + 10 26 1 0 0 0 0 + 10 27 1 0 0 0 0 + 11 10 1 0 0 0 0 + 11 13 1 0 0 0 0 + 11 28 1 6 0 0 0 + 12 11 1 0 0 0 0 + 12 17 1 0 0 0 0 + 13 14 1 0 0 0 0 + 13 15 1 0 0 0 0 + 13 29 1 1 0 0 0 + 14 19 1 0 0 0 0 + 15 16 1 0 0 0 0 + 15 17 1 0 0 0 0 + 15 30 1 1 0 0 0 + 17 1 1 0 0 0 0 + 17 31 1 6 0 0 0 + 19 18 2 0 0 0 0 + 19 20 2 0 0 0 0 + 19 21 2 0 0 0 0 +M END +> +C9H10N2O8PF + +> +324.1 + +> +9 + +> +3 + +> +-2.27 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/2e94_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/2e94_ligand_obabel.sdf new file mode 100644 index 000000000..8bbcbf9ef --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/2e94_ligand_obabel.sdf @@ -0,0 +1,113 @@ +2e94_ligand + OpenBabel05112116063D +Created by X-TOOL on Fri Nov 18 14:45:46 2016 + 45 47 0 0 0 0 0 0 0 0999 V2000 + 35.3180 53.0670 10.5620 C 0 0 0 0 0 0 0 0 0 0 0 0 + 36.1370 53.5310 11.5840 C 0 0 0 0 0 0 0 0 0 0 0 0 + 36.4880 52.6820 12.6290 C 0 0 0 0 0 0 0 0 0 0 0 0 + 36.0170 51.3740 12.6480 C 0 0 0 0 0 0 0 0 0 0 0 0 + 35.1970 50.9120 11.6240 C 0 0 0 0 0 0 0 0 0 0 0 0 + 34.8460 51.7570 10.5760 C 0 0 0 0 0 0 0 0 0 0 0 0 + 34.0920 51.2750 9.5140 C 0 0 0 0 0 0 0 0 0 0 0 0 + 33.0200 50.4150 9.7350 C 0 0 0 0 0 0 0 0 0 0 0 0 + 34.4090 51.6590 8.2140 C 0 0 0 0 0 0 0 0 0 0 0 0 + 33.6640 51.1810 7.1430 C 0 0 0 0 0 0 0 0 0 0 0 0 + 32.5970 50.3180 7.3690 C 0 0 0 0 0 0 0 0 0 0 0 0 + 32.2710 49.9350 8.6650 C 0 0 0 0 0 0 0 0 0 0 0 0 + 31.1760 49.1050 8.8820 C 0 0 0 0 0 0 0 0 0 0 0 0 + 30.9280 48.0420 8.0190 C 0 0 0 0 0 3 0 0 0 0 0 0 + 30.3640 49.2900 9.9960 C 0 0 0 0 0 0 0 0 0 0 0 0 + 29.3100 48.4230 10.2570 C 0 0 0 0 0 0 0 0 0 0 0 0 + 29.0600 47.3550 9.4030 C 0 0 0 0 0 0 0 0 0 0 0 0 + 29.8730 47.1580 8.2800 N 0 0 0 0 0 0 0 0 0 0 0 0 + 29.6790 45.9550 7.4370 C 0 0 0 0 0 0 0 0 0 0 0 0 + 29.2480 46.2370 5.9940 C 0 0 0 0 0 0 0 0 0 0 0 0 + 29.2590 44.5910 5.1110 P 0 0 0 0 0 0 0 0 0 0 0 0 + 29.0390 44.8840 3.5440 O 0 0 0 0 0 0 0 0 0 0 0 0 + 30.7590 44.0240 5.2380 O 0 0 0 0 0 0 0 0 0 0 0 0 + 28.2570 43.6440 5.6500 O 0 0 0 0 0 0 0 0 0 0 0 0 + 27.5660 47.0450 5.9070 P 0 0 0 0 0 0 0 0 0 0 0 0 + 26.4770 46.0170 6.5000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 27.6150 48.2790 6.9420 O 0 0 0 0 0 0 0 0 0 0 0 0 + 27.2420 47.5040 4.5380 O 0 0 0 0 0 0 0 0 0 0 0 0 + 30.1860 47.1170 5.3640 O 0 0 0 0 0 0 0 0 0 0 0 0 + 35.0447 53.7291 9.7484 H 0 0 0 0 0 0 0 0 0 0 0 0 + 36.5015 54.5517 11.5673 H 0 0 0 0 0 0 0 0 0 0 0 0 + 37.1279 53.0400 13.4274 H 0 0 0 0 0 0 0 0 0 0 0 0 + 36.2895 50.7128 13.4627 H 0 0 0 0 0 0 0 0 0 0 0 0 + 34.8308 49.8919 11.6425 H 0 0 0 0 0 0 0 0 0 0 0 0 + 32.7673 50.1175 10.7463 H 0 0 0 0 0 0 0 0 0 0 0 0 + 35.2394 52.3328 8.0368 H 0 0 0 0 0 0 0 0 0 0 0 0 + 33.9143 51.4806 6.1317 H 0 0 0 0 0 0 0 0 0 0 0 0 + 32.0182 49.9431 6.5326 H 0 0 0 0 0 0 0 0 0 0 0 0 + 31.5516 47.8978 7.1441 H 0 0 0 0 0 0 0 0 0 0 0 0 + 30.5554 50.1191 10.6675 H 0 0 0 0 0 0 0 0 0 0 0 0 + 28.6824 48.5795 11.1269 H 0 0 0 0 0 0 0 0 0 0 0 0 + 28.2387 46.6772 9.6056 H 0 0 0 0 0 0 0 0 0 0 0 0 + 28.9061 45.3297 7.9077 H 0 0 0 0 0 0 0 0 0 0 0 0 + 30.6297 45.4025 7.4071 H 0 0 0 0 0 0 0 0 0 0 0 0 + 30.1822 47.9550 5.8115 H 0 0 0 0 0 0 0 0 0 0 0 0 + 1 2 2 0 0 0 0 + 1 6 1 0 0 0 0 + 1 30 1 0 0 0 0 + 2 3 1 0 0 0 0 + 2 31 1 0 0 0 0 + 3 4 2 0 0 0 0 + 3 32 1 0 0 0 0 + 4 5 1 0 0 0 0 + 4 33 1 0 0 0 0 + 5 6 2 0 0 0 0 + 5 34 1 0 0 0 0 + 6 7 1 0 0 0 0 + 7 8 2 0 0 0 0 + 7 9 1 0 0 0 0 + 8 12 1 0 0 0 0 + 8 35 1 0 0 0 0 + 9 10 2 0 0 0 0 + 9 36 1 0 0 0 0 + 10 11 1 0 0 0 0 + 10 37 1 0 0 0 0 + 11 12 2 0 0 0 0 + 11 38 1 0 0 0 0 + 12 13 1 0 0 0 0 + 13 14 1 0 0 0 0 + 13 15 2 0 0 0 0 + 14 18 1 0 0 0 0 + 14 39 1 0 0 0 0 + 15 16 1 0 0 0 0 + 15 40 1 0 0 0 0 + 16 17 2 0 0 0 0 + 16 41 1 0 0 0 0 + 17 18 1 0 0 0 0 + 17 42 1 0 0 0 0 + 18 19 1 0 0 0 0 + 19 20 1 0 0 0 0 + 19 43 1 0 0 0 0 + 19 44 1 0 0 0 0 + 20 21 1 0 0 0 0 + 20 25 1 0 0 0 0 + 20 29 1 0 0 0 0 + 21 22 2 0 0 0 0 + 21 23 2 0 0 0 0 + 21 24 2 0 0 0 0 + 25 26 2 0 0 0 0 + 25 27 2 0 0 0 0 + 25 28 2 0 0 0 0 + 29 45 1 0 0 0 0 +M END +> +C19H16NO7P2 + +> +432.1 + +> +8 + +> +2 + +> +1.94 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/4xaq_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/4xaq_ligand_obabel.sdf new file mode 100644 index 000000000..758b75773 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/4xaq_ligand_obabel.sdf @@ -0,0 +1,69 @@ +4xaq_ligand + OpenBabel05112116113D +Created by X-TOOL on Fri Nov 18 18:00:48 2016 + 23 24 0 0 0 0 0 0 0 0999 V2000 + -5.5750 35.7600 26.9370 O 0 0 0 0 0 0 0 0 0 0 0 0 + -8.1450 37.0440 27.8960 C 0 0 0 0 0 0 0 0 0 0 0 0 + -9.2460 32.3630 29.3640 O 0 0 0 0 0 0 0 0 0 0 0 0 + -7.7210 36.5030 29.3140 C 0 0 0 0 0 0 0 0 0 0 0 0 + -8.0470 35.8370 26.9130 C 0 0 1 0 0 0 0 0 0 0 0 0 + -7.9940 35.0120 29.2480 C 0 0 1 0 0 0 0 0 0 0 0 0 + -10.0660 33.3980 29.0580 C 0 5 0 0 0 0 0 0 0 0 0 0 + -9.3880 34.6630 28.7190 C 0 0 2 0 0 0 0 0 0 0 0 0 + -8.2120 34.6260 27.7880 C 0 0 1 0 0 0 0 0 0 0 0 0 + -11.2780 33.2560 29.0670 O 0 0 0 0 0 0 0 0 0 0 0 0 + -9.0700 35.8490 25.8450 N 0 3 0 0 0 0 0 0 0 0 0 0 + -6.6190 35.7900 26.3010 C 0 5 0 0 0 0 0 0 0 0 0 0 + -6.5010 35.8060 24.9570 O 0 0 0 0 0 0 0 0 0 0 0 0 + -7.4661 37.8489 27.5780 H 0 0 0 0 0 0 0 0 0 0 0 0 + -9.1763 37.4252 27.9277 H 0 0 0 0 0 0 0 0 0 0 0 0 + -8.3223 36.9738 30.1057 H 0 0 0 0 0 0 0 0 0 0 0 0 + -6.6541 36.6951 29.5006 H 0 0 0 0 0 0 0 0 0 0 0 0 + -7.4560 34.4093 29.9945 H 0 0 0 0 0 0 0 0 0 0 0 0 + -10.1400 35.4606 28.6279 H 0 0 0 0 0 0 0 0 0 0 0 0 + -7.8481 33.6937 27.3314 H 0 0 0 0 0 0 0 0 0 0 0 0 + -8.9446 36.6665 25.2688 H 0 0 0 0 0 0 0 0 0 0 0 0 + -9.9885 35.8680 26.2597 H 0 0 0 0 0 0 0 0 0 0 0 0 + -8.9741 35.0208 25.2785 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2 14 1 0 0 0 0 + 2 15 1 0 0 0 0 + 4 2 1 0 0 0 0 + 4 16 1 0 0 0 0 + 4 17 1 0 0 0 0 + 5 2 1 0 0 0 0 + 5 11 1 0 0 0 0 + 5 12 1 6 0 0 0 + 6 4 1 0 0 0 0 + 6 9 1 0 0 0 0 + 6 18 1 1 0 0 0 + 7 3 2 0 0 0 0 + 7 8 1 0 0 0 0 + 7 10 2 0 0 0 0 + 8 6 1 0 0 0 0 + 8 9 1 0 0 0 0 + 8 19 1 6 0 0 0 + 9 5 1 0 0 0 0 + 9 20 1 6 0 0 0 + 11 21 1 0 0 0 0 + 11 22 1 0 0 0 0 + 11 23 1 0 0 0 0 + 12 1 2 0 0 0 0 + 12 13 2 0 0 0 0 +M CHG 3 7 -1 11 1 12 -1 +M END +> +C8H10NO4 + +> +184.1 + +> +5 + +> +0 + +> +-3.47 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/obabel/4xtw_ligand_obabel.sdf b/tests/bond_order/refined-set-ligands/obabel/4xtw_ligand_obabel.sdf new file mode 100644 index 000000000..09af162a2 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/obabel/4xtw_ligand_obabel.sdf @@ -0,0 +1,161 @@ +4xtw_ligand + OpenBabel05112116113D +Created by X-TOOL on Fri Nov 18 18:00:31 2016 + 68 72 0 0 0 0 0 0 0 0999 V2000 + -4.7030 1.6350 5.9630 N 0 0 0 0 0 0 0 0 0 0 0 0 + -5.6630 -0.3240 11.3830 C 0 0 0 0 0 0 0 0 0 0 0 0 + -6.3580 -0.7620 13.6240 C 0 0 0 0 0 0 0 0 0 0 0 0 + -2.1170 -10.0370 13.8260 C 0 0 1 0 0 0 0 0 0 0 0 0 + -0.9500 -9.2030 13.5700 N 0 0 0 0 0 0 0 0 0 0 0 0 + -0.0190 -9.3280 14.5020 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.0640 -8.7620 14.4970 O 0 0 0 0 0 0 0 0 0 0 0 0 + -0.4310 -10.1590 15.4430 N 0 0 0 0 0 0 0 0 0 0 0 0 + -1.7740 -10.6600 15.1950 C 0 0 1 0 0 0 0 0 0 0 0 0 + -2.6150 -10.0570 16.3170 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.3090 -8.6030 15.6260 S 0 0 0 0 0 0 0 0 0 0 0 0 + -3.3050 -9.0820 13.9370 C 0 0 1 0 0 0 0 0 0 0 0 0 + -3.2130 -7.8700 13.0160 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.5220 -8.2720 11.5780 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.6630 -7.0670 10.6530 C 0 0 0 0 0 0 0 0 0 0 0 0 + -4.0230 -7.5380 9.2480 C 0 0 0 0 0 0 0 0 0 0 0 0 + -4.4420 -6.3980 8.3460 C 0 0 0 0 0 0 0 0 0 0 0 0 + -5.5370 -5.8720 8.4720 O 0 0 0 0 0 0 0 0 0 0 0 0 + -3.5630 -6.0160 7.4210 N 0 0 0 0 0 0 0 0 0 0 0 0 + -3.8940 -4.8900 6.4520 S 0 0 0 0 0 0 0 0 0 0 0 0 + -5.0320 -5.2610 5.6570 O 0 0 0 0 0 0 0 0 0 0 0 0 + -2.7710 -4.6720 5.5860 O 0 0 0 0 0 0 0 0 0 0 0 0 + -4.2490 -3.5330 7.2450 N 0 0 0 0 0 0 0 0 0 0 0 0 + -3.0360 -2.7820 7.6110 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.4150 -1.3070 7.6960 C 0 0 1 0 0 0 0 0 0 0 0 0 + -4.5300 -1.1180 8.5710 O 0 0 0 0 0 0 0 0 0 0 0 0 + -2.3120 -0.4110 8.2320 C 0 0 1 0 0 0 0 0 0 0 0 0 + -1.5100 0.0980 7.1630 O 0 0 0 0 0 0 0 0 0 0 0 0 + -3.0660 0.7150 8.9090 C 0 0 2 0 0 0 0 0 0 0 0 0 + -4.4280 0.1340 9.2560 C 0 0 2 0 0 0 0 0 0 0 0 0 + -4.5270 -0.1090 10.7160 N 0 0 0 0 0 0 0 0 0 0 0 0 + -3.5070 -0.1720 11.5850 C 0 0 0 0 0 0 0 0 0 0 0 0 + -3.9970 -0.4210 12.8210 N 0 0 0 0 0 0 0 0 0 0 0 0 + -5.3390 -0.5200 12.7140 C 0 0 0 0 0 0 0 0 0 0 0 0 + -6.9580 -0.3730 10.9940 N 0 0 0 0 0 0 0 0 0 0 0 0 + -7.9210 -0.6080 11.8920 C 0 0 0 0 0 0 0 0 0 0 0 0 + -7.6350 -0.7990 13.1870 N 0 0 0 0 0 0 0 0 0 0 0 0 + -6.0820 -0.9590 14.9360 N 0 0 0 0 0 0 0 0 0 0 0 0 + -4.0200 1.7320 6.8940 N 0 0 0 0 0 0 0 0 0 0 0 0 + -3.2220 1.8460 8.0110 N 0 0 0 0 0 0 0 0 0 0 0 0 + -2.2852 -10.7999 13.0516 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8622 -8.6014 12.7761 H 0 0 0 0 0 0 0 0 0 0 0 0 + 0.1194 -10.4152 16.2376 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.8407 -11.7579 15.1794 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.9846 -9.8109 17.1842 H 0 0 0 0 0 0 0 0 0 0 0 0 + -3.4069 -10.7553 16.6256 H 0 0 0 0 0 0 0 0 0 0 0 0 + -4.2328 -9.6221 13.6972 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.1962 -7.4532 13.0655 H 0 0 0 0 0 0 0 0 0 0 0 0 + -3.9373 -7.1097 13.3436 H 0 0 0 0 0 0 0 0 0 0 0 0 + -4.4644 -8.8392 11.5648 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.7056 -8.9086 11.2063 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.7111 -6.5166 10.6216 H 0 0 0 0 0 0 0 0 0 0 0 0 + -4.4565 -6.4060 11.0317 H 0 0 0 0 0 0 0 0 0 0 0 0 + -4.8533 -8.2560 9.3183 H 0 0 0 0 0 0 0 0 0 0 0 0 + -3.1460 -8.0336 8.8062 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.6760 -6.4740 7.3626 H 0 0 0 0 0 0 0 0 0 0 0 0 + -5.1792 -3.2369 7.4621 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.2600 -2.9263 6.8449 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.6593 -3.1291 8.5844 H 0 0 0 0 0 0 0 0 0 0 0 0 + -3.6831 -0.9704 6.6837 H 0 0 0 0 0 0 0 0 0 0 0 0 + -1.6764 -0.9510 8.9492 H 0 0 0 0 0 0 0 0 0 0 0 0 + -0.8273 0.6549 7.5182 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.5391 1.0381 9.8190 H 0 0 0 0 0 0 0 0 0 0 0 0 + -5.2279 0.8174 8.9350 H 0 0 0 0 0 0 0 0 0 0 0 0 + -2.4547 -0.0435 11.3357 H 0 0 0 0 0 0 0 0 0 0 0 0 + -8.9540 -0.6447 11.5654 H 0 0 0 0 0 0 0 0 0 0 0 0 + -6.8471 -1.1378 15.6020 H 0 0 0 0 0 0 0 0 0 0 0 0 + -5.1071 -0.9299 15.2672 H 0 0 0 0 0 0 0 0 0 0 0 0 + 2 34 2 0 0 0 0 + 2 35 1 0 0 0 0 + 3 37 2 0 0 0 0 + 3 38 1 0 0 0 0 + 4 5 1 0 0 0 0 + 4 9 1 0 0 0 0 + 4 41 1 6 0 0 0 + 5 6 1 0 0 0 0 + 5 42 1 0 0 0 0 + 6 7 2 0 0 0 0 + 8 6 1 0 0 0 0 + 8 43 1 0 0 0 0 + 9 8 1 0 0 0 0 + 9 44 1 6 0 0 0 + 10 9 1 0 0 0 0 + 10 45 1 0 0 0 0 + 10 46 1 0 0 0 0 + 11 10 1 0 0 0 0 + 12 4 1 0 0 0 0 + 12 11 1 0 0 0 0 + 12 47 1 6 0 0 0 + 13 12 1 0 0 0 0 + 13 48 1 0 0 0 0 + 13 49 1 0 0 0 0 + 14 13 1 0 0 0 0 + 14 50 1 0 0 0 0 + 14 51 1 0 0 0 0 + 15 14 1 0 0 0 0 + 15 52 1 0 0 0 0 + 15 53 1 0 0 0 0 + 16 15 1 0 0 0 0 + 16 54 1 0 0 0 0 + 16 55 1 0 0 0 0 + 17 16 1 0 0 0 0 + 17 18 2 0 0 0 0 + 19 17 1 0 0 0 0 + 19 56 1 0 0 0 0 + 20 19 1 0 0 0 0 + 20 21 2 0 0 0 0 + 20 22 2 0 0 0 0 + 23 20 1 0 0 0 0 + 23 57 1 0 0 0 0 + 24 23 1 0 0 0 0 + 24 58 1 0 0 0 0 + 24 59 1 0 0 0 0 + 25 24 1 0 0 0 0 + 25 60 1 6 0 0 0 + 26 25 1 0 0 0 0 + 27 25 1 0 0 0 0 + 27 28 1 0 0 0 0 + 27 61 1 1 0 0 0 + 28 62 1 0 0 0 0 + 29 27 1 0 0 0 0 + 29 30 1 0 0 0 0 + 29 63 1 1 0 0 0 + 30 26 1 0 0 0 0 + 30 31 1 0 0 0 0 + 30 64 1 6 0 0 0 + 31 2 1 0 0 0 0 + 31 32 1 0 0 0 0 + 32 33 2 0 0 0 0 + 32 65 1 0 0 0 0 + 33 34 1 0 0 0 0 + 34 3 1 0 0 0 0 + 35 36 2 0 0 0 0 + 36 37 1 0 0 0 0 + 36 66 1 0 0 0 0 + 38 67 1 0 0 0 0 + 38 68 1 0 0 0 0 + 39 1 3 0 0 0 0 + 39 40 2 0 0 0 0 + 40 29 1 0 0 0 0 +M END +> +C20H28N12O6S2 + +> +596.5 + +> +17 + +> +9 + +> +-2.69 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/1a4r_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/1a4r_ligand.sdf new file mode 100644 index 000000000..72429c370 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/1a4r_ligand.sdf @@ -0,0 +1,107 @@ +1a4r_ligand + +Created by X-TOOL on Fri Nov 18 12:31:18 2016 + 42 44 0 0 0 0 0 0 0 0999 V2000 + 102.4860 24.8700 -2.9090 N 0 0 0 3 0 3 + 101.5220 25.8860 -2.4280 P 0 0 0 1 0 4 + 100.9830 25.4700 -1.0790 O 0 0 0 1 0 1 + 100.3500 26.2500 -3.2730 O 0 0 0 1 0 1 + 102.4090 27.1490 -2.1360 O 0 0 0 1 0 2 + 102.9800 27.8190 -0.7750 P 0 0 0 1 0 4 + 103.9320 26.8730 -0.1570 O 0 0 0 1 0 1 + 101.8500 28.3180 0.0570 O 0 0 0 1 0 1 + 103.7180 29.0170 -1.4980 O 0 0 0 1 0 2 + 104.8640 28.8490 -2.3670 C 0 0 0 3 0 4 + 105.9930 29.8990 -2.1000 C 0 0 0 2 0 4 + 105.4820 31.1830 -2.4390 O 0 0 0 1 0 2 + 106.4630 30.0620 -0.6570 C 0 0 0 2 0 4 + 107.8730 30.1930 -0.5940 O 0 0 0 2 0 2 + 105.7350 31.2660 -0.0960 C 0 0 0 2 0 4 + 106.2980 31.8890 1.0590 O 0 0 0 2 0 2 + 105.5820 32.1390 -1.3490 C 0 0 0 2 0 4 + 104.3150 32.9430 -1.5100 N 0 0 0 1 0 3 + 103.0000 32.5360 -1.3540 C 0 0 0 2 0 3 + 102.0730 33.4460 -1.5560 N 0 0 0 1 0 2 + 102.8070 34.5960 -1.8890 C 0 0 0 1 0 3 + 102.3660 35.9710 -2.2360 C 0 0 0 1 0 3 + 101.2060 36.3850 -2.3060 O 0 0 0 1 0 1 + 103.4480 36.8880 -2.5220 N 0 0 0 2 0 3 + 104.8390 36.5560 -2.4810 C 0 0 0 1 0 3 + 105.7330 37.5170 -2.7670 N 0 0 0 3 0 3 + 105.2800 35.2710 -2.1570 N 0 0 0 1 0 2 + 104.2050 34.3230 -1.8660 C 0 0 0 1 0 3 + 102.1650 23.9586 -3.1665 H 0 0 0 1 0 1 + 103.4580 25.0953 -2.9763 H 0 0 0 1 0 1 + 104.5306 28.9505 -3.4103 H 0 0 0 1 0 1 + 105.2779 27.8419 -2.2106 H 0 0 0 1 0 1 + 106.8572 29.6421 -2.7302 H 0 0 0 1 0 1 + 106.1769 29.1711 -0.0788 H 0 0 0 1 0 1 + 108.1405 30.2929 0.3121 H 0 0 0 1 0 1 + 104.7318 30.9403 0.2163 H 0 0 0 1 0 1 + 107.1751 32.1932 0.8575 H 0 0 0 1 0 1 + 106.4561 32.8002 -1.4424 H 0 0 0 1 0 1 + 102.7469 31.5134 -1.0779 H 0 0 0 1 0 1 + 103.2047 37.8264 -2.7673 H 0 0 0 1 0 1 + 106.7409 37.3058 -2.7451 H 0 0 0 1 0 1 + 105.4106 38.4650 -3.0082 H 0 0 0 1 0 1 + 2 1 1 0 0 2 + 2 3 2 0 0 2 + 2 4 2 0 0 2 + 2 5 1 0 0 2 + 5 6 1 0 0 2 + 6 7 2 0 0 2 + 6 8 2 0 0 2 + 6 9 1 0 0 2 + 9 10 1 0 0 2 + 10 11 1 0 0 2 + 11 12 1 0 0 1 + 11 13 1 0 0 1 + 12 17 1 0 0 1 + 13 14 1 0 0 2 + 13 15 1 0 0 1 + 15 16 1 0 0 2 + 17 15 1 0 0 1 + 17 18 1 0 0 2 + 18 19 1 0 0 1 + 18 28 1 0 0 1 + 19 20 2 0 0 1 + 20 21 1 0 0 1 + 21 22 1 0 0 1 + 21 28 2 0 0 1 + 22 23 2 0 0 2 + 22 24 1 0 0 1 + 24 25 1 0 0 1 + 25 26 1 0 0 2 + 25 27 2 0 0 1 + 27 28 1 0 0 1 + 1 29 1 0 0 2 + 1 30 1 0 0 2 + 10 31 1 0 0 2 + 10 32 1 0 0 2 + 11 33 1 0 0 2 + 13 34 1 0 0 2 + 14 35 1 0 0 2 + 15 36 1 0 0 2 + 16 37 1 0 0 2 + 17 38 1 0 0 2 + 19 39 1 0 0 2 + 24 40 1 0 0 2 + 26 41 1 0 0 2 + 26 42 1 0 0 2 +M END +> +C10H14N6O10P2 + +> +440.1 + +> +16 + +> +6 + +> +-4.52 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/1ai5_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/1ai5_ligand.sdf new file mode 100644 index 000000000..fed1d2056 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/1ai5_ligand.sdf @@ -0,0 +1,59 @@ +1ai5_ligand + +Created by X-TOOL on Fri Nov 18 12:05:44 2016 + 19 19 0 0 0 0 0 0 0 0999 V2000 + 14.0160 37.7680 36.3700 C 0 5 0 1 0 3 + 13.9490 36.3240 35.8790 C 0 0 0 3 0 4 + 12.6700 35.9080 35.2370 C 0 0 0 1 0 3 + 12.4280 36.4610 34.0030 C 0 0 0 2 0 3 + 11.2590 36.0710 33.4050 C 0 0 0 1 0 3 + 10.9480 36.5440 32.1190 N 0 0 0 1 0 3 + 9.7150 35.9000 31.8610 O 0 0 0 1 0 1 + 11.6460 37.4310 31.3120 O 0 0 0 1 0 1 + 10.3140 35.1870 33.8960 C 0 0 0 2 0 3 + 10.5900 34.6320 35.1090 C 0 0 0 2 0 3 + 11.7540 35.0150 35.7910 C 0 0 0 2 0 3 + 14.5840 37.9400 37.4320 O 0 0 0 1 0 1 + 13.5320 38.7810 35.9290 O 0 0 0 1 0 1 + 14.1200 35.6666 36.7442 H 0 0 0 1 0 1 + 14.7555 36.1810 35.1448 H 0 0 0 1 0 1 + 13.1143 37.1575 33.5351 H 0 0 0 1 0 1 + 9.4089 34.9506 33.3483 H 0 0 0 1 0 1 + 9.9166 33.9016 35.5428 H 0 0 0 1 0 1 + 11.9468 34.6054 36.7760 H 0 0 0 1 0 1 + 1 13 2 0 0 2 + 1 12 2 0 0 2 + 1 2 1 0 0 2 + 2 3 1 0 0 2 + 3 11 4 0 0 1 + 3 4 4 0 0 1 + 4 5 4 0 0 1 + 5 9 4 0 0 1 + 5 6 1 0 0 2 + 6 8 2 0 0 2 + 6 7 2 0 0 2 + 9 10 4 0 0 1 + 10 11 4 0 0 1 + 2 14 1 0 0 2 + 2 15 1 0 0 2 + 4 16 1 0 0 2 + 9 17 1 0 0 2 + 10 18 1 0 0 2 + 11 19 1 0 0 2 +M END +> +C8H6NO4 + +> +180.1 + +> +4 + +> +1 + +> +1.08 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/1f5l_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/1f5l_ligand.sdf new file mode 100644 index 000000000..6b10ee685 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/1f5l_ligand.sdf @@ -0,0 +1,69 @@ +1f5l_ligand + +Created by X-TOOL on Fri Nov 18 12:50:13 2016 + 24 24 0 0 0 0 0 0 0 0999 V2000 + 31.1120 7.6690 27.6830 N 0 0 0 1 0 2 + 30.5020 6.7410 28.4320 C 0 0 0 1 0 3 + 31.2400 5.3550 28.6010 C 0 0 0 1 0 3 + 32.5550 5.2790 28.1310 N 0 0 0 2 0 3 + 33.2510 4.1770 28.0800 C 0 3 0 1 0 3 + 32.7670 3.0180 28.4620 N 0 0 0 3 0 3 + 34.4700 4.2400 27.6300 N 0 0 0 3 0 3 + 30.6520 4.3960 29.1150 O 0 0 0 1 0 1 + 29.2610 7.0260 29.0190 C 0 0 0 1 0 3 + 28.5730 6.0860 29.8140 N 0 0 0 3 0 3 + 28.6930 8.2380 28.8250 N 0 0 0 1 0 2 + 29.3140 9.1790 28.0650 C 0 0 0 1 0 3 + 28.6660 10.4360 27.8950 N 0 0 0 3 0 3 + 30.5610 8.8800 27.4780 C 0 0 0 1 0 3 + 31.4320 10.0160 26.4870 Cl 0 0 0 1 0 1 + 32.9889 6.1224 27.8142 H 0 0 0 1 0 1 + 33.3514 2.1718 28.4049 H 0 0 0 1 0 1 + 31.8028 2.9549 28.8188 H 0 0 0 1 0 1 + 34.8612 5.1435 27.3272 H 0 0 0 1 0 1 + 35.0440 3.3864 27.5765 H 0 0 0 1 0 1 + 27.6628 6.3308 30.2293 H 0 0 0 1 0 1 + 28.9808 5.1547 29.9793 H 0 0 0 1 0 1 + 29.1091 11.1710 27.3254 H 0 0 0 1 0 1 + 27.7543 10.6100 28.3417 H 0 0 0 1 0 1 + 14 1 4 0 0 1 + 1 2 4 0 0 1 + 2 9 4 0 0 1 + 2 3 1 0 0 2 + 3 8 2 0 0 2 + 3 4 1 0 0 2 + 4 5 2 0 0 2 + 5 7 2 0 0 2 + 5 6 2 0 0 2 + 9 11 4 0 0 1 + 9 10 1 0 0 2 + 11 12 4 0 0 1 + 12 14 4 0 0 1 + 12 13 1 0 0 2 + 14 15 1 0 0 2 + 4 16 1 0 0 2 + 6 17 1 0 0 2 + 6 18 1 0 0 2 + 7 19 1 0 0 2 + 7 20 1 0 0 2 + 10 21 1 0 0 2 + 10 22 1 0 0 2 + 13 23 1 0 0 2 + 13 24 1 0 0 2 +M END +> +C6H9N7OCl + +> +230.6 + +> +8 + +> +0 + +> +-1.11 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/1m1b_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/1m1b_ligand.sdf new file mode 100644 index 000000000..d8f376ba3 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/1m1b_ligand.sdf @@ -0,0 +1,44 @@ +1m1b_ligand + +Created by X-TOOL on Fri Nov 18 12:58:40 2016 + 12 11 0 0 0 0 0 0 0 0999 V2000 + 30.3110 69.4470 73.1140 C 0 5 0 1 0 3 + 30.8240 68.4790 72.4320 O 0 0 0 1 0 1 + 30.9770 70.3480 73.5750 O 0 0 0 1 0 1 + 28.7920 69.3220 73.2920 C 0 0 0 1 0 3 + 28.0660 68.2870 73.7790 C 0 0 0 3 0 4 + 28.1120 70.3400 72.9260 O 0 0 0 1 0 1 + 28.4660 67.9240 75.5260 S 0 0 0 1 0 4 + 28.2630 69.1270 76.2210 O 0 0 0 1 0 1 + 29.8230 67.4780 75.5040 O 0 0 0 1 0 1 + 27.5120 67.0010 75.9560 O 0 0 0 1 0 1 + 28.2752 67.3921 73.1745 H 0 0 0 1 0 1 + 26.9976 68.5380 73.7051 H 0 0 0 1 0 1 + 1 4 1 0 0 2 + 1 3 2 0 0 2 + 1 2 2 0 0 2 + 4 6 2 0 0 2 + 4 5 1 0 0 2 + 5 7 1 0 0 2 + 7 10 2 0 0 2 + 7 9 2 0 0 2 + 7 8 2 0 0 2 + 5 11 1 0 0 2 + 5 12 1 0 0 2 +M END +> +C3H2O6S + +> +166.1 + +> +6 + +> +1 + +> +-1.66 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/1mue_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/1mue_ligand.sdf new file mode 100644 index 000000000..6dbfe7a57 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/1mue_ligand.sdf @@ -0,0 +1,121 @@ +1mue_ligand + +Created by X-TOOL on Fri Nov 18 13:41:51 2016 + 49 51 0 0 0 0 0 0 0 0999 V2000 + 22.0800 -15.7580 25.0900 C 0 0 0 2 0 3 + 20.9530 -16.4530 25.2050 N 0 0 0 1 0 3 + 19.8510 -15.8890 25.7250 C 0 0 0 1 0 3 + 19.8360 -14.5630 26.1210 C 0 0 0 2 0 3 + 20.9710 -13.8180 25.9770 C 0 0 0 2 0 3 + 22.1230 -14.4260 25.4800 C 0 0 0 2 0 3 + 18.6030 -16.7060 25.9480 C 0 0 0 1 0 4 + 17.9180 -17.0720 24.6620 C 0 0 0 3 0 4 + 18.9660 -17.8240 26.5990 F 0 0 0 1 0 1 + 17.7360 -16.0050 26.7280 F 0 0 0 1 0 1 + 17.1580 -15.9350 24.1360 N 0 0 0 2 0 3 + 17.9180 -15.2540 23.1780 C 0 0 0 1 0 3 + 17.2740 -14.0320 22.4940 C 0 0 0 1 0 3 + 18.0090 -13.4450 21.5160 N 0 0 0 1 0 3 + 19.3550 -13.9470 21.1720 C 0 0 0 1 0 3 + 19.9300 -15.0380 21.9380 C 0 0 0 2 0 3 + 19.1980 -15.6190 22.9100 N 0 0 0 1 0 2 + 17.5460 -12.2610 20.7780 C 0 0 0 3 0 4 + 16.0670 -12.3310 20.4100 C 0 0 0 1 0 3 + 15.2870 -11.4840 21.1270 N 0 0 0 2 0 3 + 13.8690 -11.4110 20.7680 C 0 0 0 3 0 4 + 12.9150 -11.4250 21.9620 C 0 0 0 1 0 3 + 12.9000 -10.3750 22.8950 C 0 0 0 2 0 3 + 12.0190 -10.4350 24.0000 C 0 0 0 2 0 3 + 11.1120 -11.4930 24.1370 C 0 0 0 2 0 3 + 11.1250 -12.5320 23.2100 C 0 0 0 2 0 3 + 12.0370 -12.4940 22.1420 C 0 0 0 1 0 3 + 16.1420 -13.6640 22.8260 O 0 0 0 1 0 1 + 20.2420 -13.2370 19.8930 Cl 0 0 0 1 0 1 + 15.6570 -13.1090 19.5420 O 0 0 0 1 0 1 + 12.1890 -13.5200 21.2880 F 0 0 0 1 0 1 + 20.9520 -17.7700 24.8070 O 0 0 0 1 0 1 + 22.9688 -16.2327 24.6903 H 0 0 0 1 0 1 + 18.9377 -14.1230 26.5387 H 0 0 0 1 0 1 + 20.9764 -12.7678 26.2455 H 0 0 0 1 0 1 + 23.0457 -13.8629 25.3986 H 0 0 0 1 0 1 + 17.2309 -17.9112 24.8454 H 0 0 0 1 0 1 + 18.6751 -17.3727 23.9229 H 0 0 0 1 0 1 + 16.2051 -15.6752 24.4281 H 0 0 0 1 0 1 + 20.9416 -15.3834 21.7298 H 0 0 0 1 0 1 + 18.1340 -12.1722 19.8526 H 0 0 0 1 0 1 + 17.7102 -11.3712 21.4036 H 0 0 0 1 0 1 + 15.6647 -10.9320 21.8704 H 0 0 0 1 0 1 + 13.6313 -12.2730 20.1274 H 0 0 0 1 0 1 + 13.7036 -10.4799 20.2062 H 0 0 0 1 0 1 + 13.5595 -9.5240 22.7689 H 0 0 0 1 0 1 + 12.0463 -9.6526 24.7498 H 0 0 0 1 0 1 + 10.4050 -11.5031 24.9586 H 0 0 0 1 0 1 + 10.4370 -13.3635 23.3116 H 0 0 0 1 0 1 + 1 2 4 0 0 1 + 1 6 4 0 0 1 + 2 3 4 0 0 1 + 2 32 2 0 0 2 + 3 4 4 0 0 1 + 3 7 1 0 0 2 + 4 5 4 0 0 1 + 5 6 4 0 0 1 + 7 8 1 0 0 2 + 7 9 1 0 0 2 + 7 10 1 0 0 2 + 8 11 1 0 0 2 + 11 12 1 0 0 2 + 12 13 1 0 0 1 + 12 17 2 0 0 1 + 13 14 1 0 0 1 + 13 28 2 0 0 2 + 14 15 1 0 0 1 + 14 18 1 0 0 2 + 15 16 2 0 0 1 + 15 29 1 0 0 2 + 16 17 1 0 0 1 + 18 19 1 0 0 2 + 19 20 1 0 0 2 + 19 30 2 0 0 2 + 20 21 1 0 0 2 + 21 22 1 0 0 2 + 22 23 4 0 0 1 + 22 27 4 0 0 1 + 23 24 4 0 0 1 + 24 25 4 0 0 1 + 25 26 4 0 0 1 + 26 27 4 0 0 1 + 27 31 1 0 0 2 + 1 33 1 0 0 2 + 4 34 1 0 0 2 + 5 35 1 0 0 2 + 6 36 1 0 0 2 + 8 37 1 0 0 2 + 8 38 1 0 0 2 + 11 39 1 0 0 2 + 16 40 1 0 0 2 + 18 41 1 0 0 2 + 18 42 1 0 0 2 + 20 43 1 0 0 2 + 21 44 1 0 0 2 + 21 45 1 0 0 2 + 23 46 1 0 0 2 + 24 47 1 0 0 2 + 25 48 1 0 0 2 + 26 49 1 0 0 2 +M END +> +C20H17N5O3F3Cl + +> +467.7 + +> +6 + +> +7 + +> +2.89 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/1w4q_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/1w4q_ligand.sdf new file mode 100644 index 000000000..030d08824 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/1w4q_ligand.sdf @@ -0,0 +1,84 @@ +1w4q_ligand + +Created by X-TOOL on Fri Nov 18 14:04:08 2016 + 31 32 0 0 0 0 0 0 0 0999 V2000 + 36.2250 -2.3660 12.1580 N 0 0 0 1 0 3 + 35.0290 -2.5550 11.4210 C 0 0 0 1 0 3 + 34.7000 -1.7980 10.5870 O 0 0 0 1 0 1 + 34.3270 -3.7120 11.7940 N 0 0 0 2 0 3 + 34.6750 -4.6670 12.7960 C 0 0 0 1 0 3 + 33.9250 -5.6050 12.9580 O 0 0 0 1 0 1 + 35.9240 -4.3900 13.5180 C 0 0 0 2 0 3 + 36.6450 -3.2830 13.1940 C 0 0 0 2 0 3 + 39.2530 -0.4990 15.5460 O 0 0 0 2 0 2 + 40.0020 -0.1650 14.2100 C 0 0 0 3 0 4 + 38.7750 0.1200 13.3080 C 0 0 0 2 0 4 + 38.4020 -1.1420 12.9600 O 0 0 0 1 0 2 + 37.6410 1.0610 13.2010 C 0 0 0 2 0 4 + 37.5420 2.5320 12.9110 O 0 0 0 1 0 2 + 36.5030 0.3120 12.3010 C 0 0 0 2 0 4 + 36.2460 1.3130 11.5430 F 0 0 0 1 0 1 + 37.1740 -1.1150 11.8700 C 0 0 0 2 0 4 + 35.4680 3.1250 13.5200 O 0 0 0 1 0 1 + 37.0160 3.5030 13.6300 P 0 0 0 1 0 4 + 37.3410 3.6810 15.0910 O 0 0 0 1 0 1 + 37.4710 4.6660 12.8340 O 0 0 0 1 0 1 + 33.4780 -3.8890 11.2961 H 0 0 0 1 0 1 + 36.2682 -5.0623 14.3025 H 0 0 0 1 0 1 + 37.5694 -3.0806 13.7329 H 0 0 0 1 0 1 + 38.6832 -1.2469 15.4099 H 0 0 0 1 0 1 + 40.5932 -1.0175 13.8445 H 0 0 0 1 0 1 + 40.6528 0.7160 14.3113 H 0 0 0 1 0 1 + 39.3186 0.4879 12.4253 H 0 0 0 1 0 1 + 37.2659 1.0391 14.2348 H 0 0 0 1 0 1 + 35.5930 0.0715 12.8703 H 0 0 0 1 0 1 + 37.5145 -1.1206 10.8241 H 0 0 0 1 0 1 + 1 2 1 0 0 1 + 1 8 1 0 0 1 + 17 1 1 0 0 2 + 2 3 2 0 0 2 + 2 4 1 0 0 1 + 4 5 1 0 0 1 + 5 6 2 0 0 2 + 7 5 1 0 0 1 + 8 7 2 0 0 1 + 10 9 1 0 0 2 + 11 10 1 0 0 2 + 12 11 1 0 0 1 + 11 13 1 0 0 1 + 12 17 1 0 0 1 + 13 14 1 0 0 2 + 13 15 1 0 0 1 + 14 19 1 0 0 2 + 15 16 1 0 0 2 + 15 17 1 0 0 1 + 19 18 2 0 0 2 + 19 20 2 0 0 2 + 19 21 2 0 0 2 + 4 22 1 0 0 2 + 7 23 1 0 0 2 + 8 24 1 0 0 2 + 9 25 1 0 0 2 + 10 26 1 0 0 2 + 10 27 1 0 0 2 + 11 28 1 0 0 2 + 13 29 1 0 0 2 + 15 30 1 0 0 2 + 17 31 1 0 0 2 +M END +> +C9H10N2O8PF + +> +324.1 + +> +9 + +> +3 + +> +-2.27 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/2e94_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/2e94_ligand.sdf new file mode 100644 index 000000000..35de477f5 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/2e94_ligand.sdf @@ -0,0 +1,113 @@ +2e94_ligand + +Created by X-TOOL on Fri Nov 18 14:45:46 2016 + 45 47 0 0 0 0 0 0 0 0999 V2000 + 35.3180 53.0670 10.5620 C 0 0 0 2 0 3 + 36.1370 53.5310 11.5840 C 0 0 0 2 0 3 + 36.4880 52.6820 12.6290 C 0 0 0 2 0 3 + 36.0170 51.3740 12.6480 C 0 0 0 2 0 3 + 35.1970 50.9120 11.6240 C 0 0 0 2 0 3 + 34.8460 51.7570 10.5760 C 0 0 0 1 0 3 + 34.0920 51.2750 9.5140 C 0 0 0 1 0 3 + 33.0200 50.4150 9.7350 C 0 0 0 2 0 3 + 34.4090 51.6590 8.2140 C 0 0 0 2 0 3 + 33.6640 51.1810 7.1430 C 0 0 0 2 0 3 + 32.5970 50.3180 7.3690 C 0 0 0 2 0 3 + 32.2710 49.9350 8.6650 C 0 0 0 1 0 3 + 31.1760 49.1050 8.8820 C 0 0 0 1 0 3 + 30.9280 48.0420 8.0190 C 0 0 0 2 0 3 + 30.3640 49.2900 9.9960 C 0 0 0 2 0 3 + 29.3100 48.4230 10.2570 C 0 0 0 2 0 3 + 29.0600 47.3550 9.4030 C 0 0 0 2 0 3 + 29.8730 47.1580 8.2800 N 0 0 0 1 0 3 + 29.6790 45.9550 7.4370 C 0 0 0 3 0 4 + 29.2480 46.2370 5.9940 C 0 0 0 1 0 4 + 29.2590 44.5910 5.1110 P 0 0 0 1 0 4 + 29.0390 44.8840 3.5440 O 0 0 0 1 0 1 + 30.7590 44.0240 5.2380 O 0 0 0 1 0 1 + 28.2570 43.6440 5.6500 O 0 0 0 1 0 1 + 27.5660 47.0450 5.9070 P 0 0 0 1 0 4 + 26.4770 46.0170 6.5000 O 0 0 0 1 0 1 + 27.6150 48.2790 6.9420 O 0 0 0 1 0 1 + 27.2420 47.5040 4.5380 O 0 0 0 1 0 1 + 30.1860 47.1170 5.3640 O 0 0 0 2 0 2 + 35.0447 53.7291 9.7484 H 0 0 0 1 0 1 + 36.5015 54.5517 11.5673 H 0 0 0 1 0 1 + 37.1279 53.0400 13.4274 H 0 0 0 1 0 1 + 36.2895 50.7128 13.4627 H 0 0 0 1 0 1 + 34.8308 49.8919 11.6425 H 0 0 0 1 0 1 + 32.7673 50.1175 10.7463 H 0 0 0 1 0 1 + 35.2394 52.3328 8.0368 H 0 0 0 1 0 1 + 33.9143 51.4806 6.1317 H 0 0 0 1 0 1 + 32.0182 49.9431 6.5326 H 0 0 0 1 0 1 + 31.5516 47.8978 7.1441 H 0 0 0 1 0 1 + 30.5554 50.1191 10.6675 H 0 0 0 1 0 1 + 28.6824 48.5795 11.1269 H 0 0 0 1 0 1 + 28.2387 46.6772 9.6056 H 0 0 0 1 0 1 + 28.9061 45.3297 7.9077 H 0 0 0 1 0 1 + 30.6297 45.4025 7.4071 H 0 0 0 1 0 1 + 30.1822 47.9550 5.8115 H 0 0 0 1 0 1 + 1 2 4 0 0 1 + 1 6 4 0 0 1 + 2 3 4 0 0 1 + 3 4 4 0 0 1 + 4 5 4 0 0 1 + 5 6 4 0 0 1 + 6 7 1 0 0 2 + 7 8 4 0 0 1 + 7 9 4 0 0 1 + 8 12 4 0 0 1 + 9 10 4 0 0 1 + 10 11 4 0 0 1 + 11 12 4 0 0 1 + 12 13 1 0 0 2 + 13 14 4 0 0 1 + 13 15 4 0 0 1 + 14 18 4 0 0 1 + 15 16 4 0 0 1 + 16 17 4 0 0 1 + 17 18 4 0 0 1 + 18 19 1 0 0 2 + 19 20 1 0 0 2 + 20 21 1 0 0 2 + 20 25 1 0 0 2 + 20 29 1 0 0 2 + 21 22 2 0 0 2 + 21 23 2 0 0 2 + 21 24 2 0 0 2 + 25 26 2 0 0 2 + 25 27 2 0 0 2 + 25 28 2 0 0 2 + 1 30 1 0 0 2 + 2 31 1 0 0 2 + 3 32 1 0 0 2 + 4 33 1 0 0 2 + 5 34 1 0 0 2 + 8 35 1 0 0 2 + 9 36 1 0 0 2 + 10 37 1 0 0 2 + 11 38 1 0 0 2 + 14 39 1 0 0 2 + 15 40 1 0 0 2 + 16 41 1 0 0 2 + 17 42 1 0 0 2 + 19 43 1 0 0 2 + 19 44 1 0 0 2 + 29 45 1 0 0 2 +M END +> +C19H16NO7P2 + +> +432.1 + +> +8 + +> +2 + +> +1.94 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/4xaq_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/4xaq_ligand.sdf new file mode 100644 index 000000000..e592942e1 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/4xaq_ligand.sdf @@ -0,0 +1,68 @@ +4xaq_ligand + +Created by X-TOOL on Fri Nov 18 18:00:48 2016 + 23 24 0 0 0 0 0 0 0 0999 V2000 + -5.5750 35.7600 26.9370 O 0 0 0 1 0 1 + -8.1450 37.0440 27.8960 C 0 0 0 3 0 4 + -9.2460 32.3630 29.3640 O 0 0 0 1 0 1 + -7.7210 36.5030 29.3140 C 0 0 0 3 0 4 + -8.0470 35.8370 26.9130 C 0 0 0 1 0 4 + -7.9940 35.0120 29.2480 C 0 0 0 2 0 4 + -10.0660 33.3980 29.0580 C 0 5 0 1 0 3 + -9.3880 34.6630 28.7190 C 0 0 0 2 0 4 + -8.2120 34.6260 27.7880 C 0 0 0 2 0 4 + -11.2780 33.2560 29.0670 O 0 0 0 1 0 1 + -9.0700 35.8490 25.8450 N 0 3 0 4 0 4 + -6.6190 35.7900 26.3010 C 0 5 0 1 0 3 + -6.5010 35.8060 24.9570 O 0 0 0 1 0 1 + -7.4661 37.8489 27.5780 H 0 0 0 1 0 1 + -9.1763 37.4252 27.9277 H 0 0 0 1 0 1 + -8.3223 36.9738 30.1057 H 0 0 0 1 0 1 + -6.6541 36.6951 29.5006 H 0 0 0 1 0 1 + -7.4560 34.4093 29.9945 H 0 0 0 1 0 1 + -10.1400 35.4606 28.6279 H 0 0 0 1 0 1 + -7.8481 33.6937 27.3314 H 0 0 0 1 0 1 + -8.9446 36.6665 25.2688 H 0 0 0 1 0 1 + -9.9885 35.8680 26.2597 H 0 0 0 1 0 1 + -8.9741 35.0208 25.2785 H 0 0 0 1 0 1 + 12 1 2 0 0 2 + 4 2 1 0 0 1 + 5 2 1 0 0 1 + 7 3 2 0 0 2 + 6 4 1 0 0 1 + 9 5 1 0 0 1 + 5 11 1 0 0 2 + 5 12 1 0 0 2 + 8 6 1 0 0 1 + 6 9 1 0 0 1 + 7 8 1 0 0 2 + 7 10 2 0 0 2 + 8 9 1 0 0 1 + 12 13 2 0 0 2 + 2 14 1 0 0 2 + 2 15 1 0 0 2 + 4 16 1 0 0 2 + 4 17 1 0 0 2 + 6 18 1 0 0 2 + 8 19 1 0 0 2 + 9 20 1 0 0 2 + 11 21 1 0 0 2 + 11 22 1 0 0 2 + 11 23 1 0 0 2 +M END +> +C8H10NO4 + +> +184.1 + +> +5 + +> +0 + +> +-3.47 + +$$$$ diff --git a/tests/bond_order/refined-set-ligands/origin/4xtw_ligand.sdf b/tests/bond_order/refined-set-ligands/origin/4xtw_ligand.sdf new file mode 100644 index 000000000..3099254f7 --- /dev/null +++ b/tests/bond_order/refined-set-ligands/origin/4xtw_ligand.sdf @@ -0,0 +1,161 @@ +4xtw_ligand + +Created by X-TOOL on Fri Nov 18 18:00:31 2016 + 68 72 0 0 0 0 0 0 0 0999 V2000 + -4.7030 1.6350 5.9630 N 0 0 0 1 0 1 + -5.6630 -0.3240 11.3830 C 0 0 0 1 0 3 + -6.3580 -0.7620 13.6240 C 0 0 0 1 0 3 + -2.1170 -10.0370 13.8260 C 0 0 0 2 0 4 + -0.9500 -9.2030 13.5700 N 0 0 0 2 0 3 + -0.0190 -9.3280 14.5020 C 0 0 0 1 0 3 + 1.0640 -8.7620 14.4970 O 0 0 0 1 0 1 + -0.4310 -10.1590 15.4430 N 0 0 0 2 0 3 + -1.7740 -10.6600 15.1950 C 0 0 0 2 0 4 + -2.6150 -10.0570 16.3170 C 0 0 0 3 0 4 + -3.3090 -8.6030 15.6260 S 0 0 0 1 0 2 + -3.3050 -9.0820 13.9370 C 0 0 0 2 0 4 + -3.2130 -7.8700 13.0160 C 0 0 0 3 0 4 + -3.5220 -8.2720 11.5780 C 0 0 0 3 0 4 + -3.6630 -7.0670 10.6530 C 0 0 0 3 0 4 + -4.0230 -7.5380 9.2480 C 0 0 0 3 0 4 + -4.4420 -6.3980 8.3460 C 0 0 0 1 0 3 + -5.5370 -5.8720 8.4720 O 0 0 0 1 0 1 + -3.5630 -6.0160 7.4210 N 0 0 0 2 0 3 + -3.8940 -4.8900 6.4520 S 0 0 0 1 0 4 + -5.0320 -5.2610 5.6570 O 0 0 0 1 0 1 + -2.7710 -4.6720 5.5860 O 0 0 0 1 0 1 + -4.2490 -3.5330 7.2450 N 0 0 0 2 0 3 + -3.0360 -2.7820 7.6110 C 0 0 0 3 0 4 + -3.4150 -1.3070 7.6960 C 0 0 0 2 0 4 + -4.5300 -1.1180 8.5710 O 0 0 0 1 0 2 + -2.3120 -0.4110 8.2320 C 0 0 0 2 0 4 + -1.5100 0.0980 7.1630 O 0 0 0 2 0 2 + -3.0660 0.7150 8.9090 C 0 0 0 2 0 4 + -4.4280 0.1340 9.2560 C 0 0 0 2 0 4 + -4.5270 -0.1090 10.7160 N 0 0 0 1 0 3 + -3.5070 -0.1720 11.5850 C 0 0 0 2 0 3 + -3.9970 -0.4210 12.8210 N 0 0 0 1 0 2 + -5.3390 -0.5200 12.7140 C 0 0 0 1 0 3 + -6.9580 -0.3730 10.9940 N 0 0 0 1 0 2 + -7.9210 -0.6080 11.8920 C 0 0 0 2 0 3 + -7.6350 -0.7990 13.1870 N 0 0 0 1 0 2 + -6.0820 -0.9590 14.9360 N 0 0 0 3 0 3 + -4.0200 1.7320 6.8940 N 0 0 0 1 0 2 + -3.2220 1.8460 8.0110 N 0 0 0 1 0 2 + -2.2852 -10.7999 13.0516 H 0 0 0 1 0 1 + -0.8622 -8.6014 12.7761 H 0 0 0 1 0 1 + 0.1194 -10.4152 16.2376 H 0 0 0 1 0 1 + -1.8407 -11.7579 15.1794 H 0 0 0 1 0 1 + -1.9846 -9.8109 17.1842 H 0 0 0 1 0 1 + -3.4069 -10.7553 16.6256 H 0 0 0 1 0 1 + -4.2328 -9.6221 13.6972 H 0 0 0 1 0 1 + -2.1962 -7.4532 13.0655 H 0 0 0 1 0 1 + -3.9373 -7.1097 13.3436 H 0 0 0 1 0 1 + -4.4644 -8.8392 11.5648 H 0 0 0 1 0 1 + -2.7056 -8.9086 11.2063 H 0 0 0 1 0 1 + -2.7111 -6.5166 10.6216 H 0 0 0 1 0 1 + -4.4565 -6.4060 11.0317 H 0 0 0 1 0 1 + -4.8533 -8.2560 9.3183 H 0 0 0 1 0 1 + -3.1460 -8.0336 8.8062 H 0 0 0 1 0 1 + -2.6760 -6.4740 7.3626 H 0 0 0 1 0 1 + -5.1792 -3.2369 7.4621 H 0 0 0 1 0 1 + -2.2600 -2.9263 6.8449 H 0 0 0 1 0 1 + -2.6593 -3.1291 8.5844 H 0 0 0 1 0 1 + -3.6831 -0.9704 6.6837 H 0 0 0 1 0 1 + -1.6764 -0.9510 8.9492 H 0 0 0 1 0 1 + -0.8273 0.6549 7.5182 H 0 0 0 1 0 1 + -2.5391 1.0381 9.8190 H 0 0 0 1 0 1 + -5.2279 0.8174 8.9350 H 0 0 0 1 0 1 + -2.4547 -0.0435 11.3357 H 0 0 0 1 0 1 + -8.9540 -0.6447 11.5654 H 0 0 0 1 0 1 + -6.8471 -1.1378 15.6020 H 0 0 0 1 0 1 + -5.1071 -0.9299 15.2672 H 0 0 0 1 0 1 + 39 1 3 0 0 2 + 31 2 1 0 0 1 + 2 34 4 0 0 1 + 2 35 4 0 0 1 + 34 3 4 0 0 1 + 3 37 4 0 0 1 + 3 38 1 0 0 2 + 4 5 1 0 0 1 + 4 9 1 0 0 1 + 12 4 1 0 0 1 + 5 6 1 0 0 1 + 6 7 2 0 0 2 + 8 6 1 0 0 1 + 9 8 1 0 0 1 + 10 9 1 0 0 1 + 11 10 1 0 0 1 + 12 11 1 0 0 1 + 13 12 1 0 0 2 + 14 13 1 0 0 2 + 15 14 1 0 0 2 + 16 15 1 0 0 2 + 17 16 1 0 0 2 + 17 18 2 0 0 2 + 19 17 1 0 0 2 + 20 19 1 0 0 2 + 20 21 2 0 0 2 + 20 22 2 0 0 2 + 23 20 1 0 0 2 + 24 23 1 0 0 2 + 25 24 1 0 0 2 + 26 25 1 0 0 1 + 27 25 1 0 0 1 + 30 26 1 0 0 1 + 27 28 1 0 0 2 + 29 27 1 0 0 1 + 29 30 1 0 0 1 + 40 29 1 0 0 2 + 30 31 1 0 0 2 + 31 32 1 0 0 1 + 32 33 2 0 0 1 + 33 34 1 0 0 1 + 35 36 4 0 0 1 + 36 37 4 0 0 1 + 39 40 2 0 0 2 + 4 41 1 0 0 2 + 5 42 1 0 0 2 + 8 43 1 0 0 2 + 9 44 1 0 0 2 + 10 45 1 0 0 2 + 10 46 1 0 0 2 + 12 47 1 0 0 2 + 13 48 1 0 0 2 + 13 49 1 0 0 2 + 14 50 1 0 0 2 + 14 51 1 0 0 2 + 15 52 1 0 0 2 + 15 53 1 0 0 2 + 16 54 1 0 0 2 + 16 55 1 0 0 2 + 19 56 1 0 0 2 + 23 57 1 0 0 2 + 24 58 1 0 0 2 + 24 59 1 0 0 2 + 25 60 1 0 0 2 + 27 61 1 0 0 2 + 28 62 1 0 0 2 + 29 63 1 0 0 2 + 30 64 1 0 0 2 + 32 65 1 0 0 2 + 36 66 1 0 0 2 + 38 67 1 0 0 2 + 38 68 1 0 0 2 +M END +> +C20H28N12O6S2 + +> +596.5 + +> +17 + +> +9 + +> +-2.69 + +$$$$ diff --git a/tests/test_bond_order_system.py b/tests/test_bond_order_system.py index 7fbad6c28..086a90cad 100644 --- a/tests/test_bond_order_system.py +++ b/tests/test_bond_order_system.py @@ -1,6 +1,7 @@ import os import unittest from context import dpdata +import glob from rdkit import Chem from rdkit.Chem import AllChem import shutil @@ -75,4 +76,24 @@ def test_dump_to_deepmd_npy(self): for bond_idx in range(4): for ii in range(3): self.assertEqual(syst['bonds'][bond_idx][ii], bonds[bond_idx][ii]) - shutil.rmtree("bond_order/methane") \ No newline at end of file + shutil.rmtree("bond_order/methane") + + def test_sanitize_mol_obabel(self): + cnt = 0 + for sdf_file in glob.glob("bond_order/refined-set-ligands/obabel/*sdf"): + syst = dpdata.BondOrderSystem(sdf_file, sanitize_level='high', verbose=False) + if syst.rdkit_mol is None: + cnt += 1 + self.assertEqual(cnt, 0) + + def test_sanitize_mol_origin(self): + cnt = 0 + for sdf_file in glob.glob("bond_order/refined-set-ligands/origin/*sdf"): + syst = dpdata.BondOrderSystem(sdf_file, sanitize_level='high', verbose=False) + if syst.rdkit_mol is None: + cnt += 1 + self.assertEqual(cnt, 0) + + def tearDown(self): + if os.path.exists("tests/.cache"): + shutil.rmtree("tests/.cache") From 8e7f0bc09b743210266e4d9c0f795300eab21fe3 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:22:16 +0800 Subject: [PATCH 13/28] Add support for AmberTools sqm/out --- dpdata/system.py | 8 +++ tests/amber/sqm.out | 138 ++++++++++++++++++++++++++++++++++++++++ tests/test_amber_sqm.py | 21 ++++++ 3 files changed, 167 insertions(+) create mode 100644 tests/amber/sqm.out create mode 100644 tests/test_amber_sqm.py diff --git a/dpdata/system.py b/dpdata/system.py index bd06b46d8..1bd509d67 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -17,6 +17,7 @@ import dpdata.md.pbc import dpdata.gaussian.log import dpdata.amber.md +import dpdata.amber.sqm import dpdata.cp2k.output from dpdata.cp2k.output import Cp2kSystems import dpdata.pwmat.movement @@ -696,6 +697,13 @@ def to_deepmd_raw(self, folder) : Dump the system in deepmd raw format to `folder` """ dpdata.deepmd.raw.dump(folder, self.data) + + @register_from_funcs.register_funcs('sqm/out') + def from_sqm_out(self, fname): + ''' + Read from ambertools sqm.out + ''' + self.data = dpdata.amber.sqm.to_system_data(fname) @register_from_funcs.register_funcs('siesta/output') def from_siesta_output(self, fname): diff --git a/tests/amber/sqm.out b/tests/amber/sqm.out new file mode 100644 index 000000000..764dc8649 --- /dev/null +++ b/tests/amber/sqm.out @@ -0,0 +1,138 @@ + -------------------------------------------------------- + AMBER SQM VERSION 19 + + By + Ross C. Walker, Michael F. Crowley, Scott Brozell, + Tim Giese, Andreas W. Goetz, + Tai-Sung Lee and David A. Case + + -------------------------------------------------------- + + +-------------------------------------------------------------------------------- + QM CALCULATION INFO +-------------------------------------------------------------------------------- + +| QMMM: Citation for AMBER QMMM Run: +| QMMM: R.C. Walker, M.F. Crowley and D.A. Case, J. COMP. CHEM. 29:1019, 2008 + +QMMM: SINGLET STATE CALCULATION +QMMM: RHF CALCULATION, NO. OF DOUBLY OCCUPIED LEVELS = 18 + +| QMMM: *** Selected Hamiltonian *** +| QMMM: AM1 + +| QMMM: *** Parameter sets in use *** +| QMMM: C : M.J.S.DEWAR et al. JACS, 107, 3902, (1985) +| QMMM: N : M.J.S.DEWAR et al. JACS, 107, 3902, (1985) +| QMMM: H : M.J.S.DEWAR et al. JACS, 107, 3902, (1985) + +| QMMM: *** SCF convergence criteria *** +| QMMM: Energy change : 0.1D-09 kcal/mol +| QMMM: Error matrix |FP-PF| : 0.1D+00 au +| QMMM: Density matrix change : 0.5D-06 +| QMMM: Maximum number of SCF cycles : 1000 + +| QMMM: *** Diagonalization Routine Information *** +| QMMM: Pseudo diagonalizations are allowed. +| QMMM: Auto diagonalization routine selection is in use. +| QMMM: +| QMMM: Timing diagonalization routines: +| QMMM: norbs = 34 +| QMMM: diag iterations used for timing = 20 +| QMMM: +| QMMM: Internal diag routine = 0.002953 seconds +| QMMM: Dspev diag routine = 0.174916 seconds +| QMMM: Dspevd diag routine = 0.002847 seconds +| QMMM: Dspevx diag routine = 0.018112 seconds +| QMMM: Dsyev diag routine = 0.016637 seconds +| QMMM: Dsyevd diag routine = 0.002183 seconds +| QMMM: Dsyevr diag routine = 0.003551 seconds +| QMMM: +| QMMM: Pseudo diag routine = 0.000901 seconds +| QMMM: +| QMMM: Using dsyevd routine (diag_routine=6). + + QMMM: QM Region Cartesian Coordinates (*=link atom) + QMMM: QM_NO. MM_NO. ATOM X Y Z + QMMM: 1 1 C 0.0090 2.0020 2.9920 + QMMM: 2 2 N -0.5270 2.5050 4.1370 + QMMM: 3 3 C -0.5300 0.8560 2.3840 + QMMM: 4 4 N 1.0500 2.6460 2.4950 + QMMM: 5 5 H -0.1200 3.3160 4.5380 + QMMM: 6 6 H -1.3090 2.0860 4.5790 + QMMM: 7 7 C 0.0580 0.4000 1.2310 + QMMM: 8 8 H -1.3780 0.3570 2.8170 + QMMM: 9 9 C 1.1550 1.0720 0.6990 + QMMM: 10 10 H -0.3330 -0.4760 0.7420 + QMMM: 11 11 C 1.5970 2.1840 1.3810 + QMMM: 12 12 H 1.6400 0.7440 -0.2010 + QMMM: 13 13 H 2.4420 2.7430 1.0170 + +-------------------------------------------------------------------------------- + RESULTS +-------------------------------------------------------------------------------- + + iter sqm energy rms gradient + ---- ------------------- ----------------------- +xmin 10 33.5359 kcal/mol 0.0648 kcal/(mol*A) +xmin 20 33.3605 kcal/mol 2.9126 kcal/(mol*A) +xmin 30 32.8935 kcal/mol 0.2527 kcal/(mol*A) +xmin 40 32.8838 kcal/mol 0.0537 kcal/(mol*A) +xmin 50 32.8834 kcal/mol 0.0102 kcal/(mol*A) +xmin 60 32.8833 kcal/mol 0.0020 kcal/(mol*A) + ... geometry converged ! + + Final MO eigenvalues (eV): + -39.9239 -35.3153 -32.8895 -29.5926 -24.0617 -23.2695 -18.1247 -17.8391 + -16.8615 -15.5408 -14.8743 -14.4815 -13.8252 -12.8035 -11.7649 -10.5917 + -10.5457 -8.8383 0.3220 0.4382 2.6389 2.8672 3.6975 3.8711 + 4.0454 4.1744 4.4373 4.7364 4.9688 5.3485 5.5584 5.8794 + 6.1725 6.9900 + + Heat of formation = 32.88333532 kcal/mol ( 1.42592842 eV) + + Total SCF energy = -26203.17173278 kcal/mol ( -1136.25479089 eV) + Electronic energy = -102669.26620941 kcal/mol ( -4452.07346643 eV) + Core-core repulsion = 76466.09447663 kcal/mol ( 3315.81867554 eV) + + Atomic Charges for Step 1 : + Atom Element Mulliken Charge + 1 C 0.105 + 2 N -0.324 + 3 C -0.235 + 4 N -0.198 + 5 H 0.204 + 6 H 0.193 + 7 C -0.059 + 8 H 0.141 + 9 C -0.230 + 10 H 0.135 + 11 C -0.031 + 12 H 0.143 + 13 H 0.156 + Total Mulliken Charge = -0.000 + + X Y Z TOTAL + QM DIPOLE -1.768 -0.338 -0.580 1.891 + + Final Structure + + QMMM: QM Region Cartesian Coordinates (*=link atom) + QMMM: QM_NO. MM_NO. ATOM X Y Z + QMMM: 1 1 C 0.0389 2.0017 3.0427 + QMMM: 2 2 N -0.4634 2.4081 4.2873 + QMMM: 3 3 C -0.5107 0.8424 2.4126 + QMMM: 4 4 N 1.0975 2.6846 2.4920 + QMMM: 5 5 H -0.1848 3.3129 4.5972 + QMMM: 6 6 H -1.4313 2.2158 4.4122 + QMMM: 7 7 C 0.0594 0.3846 1.2306 + QMMM: 8 8 H -1.3621 0.3152 2.8622 + QMMM: 9 9 C 1.1460 1.0651 0.6800 + QMMM: 10 10 H -0.3464 -0.5099 0.7348 + QMMM: 11 11 C 1.6183 2.2039 1.3541 + QMMM: 12 12 H 1.6200 0.7291 -0.2494 + QMMM: 13 13 H 2.4726 2.7815 0.9546 + + --------- Calculation Completed ---------- + diff --git a/tests/test_amber_sqm.py b/tests/test_amber_sqm.py new file mode 100644 index 000000000..48342c4cc --- /dev/null +++ b/tests/test_amber_sqm.py @@ -0,0 +1,21 @@ +import os +import unittest +import shutil +from context import dpdata +from comp_sys import CompSys, IsNoPBC + + +class TestAmberSqmOut(unittest.TestCase, CompSys, IsNoPBC): + def setUp (self) : + self.system_1 = dpdata.System('amber/sqm.out', fmt = 'sqm/out') + self.system_1.to('deepmd/npy','tmp.deepmd.npy') + self.system_2 = dpdata.System('tmp.deepmd.npy', fmt = 'deepmd/npy') + self.places = 5 + self.e_places = 4 + self.f_places = 6 + self.v_places = 6 + + def tearDown(self) : + if os.path.exists('tmp.deepmd.npy'): + shutil.rmtree('tmp.deepmd.npy') + From 3a840a2c251a07e8ecb4bcd2dc1688328c3e599b Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:22:31 +0800 Subject: [PATCH 14/28] Add bond order assignment --- dpdata/bond_order_system.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/dpdata/bond_order_system.py b/dpdata/bond_order_system.py index e60ac32ac..b590f1fcf 100644 --- a/dpdata/bond_order_system.py +++ b/dpdata/bond_order_system.py @@ -3,6 +3,9 @@ from dpdata.system import Register, System, LabeledSystem, check_System import rdkit.Chem import dpdata.rdkit.utils +from dpdata.rdkit.sanitize import Sanitizer, SanitizeError +from copy import deepcopy +# import dpdata.rdkit.mol2 def check_BondOrderSystem(data): check_System(data) @@ -28,6 +31,9 @@ def __init__(self, step = 1, data = None, rdkit_mol = None, + sanitize_level = "medium", + raise_errors = True, + verbose = False, **kwargs): """ Constructor @@ -52,12 +58,27 @@ def __init__(self, System data dict. rdkit_mol : rdkit.Chem.rdchem.Mol If `file_name` is None, you must init with a rdkit Mol type. + sanitize_level : str + The level of sanitizer, 'low', 'medium' or 'high'. + raise_errors : bool + whether to raise an Exception if sanitization procedure fails. + verbose : bool + whether to print information in the sanitization procedure. """ System.__init__(self) + self.sanitizer = Sanitizer(sanitize_level, raise_errors, verbose) + if data: + mol = dpdata.rdkit.utils.system_data_to_mol(data) + self.from_rdkit_mol(mol) if file_name: - self.from_fmt(file_name, fmt, type_map=type_map, begin=begin, step=step, **kwargs) + self.from_fmt(file_name, + fmt, + type_map=type_map, + begin=begin, + step=step, + **kwargs) elif rdkit_mol: self.from_rdkit_mol(rdkit_mol) else: @@ -100,6 +121,12 @@ def get_charge(self): ''' return sum(self.data['formal_charges']) + def get_mol(self): + ''' + Return the rdkit.Mol object + ''' + return self.rdkit_mol + def get_bond_order(self, begin_atom_idx, end_atom_idx): ''' Return the bond order between given atoms @@ -133,6 +160,7 @@ def from_rdkit_mol(self, rdkit_mol): ''' Initialize from a rdkit.Chem.rdchem.Mol object ''' + rdkit_mol = self.sanitizer.sanitize(rdkit_mol) self.data = dpdata.rdkit.utils.mol_to_system_data(rdkit_mol) self.data['bond_dict'] = dict([(f'{int(bond[0])}-{int(bond[1])}', bond[2]) for bond in self.data['bonds']]) self.rdkit_mol = rdkit_mol From 77fa374bdb46856acf7a649207df4eecce8a3ae1 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:23:11 +0800 Subject: [PATCH 15/28] Add support for AmberTools sqm/out --- dpdata/amber/__init__.py | 1 + dpdata/amber/sqm.py | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 dpdata/amber/__init__.py create mode 100644 dpdata/amber/sqm.py diff --git a/dpdata/amber/__init__.py b/dpdata/amber/__init__.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/dpdata/amber/__init__.py @@ -0,0 +1 @@ + diff --git a/dpdata/amber/sqm.py b/dpdata/amber/sqm.py new file mode 100644 index 000000000..6d5843126 --- /dev/null +++ b/dpdata/amber/sqm.py @@ -0,0 +1,54 @@ +import numpy as np + + +START = 0 +READ_CHARGE = 1 +READ_CHARGE_SUCCESS = 2 +READ_COORDS_START = 3 +READ_COORDS = 6 + +def parse_sqm_out(fname): + ''' + Read atom symbols, charges and coordinates from ambertools sqm.out file + ''' + atom_symbols = [] + coords = [] + charges = [] + with open(fname) as f: + flag = 0 + for line in f: + if line.startswith(" Atom Element Mulliken Charge"): + flag = READ_CHARGE + elif line.startswith(" Total Mulliken Charge"): + flag = READ_CHARGE_SUCCESS + elif line.startswith(" Final Structure"): + flag = READ_COORDS_START + elif flag == READ_CHARGE: + ls = line.strip().split() + atom_symbols.append(ls[-2]) + charges.append(float(ls[-1])) + elif READ_COORDS_START <= flag < READ_COORDS: + flag += 1 + elif flag == READ_COORDS: + ls = line.strip() + if not ls: + break + else: + symbol = line.strip().split()[-4] + coord = list(map(float, line.strip().split()[-3:])) + coords.append(coord) + return atom_symbols, charges, np.array(coords) + + +def to_system_data(fname): + data = {} + atom_symbols, charges, coords = parse_sqm_out(fname) + atom_names, data['atom_types'], atom_numbs = np.unique(atom_symbols, return_inverse=True, return_counts=True) + data['atom_names'] = list(atom_names) + data['atom_numbs'] = list(atom_numbs) + data['charges'] = np.array([charges]) + data['coords'] = np.array([coords]) + data['orig'] = np.array([0, 0, 0]) + data['cells'] = np.array([[[100., 0., 0.], [0., 100., 0.], [0., 0., 100.]]]) + data['nopbc'] = True + return data From 9b56cddc61b2dbb03e264adaf2114944b365beb0 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:23:25 +0800 Subject: [PATCH 16/28] Creat __init__.py --- dpdata/pwmat/__init__.py | 1 + dpdata/siesta/__init__.py | 1 + 2 files changed, 2 insertions(+) create mode 100644 dpdata/pwmat/__init__.py create mode 100644 dpdata/siesta/__init__.py diff --git a/dpdata/pwmat/__init__.py b/dpdata/pwmat/__init__.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/dpdata/pwmat/__init__.py @@ -0,0 +1 @@ + diff --git a/dpdata/siesta/__init__.py b/dpdata/siesta/__init__.py new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/dpdata/siesta/__init__.py @@ -0,0 +1 @@ + From 9c3d24dfe97518e9d6d148a5a41b955798c61a1b Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:23:54 +0800 Subject: [PATCH 17/28] Add rdkit & openbabel environment --- .github/workflows/test.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 45c97af79..501a8bb3d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,12 +13,17 @@ jobs: steps: - uses: actions/checkout@v2 + # set up conda - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: conda-incubator/setup-miniconda@v2 with: - python-version: ${{ matrix.python-version }} + auto-activate-base: true + activate-environment: "" + # install rdkit and openbabel + - name: Install rdkit + run: conda create -c conda-forge -n my-rdkit-env python=${{ matrix.python-version }} rdkit openbabel; - name: Install dependencies - run: pip install .[amber] coverage codecov + run: source $CONDA/bin/activate my-rdkit-env && pip install .[amber] coverage codecov - name: Test - run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report - - run: codecov + run: source $CONDA/bin/activate my-rdkit-env && cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report + - run: source $CONDA/bin/activate my-rdkit-env && codecov From e6296d0dae685ec16331e86087076f2f260bfb21 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:26:58 +0800 Subject: [PATCH 18/28] Update README.md --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index fd1532990..66333f824 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ The `System` or `LabeledSystem` can be constructed from the following file forma | PWmat | movement | True | True | LabeledSystem | 'pwmat/movement' | | PWmat | OUT.MLMD | True | True | LabeledSystem | 'pwmat/out.mlmd' | | Amber | multi | True | True | LabeledSystem | 'amber/md' | +| Amber/sqm | sqm.out | False | False | System | 'sqm/out' | | Gromacs | gro | True | False | System | 'gromacs/gro' | @@ -206,4 +207,48 @@ s.replace('Hf', 'Zr', 8) s.to_vasp_poscar('POSCAR.P42nmc.replace') ``` +# BondOrderSystem +A new class `BondOrderSystem` which inherits from class `System` is introduced in dpdata. This new class contains information of chemical bonds and formal charges (stored in `BondOrderSystem.data['bonds']`, `BondOrderSystem.data['formal_charges']`). Now BondOrderSystem can only read from .mol/.sdf formats, because of its dependency on rdkit (which means rdkit must be installed if you want to use this function). Other formats, such as pdb, must be converted to .mol/.sdf format (maybe with software like open babel). +```python +import dpdata +system_1 = dpdata.BondOrderSystem("tests/bond_order/CH3OH.mol", fmt="mol") # read from .mol file +system_2 = dpdata.BondOrderSystem("tests/bond_order/methane.sdf", fmt="sdf") # read from .sdf file +``` +In sdf file, all molecules must be of the same topology (i.e. conformers of the same molecular configuration). +`BondOrderSystem` also supports initialize from a `rdkit.Chem.rdchem.Mol` object directly. +```python +from rdkit import Chem +from rdkit.Chem import AllChem +import dpdata + +mol = Chem.MolFromSmiles("CC") +mol = Chem.AddHs(mol) +AllChem.EmbedMultipleConfs(mol, 10) +system = dpdata.BondOrderSystem(rdkit_mol=mol) +``` + +## Bond Order Assignment +The `BondOrderSystem` implements a more robust sanitize procedure for rdkit Mol, as defined in `dpdata.rdkit.santizie.Sanitizer`. This class defines 3 level of sanitization process by: low, medium and high. (default is medium). ++ low: use `rdkit.Chem.SanitizeMol()` function to sanitize molecule. ++ medium: before using rdkit, the programm will first assign formal charge of each atom to avoid inappropriate valence exceptions. However, this mode requires the rightness of the bond order information in the given molecule. ++ high: the program will try to fix inappropriate bond orders in aromatic hetreocycles, phosphate, sulfate, carboxyl, nitro, nitrine, guanidine groups. If this procedure fails to sanitize the given molecule, the program will then try to call `obabel` to pre-process the mol and repeat the sanitization procedure. **That is to say, if you wan't to use this level of sanitization, please ensure `obabel` is installed in the environment.** +According to our test, our sanitization procedure can successfully read 4852 small molecules in the PDBBind-refined-set. It is necessary to point out that the in the molecule file (mol/sdf), the number of explicit hydrogens has to be correct. Thus, we recommend to use + `obabel xxx -O xxx -h` to pre-process the file. The reason why we do not implement this hydrogen-adding procedure in dpdata is that we can not ensure its correctness. + +```python +import dpdata + +for sdf_file in glob.glob("bond_order/refined-set-ligands/obabel/*sdf"): + syst = dpdata.BondOrderSystem(sdf_file, sanitize_level='high', verbose=False) +``` +## Formal Charge Assignment +BondOrderSystem implement a method to assign formal charge for each atom based on the 8-electron rule (see below). Note that it only supports common elements in bio-system: B,C,N,O,P,S,As +```python +import dpdata + +syst = dpdata.BondOrderSystem("tests/bond_order/CH3NH3+.mol", fmt='mol') +print(syst.get_formal_charges()) # return the formal charge on each atom +print(syst.get_charge()) # return the total charge of the system +``` +If a valence of 3 is detected on carbon, the formal charge will be assigned to -1. Because for most cases (in alkynyl anion, isonitrile, cyclopentadienyl anion), the formal charge on 3-valence carbon is -1, and this is also consisent with the 8-electron rule. From eb18eaf7bddc241ace849fd56a4ec04668ab4400 Mon Sep 17 00:00:00 2001 From: Ericwang6 Date: Wed, 19 May 2021 00:27:10 +0800 Subject: [PATCH 19/28] Update test.yml --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 501a8bb3d..fa40e3e73 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,4 +26,5 @@ jobs: run: source $CONDA/bin/activate my-rdkit-env && pip install .[amber] coverage codecov - name: Test run: source $CONDA/bin/activate my-rdkit-env && cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report - - run: source $CONDA/bin/activate my-rdkit-env && codecov + - name: Run codecov + run: source $CONDA/bin/activate my-rdkit-env && codecov From 3876eb33eb0086c7de83f01c8a1e64342b666e18 Mon Sep 17 00:00:00 2001 From: Ericwang6 <63655850+Ericwang6@users.noreply.github.com> Date: Wed, 19 May 2021 12:14:45 +0800 Subject: [PATCH 20/28] Remove non user-friendly warnings --- dpdata/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dpdata/__init__.py b/dpdata/__init__.py index 92ba1b835..bd8fd8c02 100644 --- a/dpdata/__init__.py +++ b/dpdata/__init__.py @@ -16,7 +16,6 @@ USE_RDKIT = True except ModuleNotFoundError: USE_RDKIT = False - print("WARNING: No rdkit is installed, 'BondOrderSystem' cannot be used") if USE_RDKIT: from .bond_order_system import BondOrderSystem From 2053d117a9dcf69215a63489b3c22dd17e6bf0c3 Mon Sep 17 00:00:00 2001 From: Ericwang6 <63655850+Ericwang6@users.noreply.github.com> Date: Wed, 19 May 2021 14:51:01 +0800 Subject: [PATCH 21/28] Update dpdata/rdkit/sanitize.py Co-authored-by: Jinzhe Zeng --- dpdata/rdkit/sanitize.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dpdata/rdkit/sanitize.py b/dpdata/rdkit/sanitize.py index 23cfaaaa1..153c25318 100644 --- a/dpdata/rdkit/sanitize.py +++ b/dpdata/rdkit/sanitize.py @@ -456,7 +456,12 @@ def convert_by_obabel(mol, cache_dir=os.path.join(os.getcwd(), '.cache'), obabel mol_file_in = os.path.join(cache_dir, f'{name}.mol') mol_file_out = os.path.join(cache_dir, f'{name}_obabel.mol') Chem.MolToMolFile(mol, mol_file_in, kekulize=False) - out = os.popen(f"obabel {mol_file_in} -O {mol_file_out}").read() + from openbabel import openbabel + obConversion = openbabel.OBConversion() + obConversion.SetInAndOutFormats("mol", "mol") + mol = openbabel.OBMol() + obConversion.ReadFile(mol, mol_file_in) + obConversion.WriteFile(mol, mol_file_out) mol_obabel = Chem.MolFromMolFile(mol_file_out, removeHs=False, sanitize=False) return mol_obabel @@ -565,4 +570,4 @@ def __str__(self): return self.content def __repr__(self): - return self.__str__() \ No newline at end of file + return self.__str__() From 64d7e47eead50745d05e080e5d6109ddad8f5cdd Mon Sep 17 00:00:00 2001 From: Ericwang6 <63655850+Ericwang6@users.noreply.github.com> Date: Wed, 19 May 2021 14:57:17 +0800 Subject: [PATCH 22/28] Use obabel python interface --- dpdata/rdkit/sanitize.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dpdata/rdkit/sanitize.py b/dpdata/rdkit/sanitize.py index 153c25318..7e40fa7b4 100644 --- a/dpdata/rdkit/sanitize.py +++ b/dpdata/rdkit/sanitize.py @@ -3,12 +3,12 @@ from rdkit.Chem.rdchem import Atom, Bond, Mol, BondType import os import time - -USE_OBABEL = False -for path in os.environ['PATH'].split(":"): - if os.path.exists(os.path.join(path, "obabel")): - USE_OBABEL = True - break +# openbabel +try: + from openbabel import openbabel + USE_OBABEL = True +except ModuleNotFoundError as e: + USE_OBABEL = False def get_explicit_valence(atom, verbose=False): exp_val_calculated_from_bonds = int(sum([bond.GetBondTypeAsDouble() for bond in atom.GetBonds()])) @@ -456,7 +456,6 @@ def convert_by_obabel(mol, cache_dir=os.path.join(os.getcwd(), '.cache'), obabel mol_file_in = os.path.join(cache_dir, f'{name}.mol') mol_file_out = os.path.join(cache_dir, f'{name}_obabel.mol') Chem.MolToMolFile(mol, mol_file_in, kekulize=False) - from openbabel import openbabel obConversion = openbabel.OBConversion() obConversion.SetInAndOutFormats("mol", "mol") mol = openbabel.OBMol() @@ -526,7 +525,7 @@ def _check_level(self, level): raise ValueError(f"Invalid level '{level}', please set to 'low', 'medium' or 'high'") else: if level == 'high' and not USE_OBABEL: - raise OSError("obabel not installed, high level sanitizer cannot work") + raise ModuleNotFoundError("obabel not installed, high level sanitizer cannot work") def _handle_exception(self, error_info): if self.raise_errors: From c6a92fe1bf5938db2c146f9ef6080e1cc28065ab Mon Sep 17 00:00:00 2001 From: Yingze Wang <63655850+Ericwang6@users.noreply.github.com> Date: Mon, 14 Jun 2021 00:50:42 +0800 Subject: [PATCH 23/28] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 66333f824..624d0092d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -**dpdata** is a python package for manipulating DeePMD-kit, VASP, LAMMPS data formats. +**dpdata** is a python package for manipulating data formats of software in computational science, including DeePMD-kit, VASP, LAMMPS, GROMACS, Gaussian. dpdata only works with python 3.x. @@ -116,7 +116,7 @@ xyz_multi_systems.to_deepmd_raw('./my_deepmd_data/') ``` You may also use the following code to parse muti-system: -``` +```python from dpdata import LabeledSystem,MultiSystems from glob import glob """ From 53198b6687f9aca8d4aa7cc11d9262f8a121cd63 Mon Sep 17 00:00:00 2001 From: Yingze Wang Date: Tue, 24 Aug 2021 10:47:52 +0800 Subject: [PATCH 24/28] Remove dependency on data for MolFormat & SdfFormat --- dpdata/plugins/rdkit.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dpdata/plugins/rdkit.py b/dpdata/plugins/rdkit.py index 20e5696b2..5385027b6 100644 --- a/dpdata/plugins/rdkit.py +++ b/dpdata/plugins/rdkit.py @@ -13,8 +13,8 @@ def from_bond_order_system(self, file_name, **kwargs): return rdkit.Chem.MolFromMolFile(file_name, sanitize=False, removeHs=False) - def to_bond_order_system(self, mol, data, file_name, frame_idx=0, **kwargs): - assert (frame_idx < self.get_nframes()) + def to_bond_order_system(self, mol, file_name, frame_idx=0, **kwargs): + assert (frame_idx < mol.GetNumConformers()) rdkit.Chem.MolToMolFile(mol, file_name, confId=frame_idx) @@ -32,12 +32,12 @@ def from_bond_order_system(self, file_name, **kwargs): mol = mols[0] return mol - def to_bond_order_system(self, mol, data, file_name, frame_idx=-1, **kwargs): + def to_bond_order_system(self, mol, file_name, frame_idx=-1, **kwargs): sdf_writer = rdkit.Chem.SDWriter(file_name) if frame_idx == -1: - for ii in range(data['coords'].shape[0]): + for ii in range(mol.GetNumConformers()): sdf_writer.write(mol, confId=ii) else: - assert (frame_idx < data['coords'].shape[0]) + assert (frame_idx < mol.GetNumConformers()) sdf_writer.write(mol, confId=frame_idx) sdf_writer.close() \ No newline at end of file From d9eae31cbf621d4f2b6d3ac3992b53c64b1016fc Mon Sep 17 00:00:00 2001 From: Yingze Wang Date: Tue, 24 Aug 2021 10:48:53 +0800 Subject: [PATCH 25/28] Support dump multiple conformers for sdf file --- dpdata/bond_order_system.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dpdata/bond_order_system.py b/dpdata/bond_order_system.py index 6b0869a9f..f661bf36a 100644 --- a/dpdata/bond_order_system.py +++ b/dpdata/bond_order_system.py @@ -4,6 +4,7 @@ import dpdata.rdkit.utils from dpdata.rdkit.sanitize import Sanitizer, SanitizeError from copy import deepcopy +from rdkit.Chem import Conformer # import dpdata.rdkit.mol2 def check_BondOrderSystem(data): @@ -95,7 +96,13 @@ def from_fmt_obj(self, fmtobj, file_name, **kwargs): return self def to_fmt_obj(self, fmtobj, *args, **kwargs): - return fmtobj.to_bond_order_system(self.data, self.rdkit_mol, *args, **kwargs) + self.rdkit_mol.RemoveAllConformers() + for ii in range(self.get_nframes()): + conf = Conformer() + for idx in range(self.get_natoms()): + conf.SetAtomPosition(idx, self.data["coords"][ii][idx]) + self.rdkit_mol.AddConformer(conf, assignId=True) + return fmtobj.to_bond_order_system(self.rdkit_mol, *args, **kwargs) def __repr__(self): return self.__str__() From 4a808b0cf59ba8b5443608188d1eda89af36ea32 Mon Sep 17 00:00:00 2001 From: Yingze Wang Date: Tue, 24 Aug 2021 18:39:53 +0800 Subject: [PATCH 26/28] Fix bug of SetFormalCharge type error RDKit cannot automatically transfer np.int32 to int --- dpdata/rdkit/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpdata/rdkit/utils.py b/dpdata/rdkit/utils.py index 0dc0a9a31..5cf0df323 100644 --- a/dpdata/rdkit/utils.py +++ b/dpdata/rdkit/utils.py @@ -63,7 +63,7 @@ def system_data_to_mol(data): mol = mol_ed.GetMol() # set formal charges for idx, atom in enumerate(mol.GetAtoms()): - atom.SetFormalCharge(data['formal_charges'][idx]) + atom.SetFormalCharge(int(data['formal_charges'][idx])) # set mol name if '_name' in list(data.keys()): mol.SetProp("_Name", data['_name']) From d6b2d8ad8b73e7f72cdd396d9edff5d9e9f88e3f Mon Sep 17 00:00:00 2001 From: Yingze Wang Date: Tue, 24 Aug 2021 18:40:21 +0800 Subject: [PATCH 27/28] Add ut for to_sdf_file --- tests/test_bond_order_system.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_bond_order_system.py b/tests/test_bond_order_system.py index c0c97a9a1..06928cde2 100644 --- a/tests/test_bond_order_system.py +++ b/tests/test_bond_order_system.py @@ -6,6 +6,7 @@ from rdkit.Chem import AllChem import shutil import numpy as np +from copy import deepcopy class TestBondOrderSystem(unittest.TestCase): @@ -78,6 +79,16 @@ def test_dump_to_deepmd_npy(self): self.assertEqual(syst['bonds'][bond_idx][ii], bonds[bond_idx][ii]) shutil.rmtree("bond_order/methane") + def test_dump_to_sdf_file(self): + s1 = dpdata.BondOrderSystem("bond_order/methane.sdf", fmt="sdf") + s2 = deepcopy(s1) + s2.data["coords"] += 1.0 + s2.to_sdf_file("bond_order/test.sdf") + + nsyst = dpdata.BondOrderSystem("bond_order/test.sdf", fmt="sdf") + self.assertEqual(nsyst["coords"][0, 0, 0] - s1["coords"][0, 0, 0], 1.0) + os.remove("bond_order/test.sdf") + def test_sanitize_mol_obabel(self): cnt = 0 for sdf_file in glob.glob("bond_order/refined-set-ligands/obabel/*sdf"): From c0454c5c293d29c937a877d73c60711ec0f1384c Mon Sep 17 00:00:00 2001 From: Yingze Wang Date: Tue, 24 Aug 2021 18:40:36 +0800 Subject: [PATCH 28/28] Bug fix of dump to deepmd/raw file --- dpdata/bond_order_system.py | 5 +++-- dpdata/plugins/rdkit.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dpdata/bond_order_system.py b/dpdata/bond_order_system.py index f661bf36a..0a43bda5f 100644 --- a/dpdata/bond_order_system.py +++ b/dpdata/bond_order_system.py @@ -102,7 +102,7 @@ def to_fmt_obj(self, fmtobj, *args, **kwargs): for idx in range(self.get_natoms()): conf.SetAtomPosition(idx, self.data["coords"][ii][idx]) self.rdkit_mol.AddConformer(conf, assignId=True) - return fmtobj.to_bond_order_system(self.rdkit_mol, *args, **kwargs) + return fmtobj.to_bond_order_system(self.data, self.rdkit_mol, *args, **kwargs) def __repr__(self): return self.__str__() @@ -158,7 +158,8 @@ def copy(self): self.__class__(data=deepcopy(self.data), rdkit_mol=new_mol) - # def __add__(self, other): + def __add__(self, other): + raise NotImplementedError("magic method '+' has not been implemented on BondOrderSystem") # ''' # magic method "+" operation # ''' diff --git a/dpdata/plugins/rdkit.py b/dpdata/plugins/rdkit.py index 5385027b6..d215bf3c3 100644 --- a/dpdata/plugins/rdkit.py +++ b/dpdata/plugins/rdkit.py @@ -13,7 +13,7 @@ def from_bond_order_system(self, file_name, **kwargs): return rdkit.Chem.MolFromMolFile(file_name, sanitize=False, removeHs=False) - def to_bond_order_system(self, mol, file_name, frame_idx=0, **kwargs): + def to_bond_order_system(self, data, mol, file_name, frame_idx=0, **kwargs): assert (frame_idx < mol.GetNumConformers()) rdkit.Chem.MolToMolFile(mol, file_name, confId=frame_idx) @@ -32,7 +32,7 @@ def from_bond_order_system(self, file_name, **kwargs): mol = mols[0] return mol - def to_bond_order_system(self, mol, file_name, frame_idx=-1, **kwargs): + def to_bond_order_system(self, data, mol, file_name, frame_idx=-1, **kwargs): sdf_writer = rdkit.Chem.SDWriter(file_name) if frame_idx == -1: for ii in range(mol.GetNumConformers()):