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;
39
40 import static org.junit.Assert.assertEquals;
41
42 import edu.rit.pj.ParallelTeam;
43 import ffx.algorithms.misc.AlgorithmsTest;
44 import ffx.crystal.Crystal;
45 import ffx.crystal.HKL;
46 import ffx.crystal.ReflectionList;
47 import ffx.crystal.Resolution;
48 import ffx.numerics.math.ComplexNumber;
49 import ffx.potential.ForceFieldEnergy;
50 import ffx.potential.MolecularAssembly;
51 import ffx.potential.bonded.Atom;
52 import ffx.potential.parameters.ForceField;
53 import ffx.potential.parsers.ForceFieldFilter;
54 import ffx.potential.parsers.PDBFilter;
55 import ffx.potential.utils.PotentialsUtils;
56 import ffx.utilities.Keyword;
57
58 import java.io.File;
59 import java.util.List;
60
61 import org.apache.commons.configuration2.CompositeConfiguration;
62 import org.junit.Test;
63
64
65
66
67 public class CrystalReciprocalSpaceTest extends AlgorithmsTest {
68
69
70
71
72 @Test
73 public void test1N7SPermanent() {
74
75 File structure = getResourceFile("1N7S.pdb");
76 PotentialsUtils potutil = new PotentialsUtils();
77 MolecularAssembly mola = potutil.open(structure);
78 CompositeConfiguration properties = mola.getProperties();
79
80 Crystal crystal = new Crystal(39.767, 51.750, 132.938, 90.00, 90.00, 90.00, "P212121");
81 Resolution resolution = new Resolution(1.45);
82
83 ReflectionList reflectionList = new ReflectionList(crystal, resolution);
84 DiffractionRefinementData refinementData =
85 new DiffractionRefinementData(properties, reflectionList);
86
87 mola.finalize(true, mola.getForceField());
88 List<Atom> atomList = mola.getAtomList();
89 Atom[] atomArray = atomList.toArray(new Atom[0]);
90
91
92 ParallelTeam parallelTeam = new ParallelTeam();
93 CrystalReciprocalSpace crs =
94 new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam);
95 crs.computeAtomicDensity(refinementData.fc);
96
97
98 ComplexNumber b = new ComplexNumber(-828.584, -922.704);
99 HKL hkl = reflectionList.getHKL(1, 1, 4);
100 ComplexNumber a = refinementData.getFc(hkl.getIndex());
101
102
103
104
105
106
107 assertEquals("1 1 4 reflection should be correct", -753.5167129023503, a.re(), 0.0001);
108 assertEquals("1 1 4 reflection should be correct", -1012.107931155532, a.im(), 0.0001);
109
110 b.re(-70.4582);
111 b.im(-486.142);
112 hkl = reflectionList.getHKL(2, 1, 10);
113 a = refinementData.getFc(hkl.getIndex());
114
115
116
117
118
119
120 assertEquals("2 1 10 reflection should be correct", -69.38705883664473, a.re(), 0.0001);
121 assertEquals("2 1 10 reflection should be correct", -412.01967983851665, a.im(), 0.0001);
122 }
123
124 @Test
125 public void test1NSFPermanent() {
126
127 String filename = "1NSF.pdb";
128 File structure = getResourceFile(filename);
129
130
131 CompositeConfiguration properties = Keyword.loadProperties(structure);
132 Crystal crystal = new Crystal(115.996, 115.996, 44.13, 90.0, 90.0, 120.0, "P6");
133 Resolution resolution = new Resolution(1.89631);
134
135 ReflectionList reflectionList = new ReflectionList(crystal, resolution);
136 DiffractionRefinementData refinementData =
137 new DiffractionRefinementData(properties, reflectionList);
138
139 ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
140 ForceField forceField = forceFieldFilter.parse();
141
142
143 MolecularAssembly molecularAssembly = new MolecularAssembly(filename);
144 molecularAssembly.setFile(structure);
145 molecularAssembly.setForceField(forceField);
146 PDBFilter pdbFile = new PDBFilter(structure, molecularAssembly, forceField, properties);
147 pdbFile.readFile();
148 pdbFile.applyAtomProperties();
149 molecularAssembly.finalize(true, forceField);
150 ForceFieldEnergy.energyFactory(molecularAssembly);
151
152 List<Atom> atomList = molecularAssembly.getAtomList();
153 Atom[] atomArray = atomList.toArray(new Atom[0]);
154
155
156 ParallelTeam parallelTeam = new ParallelTeam();
157 CrystalReciprocalSpace crs =
158 new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam);
159 crs.computeAtomicDensity(refinementData.fc);
160
161
162 ComplexNumber b = new ComplexNumber(-496.999, 431.817);
163 HKL hkl = reflectionList.getHKL(1, 9, 4);
164 ComplexNumber a = refinementData.getFc(hkl.getIndex());
165
166
167
168
169
170
171 assertEquals("1 9 4 reflection should be correct", -493.71908655557087, a.re(), 0.0001);
172 assertEquals("1 9 4 reflection should be correct", 460.7406135181142, a.im(), 0.0001);
173
174 b.re(-129.767);
175 b.im(-76.9812);
176 hkl = reflectionList.getHKL(5, 26, 8);
177 a = refinementData.getFc(hkl.getIndex());
178
179
180
181
182
183
184 assertEquals("5 26 8 reflection should be correct", -122.99479244281358, a.re(), 0.0001);
185 assertEquals("5 26 8 reflection should be correct", -74.567914170119, a.im(), 0.0001);
186
187 }
188 }