1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# MDAnalysis --- https://www.mdanalysis.org
# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors
# (see the file AUTHORS for the full list of names)
#
# Released under the Lesser GNU Public Licence, v2.1 or any higher version
#
# Please cite your use of MDAnalysis in published work:
#
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
# doi: 10.25080/majora-629e541a-00e
#
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
"""MMTF trajectory reader --- :mod:`MDAnalysis.coordinates.MMTF`
================================================================
Reads coordinates data from the Macromolecular Transmission Format format
(MMTF_). This should generally be a quicker alternative to PDB.
.. versionadded:: 0.16.0
.. versionchanged:: 0.20.0
Unit cell is now properly treated as optional
Classes
-------
.. autoclass:: MMTFReader
:members:
.. _MMTF: https://www.rcsb.org/news/feature/65a1af31c76ca3abcc925d0c
"""
import warnings
import mmtf
from . import base
from ..core.universe import Universe
from ..lib.util import cached, store_init_arguments
from ..due import due, Doi
def _parse_mmtf(fn):
if fn.endswith("gz"):
return mmtf.parse_gzip(fn)
else:
return mmtf.parse(fn)
class MMTFReader(base.SingleFrameReaderBase):
"""Coordinate reader for the Macromolecular Transmission Format format (MMTF_).
.. deprecated:: 2.8.0
The MMTF format is no longer supported / serviced by the
Protein Data Bank. The Reader will be removed in version 3.0.
Users are encouraged to instead use alternative PDB formats.
"""
format = "MMTF"
@store_init_arguments
def __init__(self, filename, convert_units=True, n_atoms=None, **kwargs):
wmsg = (
"The MMTF Reader is deprecated and will be removed in "
"MDAnalysis version 3.0.0"
)
warnings.warn(wmsg, DeprecationWarning)
super(MMTFReader, self).__init__(
filename, convert_units, n_atoms, **kwargs
)
@staticmethod
def _format_hint(thing):
"""Can this Reader read *thing*?
.. versionadded:: 1.0.0
"""
return isinstance(thing, mmtf.MMTFDecoder)
@due.dcite(
Doi("10.1371/journal.pcbi.1005575"),
description="MMTF Reader",
path="MDAnalysis.coordinates.MMTF",
)
def _read_first_frame(self):
# TOOD: Check units?
if isinstance(self.filename, mmtf.MMTFDecoder):
top = self.filename
else:
top = _parse_mmtf(self.filename)
self.n_atoms = top.num_atoms
self.ts = ts = self._Timestep(self.n_atoms, **self._ts_kwargs)
ts._pos[:, 0] = top.x_coord_list
ts._pos[:, 1] = top.y_coord_list
ts._pos[:, 2] = top.z_coord_list
if not top.unit_cell is None:
# optional field
ts.dimensions = top.unit_cell
return ts
|