Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ install:

# command to run tests
script:
- ./testsuite/MDAnalysisTests/mda_nosetests --with-coverage --cover-package MDAnalysis --processes=2 --process-timeout=300 --with-memleak
- ./testsuite/MDAnalysisTests/mda_nosetests --with-coverage --cover-package MDAnalysis --processes=2 --process-timeout=400 --with-memleak
- |
test ${TRAVIS_PULL_REQUEST} == "false" && \
test ${TRAVIS_BRANCH} == ${GH_DOC_BRANCH} && \
Expand Down
46 changes: 29 additions & 17 deletions package/MDAnalysis/analysis/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
import MDAnalysis.lib.qcprot as qcp
from MDAnalysis.exceptions import SelectionError, SelectionWarning
import MDAnalysis.analysis.rms as rms
from MDAnalysis.coordinates.memory import MemoryReader
# remove after rms_fit_trj deprecation over
from MDAnalysis.lib.log import ProgressMeter

Expand Down Expand Up @@ -600,6 +601,7 @@ def rms_fit_trj(
strict=False,
force=True,
quiet=False,
in_memory=False,
**kwargs):
"""RMS-fit trajectory to a reference structure using a selection.

Expand Down Expand Up @@ -652,15 +654,19 @@ def rms_fit_trj(
- ``True``: suppress progress and logging for levels INFO and below.
- ``False``: show all status messages and do not change the the logging
level (default)

*in_memory*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention that this is faster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested the speed very systematically for the alignment, so I've just added ", which can improve performance substantially in some cases".

Default: ``False``
- ``True``: Switch to an in-memory trajectory so that alignment can
be done in-place, which can improve performance substantially in
some cases.

*kwargs*
All other keyword arguments are passed on the trajectory
:class:`~MDAnalysis.coordinates.base.Writer`; this allows manipulating/fixing
trajectories on the fly (e.g. change the output format by changing the extension of *filename*
and setting different parameters as described for the corresponding writer).

:Returns: *filename* (either provided or auto-generated)
:Returns: *filename* (either provided or auto-generated), or None if in_memory=True

.. _ClustalW: http://www.clustal.org/
.. _STAMP: http://www.compbio.dundee.ac.uk/manuals/stamp.4.2/
Expand All @@ -682,19 +688,24 @@ def rms_fit_trj(
logging.disable(logging.WARN)

kwargs.setdefault('remarks', 'RMS fitted trajectory to reference')
if filename is None:
path, fn = os.path.split(frames.filename)
filename = os.path.join(path, prefix + fn)
_Writer = frames.Writer
writer = None
if in_memory or isinstance(traj.trajectory, MemoryReader):
traj.transfer_to_memory()
frames = traj.trajectory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just move the above frames = to below this if block to simplify

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean moving the frames = traj.trajectory line from the first line of the method (line 684) to after the if-block (line 709). If so, this would not work, since the else branch in the if-statement also uses the frames variable. Perhaps I'm misunderstanding what you meant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah my mistake, didn't see that

filename = None
logger.info("Moved trajectory to in-memory representation")
else:
_Writer = frames.OtherWriter
if os.path.exists(filename) and not force:
logger.warn(
"{0} already exists and will NOT be overwritten; use force=True if you want this".format(filename))
return filename
writer = _Writer(filename, **kwargs)
del _Writer

if filename is None:
path, fn = os.path.split(frames.filename)
filename = os.path.join(path, prefix + fn)
_Writer = frames.Writer
else:
_Writer = frames.OtherWriter
if os.path.exists(filename) and not force:
logger.warn("{0} already exists and will NOT be overwritten; use force=True if you want this".format(filename))
return filename
writer = _Writer(filename, **kwargs)
del _Writer
select = rms.process_selection(select)
ref_atoms = reference.select_atoms(*select['reference'])
traj_atoms = traj.select_atoms(*select['mobile'])
Expand Down Expand Up @@ -756,10 +767,11 @@ def rms_fit_trj(
ts.positions[:] = ts.positions * R
ts.positions += ref_com

writer.write(traj.atoms) # write whole input trajectory system
percentage.echo(ts.frame)
if writer is not None:
writer.write(traj.atoms) # write whole input trajectory system
percentage.echo(ts.frame)
logger.info("Wrote %d RMS-fitted coordinate frames to file %r",
frames.n_frames, filename)
frames.n_frames, filename)

if rmsdfile is not None:
np.savetxt(rmsdfile, rmsd)
Expand Down
17 changes: 12 additions & 5 deletions package/MDAnalysis/coordinates/DCD.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,15 @@ def _read_frame(self, frame):
ts.frame = frame
return ts

def timeseries(self, asel, start=None, stop=None, step=None, skip=None,
def timeseries(self, asel=None, start=None, stop=None, step=None, skip=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asel=None should be documented

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed in 5710477.

format='afc'):
"""Return a subset of coordinate data for an AtomGroup

:Arguments:
*asel*
:class:`~MDAnalysis.core.AtomGroup.AtomGroup` object
Defaults to None, in which case the full set of coordinate data
is returned.
*start, stop, step*
A range of the trajectory to access, with start being inclusive
and stop being exclusive.
Expand All @@ -527,12 +529,17 @@ def timeseries(self, asel, start=None, stop=None, step=None, skip=None,
category=DeprecationWarning)

start, stop, step = self.check_slice_indices(start, stop, step)
if len(asel) == 0:
raise NoDataError("Timeseries requires at least one atom to analyze")

if asel is not None:
if len(asel) == 0:
raise NoDataError("Timeseries requires at least one atom to analyze")
atom_numbers = list(asel.indices)
else:
atom_numbers = range(self.n_atoms)

if len(format) != 3 and format not in ['afc', 'acf', 'caf', 'cfa', 'fac', 'fca']:
raise ValueError("Invalid timeseries format")
atom_numbers = list(asel.indices)
# Check if the atom numbers can be grouped for efficiency, then we can read partial buffers
# Check if the atom numbers can be grouped for efficiency, then we can read partial buffers
# from trajectory file instead of an entire timestep
# XXX needs to be implemented
return self._read_timeseries(atom_numbers, start, stop, step, format)
Expand Down
1 change: 1 addition & 0 deletions package/MDAnalysis/coordinates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@
from . import TRZ
from . import XTC
from . import XYZ
from . import memory

try:
from . import DCD
Expand Down
3 changes: 2 additions & 1 deletion package/MDAnalysis/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ def next_as_aux(self, auxname):
--------
:meth:`iter_as_aux`
"""

aux = self._check_for_aux(auxname)
ts = self.ts
# catch up auxiliary if it starts earlier than trajectory
Expand All @@ -1416,7 +1417,7 @@ def next_as_aux(self, auxname):
while self.frame != next_frame or getattr(self, '_frame', 0) == -1:
# iterate trajectory until frame is reached
ts = self.next()
return ts
return ts

def iter_as_aux(self, auxname):
"""Iterate through timesteps for which there is at least one assigned
Expand Down
Loading