Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
782ae65
add BondOrderSystem
Ericwang6 Apr 29, 2021
054e293
add BondOrderSystem
Ericwang6 Apr 29, 2021
9656645
add BondOrderSystem
Ericwang6 Apr 29, 2021
db3f9b9
add BondOrderSystem
Ericwang6 Apr 29, 2021
571fa82
add BondOrderSystem
Ericwang6 Apr 29, 2021
39051fa
Update BondOrderSystem
Ericwang6 Apr 30, 2021
26b6085
solve oveall dependency on rdkit
Ericwang6 May 1, 2021
19d7617
Merge pull request #1 from deepmodeling/devel
Ericwang6 May 2, 2021
e982059
Add dpdata/rdkit package
Ericwang6 May 9, 2021
baee725
Add information on functions
Ericwang6 May 9, 2021
f981fe7
Spelling correction
Ericwang6 May 9, 2021
1a23e7a
Merge branch 'deepmodeling:devel' into devel
Ericwang6 May 9, 2021
4a5f2ab
Merge branch 'deepmodeling:devel' into devel
Ericwang6 May 18, 2021
cb07074
Add bond order assignment
Ericwang6 May 18, 2021
95883e7
Add test cases for bond order assignment
Ericwang6 May 18, 2021
8e7f0bc
Add support for AmberTools sqm/out
Ericwang6 May 18, 2021
3a840a2
Add bond order assignment
Ericwang6 May 18, 2021
77fa374
Add support for AmberTools sqm/out
Ericwang6 May 18, 2021
9b56cdd
Creat __init__.py
Ericwang6 May 18, 2021
9c3d24d
Add rdkit & openbabel environment
Ericwang6 May 18, 2021
e6296d0
Update README.md
Ericwang6 May 18, 2021
eb18eaf
Update test.yml
Ericwang6 May 18, 2021
3876eb3
Remove non user-friendly warnings
Ericwang6 May 19, 2021
2053d11
Update dpdata/rdkit/sanitize.py
Ericwang6 May 19, 2021
64d7e47
Use obabel python interface
Ericwang6 May 19, 2021
3514f7d
Merge branch 'devel' of https://github.com/deepmodeling/dpdata into d…
Ericwang6 May 20, 2021
59daa0d
Merge branch 'deepmodeling-devel' into devel
Ericwang6 May 20, 2021
74788f8
Merge branch 'deepmodeling:devel' into devel
Ericwang6 Jun 13, 2021
c6a92fe
Update README.md
Ericwang6 Jun 13, 2021
8d8b1dc
Merge branch 'deepmodeling:devel' into devel
Ericwang6 Aug 23, 2021
53198b6
Remove dependency on data for MolFormat & SdfFormat
Ericwang6 Aug 24, 2021
d9eae31
Support dump multiple conformers for sdf file
Ericwang6 Aug 24, 2021
4a808b0
Fix bug of SetFormalCharge type error
Ericwang6 Aug 24, 2021
d6b2d8a
Add ut for to_sdf_file
Ericwang6 Aug 24, 2021
c0454c5
Bug fix of dump to deepmd/raw file
Ericwang6 Aug 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.


Expand Down Expand Up @@ -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
"""
Expand Down
10 changes: 9 additions & 1 deletion dpdata/bond_order_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -95,6 +96,12 @@ def from_fmt_obj(self, fmtobj, file_name, **kwargs):
return self

def to_fmt_obj(self, fmtobj, *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.data, self.rdkit_mol, *args, **kwargs)

def __repr__(self):
Expand Down Expand Up @@ -151,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
# '''
Expand Down
10 changes: 5 additions & 5 deletions dpdata/plugins/rdkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, data, mol, file_name, frame_idx=0, **kwargs):
assert (frame_idx < mol.GetNumConformers())
rdkit.Chem.MolToMolFile(mol, file_name, confId=frame_idx)


Expand All @@ -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, data, 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()
2 changes: 1 addition & 1 deletion dpdata/rdkit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
11 changes: 11 additions & 0 deletions tests/test_bond_order_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rdkit.Chem import AllChem
import shutil
import numpy as np
from copy import deepcopy

class TestBondOrderSystem(unittest.TestCase):

Expand Down Expand Up @@ -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):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A similar method test_dump_to_mol_file can be also added here

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"):
Expand Down