1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.xray.parsers;
39
40 import static org.junit.Assert.assertEquals;
41 import static org.junit.Assert.assertNotNull;
42 import static org.junit.Assert.assertTrue;
43
44 import ffx.algorithms.misc.AlgorithmsTest;
45 import ffx.crystal.Crystal;
46 import ffx.crystal.HKL;
47 import ffx.crystal.ReflectionList;
48 import ffx.crystal.Resolution;
49 import ffx.utilities.Keyword;
50 import ffx.xray.DiffractionRefinementData;
51
52 import java.io.File;
53
54 import org.apache.commons.configuration2.CompositeConfiguration;
55 import org.junit.Test;
56
57
58
59
60
61
62 public class MTZFilterTest extends AlgorithmsTest {
63
64 private final File mtzFile = getResourceFile("2DRM.mtz");
65
66 private final CompositeConfiguration properties = Keyword.loadProperties(mtzFile);
67
68 private final Crystal crystal = new Crystal(29.97, 37.86, 44.51, 90.28, 90.11, 90.64, "P1");
69 private final Resolution resolution = new Resolution(1.30);
70 private final ReflectionList reflectionList = new ReflectionList(crystal, resolution);
71 private final DiffractionRefinementData refinementData =
72 new DiffractionRefinementData(properties, reflectionList);
73
74 @Test
75 public void testMTZHKL() {
76 MTZFilter mtzFilter = new MTZFilter();
77 assertTrue(
78 "mtz file errors", mtzFilter.readFile(mtzFile, reflectionList, refinementData, null));
79 HKL hkl = reflectionList.getHKL(-10, 1, 1);
80 assertEquals("-10 1 1 FP value", 229.90, refinementData.getF(hkl.getIndex()), 0.02);
81 assertEquals("-10 1 1 SIGFP value", 2.50, refinementData.getSigF(hkl.getIndex()), 0.02);
82 assertEquals("-10 1 1 FREE value", 1, refinementData.getFreeR(hkl.getIndex()));
83 hkl = reflectionList.getHKL(-10, 1, 10);
84 assertEquals(
85 "-10 1 10 FP value should be NaN", Double.NaN, refinementData.getF(hkl.getIndex()), 0.1);
86 assertEquals(
87 "-10 1 10 SIGFP value should be NaN", Double.NaN, refinementData.getSigF(hkl.getIndex()), 0.1);
88 }
89
90 @Test
91 public void testMTZParams() {
92 MTZFilter mtzFilter = new MTZFilter();
93 assertTrue(
94 "mtz file should be read in without errors",
95 mtzFilter.readFile(mtzFile, reflectionList, refinementData, null));
96 assertEquals("mtz file number of columns", 6, mtzFilter.getnColumns());
97 assertEquals("mtz file number of reflections", 48115, mtzFilter.getnReflections());
98 assertEquals("mtz file space group number", 1, mtzFilter.getSpaceGroupNum());
99 }
100
101 @Test
102 public void testMTZReadFile() {
103 MTZFilter mtzFilter = new MTZFilter();
104 assertTrue(
105 "mtz file should be read in without errors",
106 mtzFilter.readFile(mtzFile, reflectionList, refinementData, null));
107 }
108
109 @Test
110 public void testMTZReflectionList() {
111 MTZFilter mtzFilter = new MTZFilter();
112 ReflectionList tmp = mtzFilter.getReflectionList(mtzFile);
113 assertNotNull("mtz file should return a reflection list", tmp);
114 assertEquals("reflection list space group", 1, tmp.spaceGroup.number);
115 assertEquals("reflection list cell dimension", 29.969, tmp.crystal.a, 0.01);
116 assertEquals("reflection list resolution", 1.30, tmp.resolution.resolutionLimit(), 0.01);
117 }
118 }