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

[Update] Check for spacegroup and box angles when reading in CCP4 den… #1

Merged
merged 1 commit into from
Jan 16, 2017
Merged
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
17 changes: 12 additions & 5 deletions powerfit/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ def __init__(self, fid):
self._get_endiannes()
# get the header
self._get_header()
# Symmetry and non-rectangular boxes are not supported.
error = (self.header['ispg'] != 1 or
self.header['alpha'] != self.header['beta'] !=
self.header['gamma'] != 90)
if error:
msg = "Only densities with P1-symmetry in rectangular boxes are supported."
raise ValueError(msg)

# check the order of axis in the file
self._get_order()
# determine the voxelspacing and origin
Expand Down Expand Up @@ -326,8 +334,7 @@ def _get_density(self):
elif mode == 2:
dtype = 'f4'

density = np.fromfile(self.fhandle,
dtype=self._endian + dtype).reshape(self.shape)
density = np.fromfile(self.fhandle, dtype=self._endian + dtype).reshape(self.shape)
if self.order == (1, 3, 2):
self.density = np.swapaxes(self.density, 0, 1)
elif self.order == (2, 1, 3):
Expand Down Expand Up @@ -512,11 +519,11 @@ def _get_header(self):

line = volume.readline()
header['xlength'] = float(line[0:12])
header['ylength'] = float(line[12:24])
header['ylength'] = float(line[12:24])
header['zlength'] = float(line[24:36])
header['alpha'] = float(line[36:48])
header['alpha'] = float(line[36:48])
header['beta'] = float(line[48:60])
header['gamma'] = float(line[60:72])
header['gamma'] = float(line[60:72])

header['order'] = volume.readline()[0:3]

Expand Down