Skip to content

Commit b3839b5

Browse files
committed
feat: add support for reading unit cell dimensions from @<TRIPOS>CRYSIN records in MOL2Parser
1 parent edfa9c3 commit b3839b5

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

package/CHANGELOG

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The rules for this file:
1515

1616
-------------------------------------------------------------------------------
1717
??/??/?? IAlibay, orbeckst, marinegor, tylerjereddy, ljwoods2, marinegor,
18-
spyke7, talagayev
18+
spyke7, talagayev, Dreamstick9
1919

2020
* 2.11.0
2121

@@ -28,6 +28,7 @@ Fixes
2828
to version 5.1.0 (Issue #5145, PR #5146)
2929
* Fixes incorrect assignment of secondary structure to proline residues in
3030
DSSP by porting upstream PyDSSP 0.9.1 fix (Issue #4913)
31+
* MOL2Parser now reads unit cell dimensions from @<TRIPOS>CRYSIN records (Issue #3341)
3132

3233
Enhancements
3334
* Enables parallelization for analysis.diffusionmap.DistanceMatrix
@@ -223,7 +224,6 @@ Fixes
223224
* Fix doctest errors of lib/picklable_file_io.py (Issue #3925, PR #4371)
224225
* Fix deploy action to use the correct version of the pypi upload action.
225226
* Fix groups.py doctests using sphinx directives (Issue #3925, PR #4374)
226-
* MOL2Parser now reads unit cell dimensions from @<TRIPOS>CRYSIN records (Issue #3341)
227227

228228
Enhancements
229229
* Removed type and mass guessing from all topology parsers (PR #3753)

package/MDAnalysis/coordinates/MOL2.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@
6969
* The MDAnalysis :class:`MOL2Reader` and :class:`MOL2Writer` only handle the
7070
MOLECULE, SUBSTRUCTURE, ATOM, and BOND record types. Other records are not
7171
currently read or preserved on writing.
72-
* As the CRYSIN record type is not parsed / written, MOL2 systems always have
73-
dimensions set to ``None`` and dimensionless MOL2 files are written.
72+
* The MDAnalysis :class:`MOL2Reader` now reads unit cell dimensions from the
73+
@<TRIPOS>CRYSIN record. The space group and setting information (the 7th
74+
and 8th fields) are currently ignored. The unit cell is interpreted in the
75+
common crystallographic convention with box vector **a** parallel to the x-axis,
76+
**b** in the xy-plane, and **c** having a positive z-component.
7477
7578
7679
MOL2 format notes
@@ -247,12 +250,9 @@ def _read_frame(self, frame):
247250
except KeyError:
248251
pass
249252
if "crysin" in sections:
250-
try:
251-
line = sections["crysin"][0].strip()
252-
dims = [float(x) for x in line.split()[:6]]
253-
self.ts.dimensions = np.array(dims, dtype=np.float32)
254-
except (ValueError, IndexError):
255-
pass
253+
line = sections["crysin"][0].strip()
254+
dims = [float(x) for x in line.split()[:6]]
255+
self.ts.dimensions = np.array(dims, dtype=np.float32)
256256

257257
self.ts.positions = np.array(coords, dtype=np.float32)
258258

0 commit comments

Comments
 (0)