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 assertEquals("1 1 4 reflection should be correct", -753.5793258338429, a.re(), 0.0001);
102 assertEquals("1 1 4 reflection should be correct", -1012.0644582810149, a.im(), 0.0001);
103
104 b.re(-70.4582);
105 b.im(-486.142);
106 hkl = reflectionList.getHKL(2, 1, 10);
107 a = refinementData.getFc(hkl.getIndex());
108 assertEquals("2 1 10 reflection should be correct", -69.31114217592258, a.re(), 0.0001);
109 assertEquals("2 1 10 reflection should be correct", -412.03857890421773, a.im(), 0.0001);
110 }
111
112 @Test
113 public void test1NSFPermanent() {
114
115 String filename = "1NSF.pdb";
116 File structure = getResourceFile(filename);
117
118
119 CompositeConfiguration properties = Keyword.loadProperties(structure);
120 Crystal crystal = new Crystal(115.996, 115.996, 44.13, 90.0, 90.0, 120.0, "P6");
121 Resolution resolution = new Resolution(1.89631);
122
123 ReflectionList reflectionList = new ReflectionList(crystal, resolution);
124 DiffractionRefinementData refinementData =
125 new DiffractionRefinementData(properties, reflectionList);
126
127 ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
128 ForceField forceField = forceFieldFilter.parse();
129
130
131 MolecularAssembly molecularAssembly = new MolecularAssembly(filename);
132 molecularAssembly.setFile(structure);
133 molecularAssembly.setForceField(forceField);
134 PDBFilter pdbFile = new PDBFilter(structure, molecularAssembly, forceField, properties);
135 pdbFile.readFile();
136 pdbFile.applyAtomProperties();
137 molecularAssembly.finalize(true, forceField);
138 ForceFieldEnergy.energyFactory(molecularAssembly);
139
140 List<Atom> atomList = molecularAssembly.getAtomList();
141 Atom[] atomArray = atomList.toArray(new Atom[0]);
142
143
144 ParallelTeam parallelTeam = new ParallelTeam();
145 CrystalReciprocalSpace crs =
146 new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam);
147 crs.computeAtomicDensity(refinementData.fc);
148
149
150 ComplexNumber b = new ComplexNumber(-496.999, 431.817);
151 HKL hkl = reflectionList.getHKL(1, 9, 4);
152 ComplexNumber a = refinementData.getFc(hkl.getIndex());
153
154 assertEquals("1 9 4 reflection should be correct", -493.7187045633783, a.re(), 0.0001);
155 assertEquals("1 9 4 reflection should be correct", 460.7338806590369, a.im(), 0.0001);
156
157 b.re(-129.767);
158 b.im(-76.9812);
159 hkl = reflectionList.getHKL(5, 26, 8);
160 a = refinementData.getFc(hkl.getIndex());
161 assertEquals("5 26 8 reflection should be correct", -122.9964517142246, a.re(), 0.0001);
162 assertEquals("5 26 8 reflection should be correct", -74.56810279849924, a.im(), 0.0001);
163 }
164 }