Skip to content

Commit 9ec502e

Browse files
committed
added test for #57
1 parent 43d398f commit 9ec502e

3 files changed

Lines changed: 53 additions & 3 deletions

File tree

gridData/tests/datafiles/1jzv.ccp4

1.95 MB
Binary file not shown.

gridData/tests/datafiles/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
DX = resource_filename(__name__, 'test.dx')
88
CCP4 = resource_filename(__name__, 'test.ccp4')
9+
# from http://www.ebi.ac.uk/pdbe/coordinates/files/1jzv.ccp4
10+
# (see issue #57)
11+
CCP4_1JZV = resource_filename(__name__, '1jzv.ccp4')
912
# water density around M2 TM helices of nAChR from MD simulations
1013
# [O. Beckstein and M. S. P. Sansom. Physical Biology 3(2):147-159, 2006]
1114
gOpenMol = resource_filename(__name__, 'nAChR_M2_water.plt')

gridData/tests/test_ccp4.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,64 @@
11
from __future__ import absolute_import, division
22

3+
import pytest
4+
35
import numpy as np
46
from numpy.testing import (assert_almost_equal,
57
assert_equal)
68

7-
from gridData import Grid
9+
from gridData import Grid, CCP4
810

911
from . import datafiles
1012

11-
def test_ccp4():
12-
g = Grid(datafiles.CCP4)
13+
@pytest.fixture(scope="module")
14+
def g():
15+
return Grid(datafiles.CCP4)
16+
17+
def test_ccp4(g):
1318
POINTS = 192
1419
assert_equal(g.grid.flat, np.arange(1, POINTS+1))
1520
assert_equal(g.grid.size, POINTS)
1621
assert_almost_equal(g.delta, [3./4, .5, 2./3])
1722
assert_equal(g.origin, np.zeros(3))
23+
24+
@pytest.fixture(scope="module")
25+
def ccp4data():
26+
return CCP4.CCP4(datafiles.CCP4_1JZV)
27+
28+
@pytest.mark.parametrize('name,value', [
29+
('nc', 96),
30+
('nr', 76),
31+
('ns', 70),
32+
('mode', 2),
33+
('ncstart', -4),
34+
('nrstart', -23),
35+
('nsstart', 102),
36+
('nx', 84),
37+
('ny', 84),
38+
('nz', 160),
39+
('xlen', 45.79999923706055),
40+
('ylen', 45.79999923706055),
41+
('zlen', 89.6500015258789),
42+
('alpha', 90.0),
43+
('beta', 90.0),
44+
('gamma', 90.0),
45+
('mapc', 2),
46+
('mapr', 1),
47+
('maps', 3),
48+
('amin', -0.9930942058563232),
49+
('amax', 9.050403594970703),
50+
('amean', -0.0005801090155728161),
51+
('ispg', 92),
52+
('nsymbt', 640),
53+
('lskflg', 0),
54+
('bsaflag', '@'),
55+
('skwmat', None),
56+
('skwtrn', None),
57+
('endianness', 'little'),
58+
('arms', 0.4034915268421173),
59+
('nlabl', 1),
60+
('label', ' Map from fft '),
61+
])
62+
def test_ccp4_integer_reading(ccp4data, name, value):
63+
assert_equal(ccp4data.header[name], value)
64+

0 commit comments

Comments
 (0)