Skip to content

Commit

Permalink
More tests passing after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Jun 20, 2017
1 parent 0eab030 commit 7ef3bfa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
4 changes: 1 addition & 3 deletions DockerMakefiles/buildfiles/ambertools/runsander.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ def convert(q, units):
10.0
"""
quantity = q['value'] * ureg(q['units'])
return quantity.m_as(units)


return quantity.value_in(units)


##### helper routines below ######
Expand Down
2 changes: 1 addition & 1 deletion moldesign/_tests/test_atoms_and_bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .test_ambertools_xface import protein_default_amber_forcefield, pdb1yu8
from .molecule_fixtures import h2
from .test_pyscf_xface import h2_rhfwfn
from .test_qm_xfaces import h2_rhfwfn


def test_forcefield_atom_term_access(protein_default_amber_forcefield):
Expand Down
2 changes: 1 addition & 1 deletion moldesign/_tests/test_molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .object_fixtures import *
from .test_ambertools_xface import protein_default_amber_forcefield
from .test_pyscf_xface import h2_rhfwfn
from .test_qm_xfaces import h2_rhfwfn


def test_h2_protected_atom_arrays(h2):
Expand Down
8 changes: 3 additions & 5 deletions moldesign/interfaces/openbabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ def mol_to_pybel(mdtmol):
if atom.residue and atom.residue not in resmap:
obres = obmol.NewResidue()
resmap[atom.residue] = obres
obres.SetChain(str(
mdt.utils.if_not_none(atom.chain.name, 'Z')[0]))
obres.SetName(str(
mdt.utils.if_not_none(atom.residue.pdbname, 'UNL')))
obres.SetNum(mdt.utils.if_not_none(atom.residue.pdbindex, '0'))
obres.SetChain(str(atom.chain.pdbname)[0] if atom.chain.pdbname else 'Z')
obres.SetName(str(atom.residue.pdbname) if atom.residue.pdbname else 'UNL')
obres.SetNum(str(atom.residue.pdbindex) if atom.residue.pdbindex else 0)
else:
obres = resmap[atom.residue]

Expand Down
4 changes: 2 additions & 2 deletions moldesign/models/jsonmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _make_wfn(self, state):
return wfn

@staticmethod
def _json_to_quantities(jsonprops):
def _json_to_quantities(jsonprops): # TODO: handle this within JSON decoder
props = {}
for name, property in jsonprops.items():
if isinstance(property, dict) and len(property) == 2 and \
Expand All @@ -142,7 +142,7 @@ def _make_minimization_job(self, nsteps):
params['runType'] = 'minimization'
if nsteps is not None:
params['minimization_steps'] = 100
inputfiles['params.json'] = json.dumps(dict(params))
inputfiles['params.json'] = mdt.utils.json_dumps(dict(params))

job = pyccc.Job(image=mdt.compute.get_image_path(self.IMAGE),
command='%s && %s' % (self.RUNNER, self.PARSER),
Expand Down
11 changes: 9 additions & 2 deletions moldesign/utils/json_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
from . import args_from


# TODO: defined JSON types that we can serialize directly into MDT objects OR
# use a JSON "pickling" library (only if there's more complexity than covered here already)

class JsonEncoder(json.JSONEncoder):
def default(self, obj):
if hasattr(obj, 'to_json'):
obj = obj.to_json()
return obj
return obj.to_json()
elif hasattr(obj, 'tolist'):
return obj.tolist()
else:
raise TypeError('No seralizer for object "%s" (class: %s)'
% (obj,obj.__class__.__name__))


@args_from(json.dump)
Expand Down

0 comments on commit 7ef3bfa

Please sign in to comment.