You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Class `dpdata.MultiSystems` can read data from a dir which may contains many files of different systems, or from single xyz file which contains different systems.
@@ -206,4 +207,48 @@ s.replace('Hf', 'Zr', 8)
206
207
s.to_vasp_poscar('POSCAR.P42nmc.replace')
207
208
```
208
209
210
+
# BondOrderSystem
211
+
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).
212
+
```python
213
+
import dpdata
214
+
system_1 = dpdata.BondOrderSystem("tests/bond_order/CH3OH.mol", fmt="mol") # read from .mol file
215
+
system_2 = dpdata.BondOrderSystem("tests/bond_order/methane.sdf", fmt="sdf") # read from .sdf file
216
+
```
217
+
In sdf file, all molecules must be of the same topology (i.e. conformers of the same molecular configuration).
218
+
`BondOrderSystem` also supports initialize from a `rdkit.Chem.rdchem.Mol` object directly.
219
+
```python
220
+
from rdkit import Chem
221
+
from rdkit.Chem import AllChem
222
+
import dpdata
223
+
224
+
mol = Chem.MolFromSmiles("CC")
225
+
mol = Chem.AddHs(mol)
226
+
AllChem.EmbedMultipleConfs(mol, 10)
227
+
system = dpdata.BondOrderSystem(rdkit_mol=mol)
228
+
```
229
+
230
+
## Bond Order Assignment
231
+
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).
232
+
+ low: use `rdkit.Chem.SanitizeMol()` function to sanitize molecule.
233
+
+ 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.
234
+
+ 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.**
235
+
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
236
+
`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.
237
+
238
+
```python
239
+
import dpdata
240
+
241
+
for sdf_file in glob.glob("bond_order/refined-set-ligands/obabel/*sdf"):
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
print(syst.get_formal_charges()) # return the formal charge on each atom
251
+
print(syst.get_charge()) # return the total charge of the system
252
+
```
209
253
254
+
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.
0 commit comments