Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:MDAnalysis/mdanalysis into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
orbeckst committed Jul 7, 2016
2 parents c11cb74 + 852daec commit 5d78f03
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 34 deletions.
6 changes: 4 additions & 2 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ The rules for this file:
* release numbers follow "Semantic Versioning" http://semver.org

------------------------------------------------------------------------------
??/??/16 kain88-de,jdetle, fiona-naughton, richardjgowers
??/??/16 kain88-de, fiona-naughton, richardjgowers, tyler.je.reddy, jdetle

* 0.15.1

Fixes
* GROWriter resids now truncated properly (Issue #886)
* reading/writing lambda value in trr files (Issue #859)
* fix __iter__/next redundancy (Issue #869)
* SingleFrameReader now raises StopIteration instead of IOError on calling
next (Issue #869)
* Display of Deprecation warnings doesn't affect other modules anymore (Issue #754)

* Changed nframes to n_frames in analysis modules for consistency (Issue #890)

Changes
* Added protected variable _frame_index to to keep track of frame iteration
number in AnalysisBase
Expand Down
8 changes: 4 additions & 4 deletions package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _prepare(self):
self._ref_com = self.ref_atoms.center_of_mass()
self._ref_coordinates = self.ref_atoms.positions - self._ref_com
# allocate the array for selection atom coords
self.rmsd = np.zeros((self.nframes,))
self.rmsd = np.zeros((self.n_frames,))

def _single_frame(self):
index = self._ts.frame
Expand Down Expand Up @@ -717,8 +717,8 @@ def rms_fit_trj(
traj_coordinates = traj_atoms.positions.copy()

# RMSD timeseries
nframes = len(frames)
rmsd = np.zeros((nframes,))
n_frames = len(frames)
rmsd = np.zeros((n_frames,))

# R: rotation matrix that aligns r-r_com, x~-x~com
# (x~: selected coordinates, x: all coordinates)
Expand All @@ -727,7 +727,7 @@ def rms_fit_trj(
R = np.matrix(rot.reshape(3, 3))

percentage = ProgressMeter(
nframes,
n_frames,
interval=10,
quiet=quiet,
format="Fitted frame %(step)5d/%(numsteps)d [%(percentage)5.1f%%] r")
Expand Down
4 changes: 2 additions & 2 deletions package/MDAnalysis/analysis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _setup_frames(self, trajectory, start=None,
self.start = start
self.stop = stop
self.step = step
self.nframes = len(range(start, stop, step))
self.n_frames = len(range(start, stop, step))

def _single_frame(self):
"""Calculate data from a single frame of trajectory
Expand Down Expand Up @@ -99,7 +99,7 @@ def run(self, **kwargs):
self._trajectory[self.start:self.stop:self.step]):
self._frame_index = i
self._ts = ts
# logger.info("--> Doing frame {} of {}".format(i+1, self.nframes))
# logger.info("--> Doing frame {} of {}".format(i+1, self.n_frames))
self._single_frame()
logger.info("Finishing up")
self._conclude()
8 changes: 4 additions & 4 deletions package/MDAnalysis/analysis/lineardensity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- http://www.MDAnalysis.org
# Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein
Expand Down Expand Up @@ -46,7 +46,7 @@ class LinearDensity(AnalysisBase):
binsize : float
Bin width in Angstrom used to build linear density
histograms. Defines the resolution of the resulting density
histograms. Defines the resolution of the resulting density
profile (smaller --> higher resolution) [0.25]
start : int
Expand All @@ -58,7 +58,7 @@ class LinearDensity(AnalysisBase):
Example
-------
First create a LinearDensity object by supplying a selection,
First create a LinearDensity object by supplying a selection,
then use the `run` method:
ldens = LinearDensity(selection)
ldens.run()
Expand Down Expand Up @@ -161,7 +161,7 @@ def _conclude(self):
# Average results over the number of configurations
for dim in ['x', 'y', 'z']:
for key in ['pos', 'pos_std', 'char', 'char_std']:
self.results[dim][key] /= self.nframes
self.results[dim][key] /= self.n_frames
# Compute standard deviation for the error
self.results[dim]['pos_std'] = np.sqrt(self.results[dim]['pos_std']
- np.square(self.results[dim]['pos']))
Expand Down
8 changes: 3 additions & 5 deletions package/MDAnalysis/analysis/polymer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- http://www.MDAnalysis.org
# Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein
Expand Down Expand Up @@ -84,7 +84,7 @@ def _single_frame(self):
# could optimise this by writing a "self dot array"
# we're only using the upper triangle of np.inner
# function would accept a bunch of coordinates and spit out the
# decorrel for that
# decorrel for that
n = len(self._atomgroups[0])

for chain in self._atomgroups:
Expand All @@ -101,7 +101,7 @@ def _conclude(self):
n = len(self._atomgroups[0])

norm = np.linspace(n - 1, 1, n - 1)
norm *= len(self._atomgroups) * self.nframes
norm *= len(self._atomgroups) * self.n_frames

self.results = self._results / norm
self._calc_bond_length()
Expand Down Expand Up @@ -169,5 +169,3 @@ def expfunc(x, a):
a = curve_fit(expfunc, x, y)[0][0]

return a


4 changes: 2 additions & 2 deletions package/MDAnalysis/analysis/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def _conclude(self):
vol *= 4/3.0 * np.pi

# Average number density
box_vol = self.volume / self.nframes
box_vol = self.volume / self.n_frames
density = N / box_vol

rdf = self.count / (density * vol * self.nframes)
rdf = self.count / (density * vol * self.n_frames)

self.rdf = rdf
6 changes: 3 additions & 3 deletions package/MDAnalysis/analysis/rms.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ def run(self, start=None, stop=None, step=None,
rot = None

# RMSD timeseries
nframes = len(np.arange(0, len(trajectory))[start:stop:step])
rmsd = np.zeros((nframes, 3 + len(self.groupselections_atoms)))
n_frames = len(np.arange(0, len(trajectory))[start:stop:step])
rmsd = np.zeros((n_frames, 3 + len(self.groupselections_atoms)))

percentage = ProgressMeter(
nframes, interval=10, format="RMSD %(rmsd)5.2f A at frame "
n_frames, interval=10, format="RMSD %(rmsd)5.2f A at frame "
"%(step)5d/%(numsteps)d [%(percentage)5.1f%%]\r")

for k, ts in enumerate(trajectory[start:stop:step]):
Expand Down
5 changes: 3 additions & 2 deletions package/MDAnalysis/coordinates/GRO.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,10 @@ def write(self, selection, frame=None):
# Atom descriptions and coords
for atom_index, atom in enumerate(atoms):
truncated_atom_index = int(str(atom_index + 1)[-5:])
truncated_resid = int(str(atom.resid)[:5])
if has_velocities:
output_gro.write(self.fmt['xyz_v'].format(
resid=atom.resid,
resid=truncated_resid,
resname=atom.resname,
index=truncated_atom_index,
name=atom.name,
Expand All @@ -308,7 +309,7 @@ def write(self, selection, frame=None):
))
else:
output_gro.write(self.fmt['xyz'].format(
resid=atom.resid,
resid=truncated_resid,
resname=atom.resname,
index=truncated_atom_index,
name=atom.name,
Expand Down
8 changes: 4 additions & 4 deletions testsuite/MDAnalysisTests/analysis/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ def tearDown(self):

def test_default(self):
an = FrameAnalysis(self.u.trajectory)
assert_(an.nframes == len(self.u.trajectory))
assert_(an.n_frames == len(self.u.trajectory))

an.run()
assert_(an.frames == list(range(len(self.u.trajectory))))

def test_start(self):
an = FrameAnalysis(self.u.trajectory, start=20)
assert_(an.nframes == len(self.u.trajectory) - 20)
assert_(an.n_frames == len(self.u.trajectory) - 20)

an.run()
assert_(an.frames == list(range(20, len(self.u.trajectory))))

def test_stop(self):
an = FrameAnalysis(self.u.trajectory, stop=20)
assert_(an.nframes == 20)
assert_(an.n_frames == 20)

an.run()
assert_(an.frames == list(range(20)))

def test_step(self):
an = FrameAnalysis(self.u.trajectory, step=20)
assert_(an.nframes == 5)
assert_(an.n_frames == 5)

an.run()
assert_(an.frames == list(range(98))[::20])
39 changes: 33 additions & 6 deletions testsuite/MDAnalysisTests/coordinates/test_gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,18 @@ def test_check_coordinate_limits_max_noconversion(self):


class TestGROWriterLarge(TestCase, tempdir.TempDir):
def setUp(self):
self.tmpdir = tempdir.TempDir()
self.large_universe = mda.Universe(GRO_large)

def tearDown(self):
del self.tmpdir
del self.large_universe
# not normally recommended to use class-level
# setup for universe (special case here)
@classmethod
def setUpClass(cls):
cls.tmpdir = tempdir.TempDir()
cls.large_universe = mda.Universe(GRO_large)

@classmethod
def tearDownClass(cls):
del cls.tmpdir
del cls.large_universe

@dec.slow
@attr('issue')
Expand All @@ -284,6 +289,28 @@ def test_writer_large(self):
err_msg="Writing GRO file with > 100 000 "
"coords does not truncate properly.")

@dec.slow
@attr('issue')
def test_writer_large_residue_count(self):
"""Ensure large residue number truncation for
GRO files (Issue 886)."""
outfile = os.path.join(self.tmpdir.name, 'outfile2.gro')
target_resname = self.large_universe.residues[-1].resname
resid_value = 999999999999999999999
self.large_universe.residues[-1].atoms.resids = resid_value
self.large_universe.atoms.write(outfile)
with open(outfile, 'rt') as mda_output:
output_lines = mda_output.readlines()
produced_resid = output_lines[-2].split(target_resname)[0]
expected_resid = str(resid_value)[:5]
assert_equal(produced_resid,
expected_resid,
err_msg="Writing GRO file with > 99 999 "
"resids does not truncate properly.")




class TestGROWriterVels(object):
def setUp(self):
self.tmpdir = tempdir.TempDir()
Expand Down

0 comments on commit 5d78f03

Please sign in to comment.