Skip to content

Commit

Permalink
Finish fluctmatch-3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Click committed Oct 14, 2017
2 parents 73ee031 + f584058 commit 6237338
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/fluctmatch/coordinates/COR.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ class CORWriter(CRD.CRDWriter):
# crdtype = "extended"
# fortran_format = "(2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10)"
ATOM_EXT=(
"{serial:10d}{totRes:10d} {resname:<8.8s} {name:<8.8s}""
"{pos[0]:20.10f}{pos[1]:20.10f}{pos[2]:20.10f} ""
"{serial:10d}{totRes:10d} {resname:<8.8s} {name:<8.8s}"
"{pos[0]:20.10f}{pos[1]:20.10f}{pos[2]:20.10f} "
"{chainID:<8.8s} {resSeq:<8d}{tempfactor:20.10f}\n"
),
NUMATOMS_EXT="{0:10d} EXT\n",
# crdtype = "standard"
# fortran_format = "(2I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,A4,F10.5)"
ATOM=(
"{serial:5d}{totRes:5d} {resname:<4.4s} {name:<4.4s}""
"{pos[0]:10.5f}{pos[1]:10.5f}{pos[2]:10.5f} ""
"{serial:5d}{totRes:5d} {resname:<4.4s} {name:<4.4s}"
"{pos[0]:10.5f}{pos[1]:10.5f}{pos[2]:10.5f} "
"{chainID:<4.4s} {resSeq:<4d}{tempfactor:10.5f}\n"
),
TITLE="* FRAME {frame} FROM {where}\n",
Expand Down
26 changes: 16 additions & 10 deletions src/fluctmatch/models/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,24 @@ def _fill_ts(self, other_ts):
residues, viewitems(self._mapping)
)
if self.ts.has_velocities:
self.ts._velocities[:] = [
res.select_atoms(selection).velocities.sum()
for res, (_, selection) in residue_selection
if res.select_atoms(selection)
]
try:
self.ts._velocities[:] = [
res.select_atoms(selection).velocities.sum()
for res, (_, selection) in residue_selection
if res.select_atoms(selection)
]
except ValueError:
pass

if self.ts.has_forces:
self.ts._forces[:] = [
res.select_atoms(selection).forces.sum()
for res, (_, selection) in residue_selection
if res.select_atoms(selection)
]
try:
self.ts._forces[:] = [
res.select_atoms(selection).forces.sum()
for res, (_, selection) in residue_selection
if res.select_atoms(selection)
]
except ValueError:
pass

def _reopen(self):
# Rewind my reference trajectory
Expand Down
27 changes: 25 additions & 2 deletions tests/fluctmatch/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_average_bonds():
universe.bonds.bonds()
for _ in universe.trajectory
], axis=0)
bonds = fmutils.BondStats(universe, func="mean").run().result
(bonds, ) = fmutils.BondStats(universe, func="mean").run().result
testing.assert_allclose(
bonds["r_IJ"],
avg_bonds,
Expand All @@ -67,9 +67,32 @@ def test_bond_fluctuation():
universe.bonds.bonds()
for _ in universe.trajectory
], axis=0)
bonds = fmutils.BondStats(universe, func="std").run().result
(bonds, ) = fmutils.BondStats(universe, func="std").run().result
testing.assert_allclose(
bonds["r_IJ"],
bond_fluct,
err_msg=native_str("Bond fluctuations don't match."),
)


def test_bond_all_stats():
universe = mda.Universe(TPR, XTC)
bond_average = np.mean([
universe.bonds.bonds()
for _ in universe.trajectory
], axis=0)
bond_fluct = np.std([
universe.bonds.bonds()
for _ in universe.trajectory
], axis=0)
(average, std) = fmutils.BondStats(universe, func="both").run().result
testing.assert_allclose(
std["r_IJ"],
bond_fluct,
err_msg=native_str("Bond fluctuations don't match."),
) and testing.assert_allclose(
average["r_IJ"],
bond_fluct,
err_msg=native_str("Bond fluctuations don't match."),
)

1 change: 0 additions & 1 deletion tests/test_fluctmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ def test_main():
runner = CliRunner()
result = runner.invoke(main, [])

assert result.output == "()\n"
assert result.exit_code == 0

0 comments on commit 6237338

Please sign in to comment.