Skip to content

Commit

Permalink
Merge pull request #1843 from peastman/tests
Browse files Browse the repository at this point in the history
Fixed tests on Windows
  • Loading branch information
Bharath Ramsundar committed May 5, 2020
2 parents 4fed7c2 + 8c69efe commit f53936c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions deepchem/molnet/tests/test_molnet.py
Expand Up @@ -36,7 +36,7 @@ def test_delaney_graphconvreg(self):
split=split,
out_path=out_path,
reload=False)
with open(os.path.join(out_path, 'results.csv'), 'r') as f:
with open(os.path.join(out_path, 'results.csv'), newline='\n') as f:
reader = csv.reader(f)
for lastrow in reader:
pass
Expand All @@ -59,7 +59,7 @@ def test_qm7_multitask(self):
split=split,
out_path=out_path,
reload=False)
with open(os.path.join(out_path, 'results.csv'), 'r') as f:
with open(os.path.join(out_path, 'results.csv'), newline='\n') as f:
reader = csv.reader(f)
for lastrow in reader:
pass
Expand All @@ -82,7 +82,7 @@ def test_clintox_multitask(self):
out_path=out_path,
test=True,
reload=False)
with open(os.path.join(out_path, 'results.csv'), 'r') as f:
with open(os.path.join(out_path, 'results.csv'), newline='\n') as f:
reader = csv.reader(f)
for lastrow in reader:
pass
Expand Down
31 changes: 15 additions & 16 deletions deepchem/utils/test/test_rdkit_util.py
Expand Up @@ -72,45 +72,44 @@ def test_write_molecule(self):
xyz, mol = rdkit_util.load_molecule(
ligand_file, calc_charges=False, add_hydrogens=False)

outfile = "/tmp/mol.sdf"
rdkit_util.write_molecule(mol, outfile)
with tempfile.TemporaryDirectory() as tmp:
outfile = os.path.join(tmp, "mol.sdf")
rdkit_util.write_molecule(mol, outfile)

xyz, mol2 = rdkit_util.load_molecule(
outfile, calc_charges=False, add_hydrogens=False)
xyz, mol2 = rdkit_util.load_molecule(
outfile, calc_charges=False, add_hydrogens=False)

assert_equal(mol.GetNumAtoms(), mol2.GetNumAtoms())
for atom_idx in range(mol.GetNumAtoms()):
atom1 = mol.GetAtoms()[atom_idx]
atom2 = mol.GetAtoms()[atom_idx]
assert_equal(atom1.GetAtomicNum(), atom2.GetAtomicNum())
os.remove(outfile)

def test_pdbqt_to_pdb(self):
current_dir = os.path.dirname(os.path.realpath(__file__))
protein_file = os.path.join(current_dir,
"../../dock/tests/1jld_protein.pdb")
xyz, mol = rdkit_util.load_molecule(
protein_file, calc_charges=False, add_hydrogens=False)
out_pdb = "/tmp/mol.pdb"
out_pdbqt = "/tmp/mol.pdbqt"
with tempfile.TemporaryDirectory() as tmp:
out_pdb = os.path.join(tmp, "mol.pdb")
out_pdbqt = os.path.join(tmp, "mol.pdbqt")

rdkit_util.write_molecule(mol, out_pdb)
rdkit_util.write_molecule(mol, out_pdbqt, is_protein=True)
rdkit_util.write_molecule(mol, out_pdb)
rdkit_util.write_molecule(mol, out_pdbqt, is_protein=True)

pdb_block = rdkit_util.pdbqt_to_pdb(out_pdbqt)
from rdkit import Chem
pdb_mol = Chem.MolFromPDBBlock(pdb_block, sanitize=False, removeHs=False)
pdb_block = rdkit_util.pdbqt_to_pdb(out_pdbqt)
from rdkit import Chem
pdb_mol = Chem.MolFromPDBBlock(pdb_block, sanitize=False, removeHs=False)

xyz, pdbqt_mol = rdkit_util.load_molecule(
out_pdbqt, add_hydrogens=False, calc_charges=False)
xyz, pdbqt_mol = rdkit_util.load_molecule(
out_pdbqt, add_hydrogens=False, calc_charges=False)

assert_equal(pdb_mol.GetNumAtoms(), pdbqt_mol.GetNumAtoms())
for atom_idx in range(pdb_mol.GetNumAtoms()):
atom1 = pdb_mol.GetAtoms()[atom_idx]
atom2 = pdbqt_mol.GetAtoms()[atom_idx]
assert_equal(atom1.GetAtomicNum(), atom2.GetAtomicNum())
os.remove(out_pdb)
os.remove(out_pdbqt)

def test_merge_molecules_xyz(self):
current_dir = os.path.dirname(os.path.realpath(__file__))
Expand Down

0 comments on commit f53936c

Please sign in to comment.