diff --git a/deployment/codeship_runtests.sh b/deployment/codeship_runtests.sh index 2b48142..7fa7dcd 100755 --- a/deployment/codeship_runtests.sh +++ b/deployment/codeship_runtests.sh @@ -5,7 +5,7 @@ set -e VERSION="${TESTENV}.py${PYVERSION}" -PYTESTFLAGS="-n 6 --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=1800" +PYTESTFLAGS="-n 5 --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=1800 --tb=short" if [ "${VERSION}" == "complete.py3" ]; then PYTESTFLAGS="--cov moldesign ${PYTESTFLAGS}" fi diff --git a/moldesign/_tests/test_tools.py b/moldesign/_tests/test_tools.py index d670b9b..e27c279 100644 --- a/moldesign/_tests/test_tools.py +++ b/moldesign/_tests/test_tools.py @@ -50,6 +50,20 @@ def test_ammonium_formal_charge(objkey, request): assert atom.formal_charge == 0 * u.q_e +def test_set_hybridization_and_saturate(): + # Creates just the carbons of ethylene, expects the routine to figure out the rest + atom1 = mdt.Atom(6) + atom2 = mdt.Atom(6) + atom2.x = 1.35 * u.angstrom + atom1.bond_to(atom2, 1) + mol = mdt.Molecule([atom1, atom2]) + newmol = mdt.set_hybridization_and_saturate(mol) + pytest.xfail('This is apparently broken') + assert newmol.num_atoms == 6 + assert newmol.atoms[0].bond_graph[atom1] == 2 + assert len(newmol.get_atoms(atnum=1)) == 4 + + @pytest.fixture def c2_no_hydrogen_from_smiles(): mymol = mdt.from_smiles('[CH0][CH0]') diff --git a/moldesign/fileio.py b/moldesign/fileio.py index 9dd41f0..d3e7ed6 100644 --- a/moldesign/fileio.py +++ b/moldesign/fileio.py @@ -324,6 +324,13 @@ def read_xyz(f): return mdt.Molecule(tempmol.atoms) +def write_xyz(mol, fileobj): + fileobj.write(" %d\n%s\n" % (mol.num_atoms, mol.name)) + for atom in mol.atoms: + x, y, z = atom.position.value_in(mdt.units.angstrom) + fileobj.write("%s %24.14f %24.14f %24.14f\n" % (atom.element, x, y, z)) + + @utils.exports def from_pdb(pdbcode, usecif=False): """ Import the given molecular geometry from PDB.org @@ -442,7 +449,8 @@ def _get_format(filename, format): 'xyz': read_xyz} WRITERS = {'pdb': write_pdb, - 'mmcif': write_mmcif} + 'mmcif': write_mmcif, + 'xyz': write_xyz} if PY2: bzopener = bz2.BZ2File diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..c6846c3 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,6 @@ +[pytest] +testpaths = moldesign/_tests + +markers = + base: tests data structures, molecule construction + slow: heavy duty simulation and numerical tests diff --git a/requirements.txt b/requirements.txt index 0d2611b..29b2964 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ numpy >= 1.12 pathlib2 ; python_version < '3.3' parmed >= 2.7.3 pint >= 0.8 -pyccc >= 0.7.7 +pyccc >= 0.7.9 pyyaml requests scipy