Skip to content

Commit d965768

Browse files
authored
Merge branch 'master' into unique-atom-names
2 parents 26cfb1e + baefccc commit d965768

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

openforcefield/utils/toolkits.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from functools import wraps
5656
import importlib
5757
import logging
58+
import subprocess
5859

5960
from simtk import unit
6061
import numpy as np
@@ -215,7 +216,7 @@ def from_file(self,
215216
allow_undefined_stereo=False):
216217
"""
217218
Return an openforcefield.topology.Molecule from a file using this toolkit.
218-
219+
219220
Parameters
220221
----------
221222
file_path : str
@@ -240,7 +241,7 @@ def from_file_obj(self,
240241
"""
241242
Return an openforcefield.topology.Molecule from a file-like object (an object with a ".read()" method using this
242243
toolkit.
243-
244+
244245
Parameters
245246
----------
246247
file_obj : file-like object
@@ -1080,25 +1081,25 @@ def from_smiles(self, smiles, hydrogens_are_explicit=False, allow_undefined_ster
10801081

10811082
def generate_conformers(self, molecule, n_conformers=1, clear_existing=True):
10821083
"""
1083-
Generate molecule conformers using OpenEye Omega.
1084+
Generate molecule conformers using OpenEye Omega.
10841085
10851086
.. warning :: This API is experimental and subject to change.
10861087
10871088
.. todo ::
1088-
1089+
10891090
* which parameters should we expose? (or can we implement a general system with **kwargs?)
10901091
* will the coordinates be returned in the OpenFF Molecule's own indexing system? Or is there a chance that
10911092
they'll get reindexed when we convert the input into an OEmol?
1092-
1093+
10931094
Parameters
10941095
---------
1095-
molecule : a :class:`Molecule`
1096+
molecule : a :class:`Molecule`
10961097
The molecule to generate conformers for.
10971098
n_conformers : int, default=1
10981099
The maximum number of conformers to generate.
10991100
clear_existing : bool, default=True
11001101
Whether to overwrite existing conformers for the molecule
1101-
1102+
11021103
"""
11031104
from openeye import oeomega
11041105
oemol = self.to_openeye(molecule)
@@ -1222,7 +1223,7 @@ def compute_partial_charges_am1bcc(self, molecule):
12221223
"""
12231224
Compute AM1BCC partial charges with OpenEye quacpac. This function will attempt to use
12241225
the OEAM1BCCELF10 charge generation method, but may print a warning and fall back to
1225-
normal OEAM1BCC if an error is encountered. This error is known to occur with some
1226+
normal OEAM1BCC if an error is encountered. This error is known to occur with some
12261227
carboxylic acids, and is under investigation by OpenEye.
12271228
12281229
@@ -1780,25 +1781,25 @@ def from_smiles(self, smiles, hydrogens_are_explicit=False, allow_undefined_ster
17801781

17811782
def generate_conformers(self, molecule, n_conformers=1, clear_existing=True):
17821783
"""
1783-
Generate molecule conformers using RDKit.
1784+
Generate molecule conformers using RDKit.
17841785
17851786
.. warning :: This API is experimental and subject to change.
17861787
17871788
.. todo ::
1788-
1789+
17891790
* which parameters should we expose? (or can we implement a general system with **kwargs?)
17901791
* will the coordinates be returned in the OpenFF Molecule's own indexing system? Or is there a chance that they'll get reindexed when we convert the input into an RDMol?
1791-
1792+
17921793
Parameters
17931794
---------
1794-
molecule : a :class:`Molecule`
1795+
molecule : a :class:`Molecule`
17951796
The molecule to generate conformers for.
17961797
n_conformers : int, default=1
17971798
Maximum number of conformers to generate.
17981799
clear_existing : bool, default=True
17991800
Whether to overwrite existing conformers for the molecule.
1800-
1801-
1801+
1802+
18021803
"""
18031804
from rdkit.Chem import AllChem
18041805
rdmol = self.to_rdkit(molecule)
@@ -2743,15 +2744,17 @@ def compute_partial_charges_am1bcc(self, molecule):
27432744
# Compute desired charges
27442745
# TODO: Add error handling if antechamber chokes
27452746
# TODO: Add something cleaner than os.system
2746-
os.system(
2747-
"antechamber -i molecule.sdf -fi sdf -o charged.mol2 -fo mol2 -pf "
2748-
"yes -c bcc -nc {}".format(net_charge))
2747+
subprocess.check_output([
2748+
"antechamber", "-i", "molecule.sdf", "-fi", "sdf", "-o", "charged.mol2", "-fo", "mol2", "-pf", "yes", "-c", "bcc",
2749+
"-nc", str(net_charge)
2750+
])
27492751
#os.system('cat charged.mol2')
27502752

27512753
# Write out just charges
2752-
os.system(
2753-
"antechamber -i charged.mol2 -fi mol2 -o charges2.mol2 -fo mol2 -c wc "
2754-
"-cf charges.txt -pf yes")
2754+
subprocess.check_output([
2755+
"antechamber", "-i", "charged.mol2", "-fi", "mol2", "-o", "charges2.mol2", "-fo", "mol2", "-c", "wc", "-cf",
2756+
"charges.txt", "-pf", "yes"
2757+
])
27552758
#os.system('cat charges.txt')
27562759
# Check to ensure charges were actually produced
27572760
if not os.path.exists('charges.txt'):

0 commit comments

Comments
 (0)