Skip to content

fixed Issue #2001 - support for Tinker periodic boundary box#2011

Merged
richardjgowers merged 7 commits intoMDAnalysis:developfrom
micaela-matta:issue-2001
Aug 6, 2018
Merged

fixed Issue #2001 - support for Tinker periodic boundary box#2011
richardjgowers merged 7 commits intoMDAnalysis:developfrom
micaela-matta:issue-2001

Conversation

@micaela-matta
Copy link
Contributor

Fixes #2001

Changes made in this Pull Request:

  • TXYZ now reads box information when present

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Copy link
Member

@kain88-de kain88-de left a comment

Choose a reason for hiding this comment

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

Thank you for the fix. There are some minor issues with the comments. It would be nice if you can address them.

names = np.zeros(natoms, dtype=object)
types = np.zeros(natoms, dtype=np.int)
bonds = []
#Checks whether file contains periodic boundary box info
Copy link
Member

Choose a reason for hiding this comment

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

The comment would be better if it explains why this works. Currently, it only explains what the code does. So something along the lines of

PBC box information is stored optionally in tinker files at the beginning of a frame. The box is stored as (x, y, z, alpha, beta, gamma). If not box information is stored the second value (space separated) is an atom name. To detect if a box is stored we, therefore, need to check if the second value can be converted to float. This assumes there are no pure numerical atom names.

it is longer but much better understandable for a maintainer later/

@@ -43,6 +43,7 @@
"""

from __future__ import absolute_import
Copy link
Member

Choose a reason for hiding this comment

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

Since you now use zip we also need to import the iterating zip from six. Please add the line from six.moves import zip below the future import.

self.xyzfile = util.anyopen(self.filename)
self._cache = dict()

with util.openany(self.filename) as inp:
Copy link
Member

Choose a reason for hiding this comment

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

also add a comment here why the code works.

fline = inf.readline()
try:
float(fline.split()[1])
except:
Copy link
Member

Choose a reason for hiding this comment

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

expect ValueError

"XYZ", "XYZ_psf", "XYZ_bz2",
"XYZ_mini", "XYZ_five", # 3 and 5 atoms xyzs for an easy topology
"TXYZ", "ARC", # Tinker files
"TXYZ", "ARC", "ARC_PDB", # Tinker files
Copy link
Member

Choose a reason for hiding this comment

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

it's called ARC_PDB here but ARC_PBC everywhere else

@jbarnoud jbarnoud mentioned this pull request Aug 3, 2018
4 tasks
@orbeckst
Copy link
Member

orbeckst commented Aug 3, 2018

There's not __future__.zip:

 from __future__ import absolute_import, zip

Makes Travis unhappy.

@kain88-de
Copy link
Member

kain88-de commented Aug 4, 2018 via email

@codecov
Copy link

codecov bot commented Aug 5, 2018

Codecov Report

Merging #2011 into develop will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2011      +/-   ##
===========================================
+ Coverage     88.5%   88.59%   +0.08%     
===========================================
  Files          143      143              
  Lines        17249    17305      +56     
  Branches      2646     2649       +3     
===========================================
+ Hits         15266    15331      +65     
+ Misses        1385     1376       -9     
  Partials       598      598
Impacted Files Coverage Δ
package/MDAnalysis/topology/TXYZParser.py 100% <100%> (ø) ⬆️
package/MDAnalysis/coordinates/TXYZ.py 90% <100%> (+9.23%) ⬆️
package/MDAnalysis/lib/NeighborSearch.py 85.29% <0%> (-0.82%) ⬇️
package/MDAnalysis/transformations/rotate.py 100% <0%> (ø) ⬆️
package/MDAnalysis/lib/transformations.py 78.62% <0%> (+0.14%) ⬆️
package/MDAnalysis/core/selection.py 99.36% <0%> (+0.14%) ⬆️
package/MDAnalysis/lib/util.py 86.86% <0%> (+0.33%) ⬆️
package/MDAnalysis/lib/distances.py 87.63% <0%> (+0.41%) ⬆️
package/MDAnalysis/lib/pkdtree.py 94.36% <0%> (+1.86%) ⬆️
package/MDAnalysis/topology/guessers.py 100% <0%> (+1.86%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 461aadf...2112951. Read the comment docs.

@richardjgowers richardjgowers self-assigned this Aug 5, 2018
# Can't infinitely read as XYZ files can be multiframe
for i in range(natoms):
line = inf.readline().split()
for i, line in zip(range(natoms), itertools.chain([fline], inf)):
Copy link
Member

Choose a reason for hiding this comment

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

The linter was complaining about this line because it thought we weren't iterating the range, but we are, so I changed the linter RC file.

@richardjgowers richardjgowers dismissed kain88-de’s stale review August 6, 2018 13:24

Comments addressed

@richardjgowers richardjgowers merged commit bf03cd4 into MDAnalysis:develop Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants