Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the TPR parser a bit faster #2804

Merged
merged 3 commits into from
Jul 2, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ The rules for this file:

------------------------------------------------------------------------------
??/??/?? richardjgowers, IAlibay, hmacdope, orbeckst, cbouy, lilyminium,
daveminh
daveminh, jbarnoud


* 2.0.0

Expand All @@ -33,6 +34,7 @@ Enhancements
token (Issue #2468, PR #2707)
* Added the `from_smiles` classmethod to the Universe (Issue #2468, PR #2707)
* Added computation of Mean Squared Displacements (#2438, PR #2619)
* Improved performances when parsing TPR files (PR #2804)
* Added converter between Cartesian and Bond-Angle-Torsion coordinates (PR #2668)

Changes
Expand Down
11 changes: 4 additions & 7 deletions package/MDAnalysis/topology/tpr/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ def __init__(self, name, long_name, natoms):
self.natoms = natoms

def process(self, atom_ndx):
while atom_ndx:
# format for all info: (type, [atom1, atom2, ...])
# yield atom_ndx.pop(0), [atom_ndx.pop(0) for i in range(self.natoms)]

# but currently only [atom1, atom2, ...] is interested
atom_ndx.pop(0)
yield [atom_ndx.pop(0) for i in range(self.natoms)]
# The format for all record is (type, atom1, atom2, ...)
# but we are only interested in the atoms.
for cursor in range(0, len(atom_ndx), self.natoms + 1):
yield atom_ndx[cursor + 1: cursor + 1 + self.natoms]