use of ffx.crystal.Resolution in project ffx by mjschnie.
the class CIFFilterTest method testCIFFilter2DRM.
@Test
public void testCIFFilter2DRM() {
String filename = "ffx/xray/structures/2DRM.cif";
ClassLoader cl = this.getClass().getClassLoader();
File cifFile = new File(cl.getResource(filename).getPath());
// load any properties associated with it
CompositeConfiguration properties = Keyword.loadProperties(cifFile);
CIFFilter cifFilter = new CIFFilter();
ReflectionList reflectionList = cifFilter.getReflectionList(cifFile);
assertNull(" Reflection list should be null", reflectionList);
Crystal crystal = new Crystal(29.969, 37.861, 44.506, 90.28, 90.11, 90.64, "P1");
Resolution resolution = new Resolution(1.30);
reflectionList = new ReflectionList(crystal, resolution);
DiffractionRefinementData refinementData = new DiffractionRefinementData(properties, reflectionList);
assertTrue(" CIF data not read correctly", cifFilter.readFile(cifFile, reflectionList, refinementData, properties));
HKL hkl = reflectionList.getHKL(-21, -6, 7);
assertEquals("-21 -6 7 F", 18.6, refinementData.getF(hkl.index()), 0.01);
assertEquals("-21 -6 7 sigF", 3.6, refinementData.getSigF(hkl.index()), 0.01);
assertEquals("-21 -6 7 freeR value", 0, refinementData.freer[hkl.index()]);
hkl = reflectionList.getHKL(-21, -6, 8);
assertEquals("-21 -6 7 F", 20.2, refinementData.getF(hkl.index()), 0.01);
assertEquals("-21 -6 7 sigF", 5.0, refinementData.getSigF(hkl.index()), 0.01);
assertEquals("-21 -6 7 freeR value", 1, refinementData.freer[hkl.index()]);
}
use of ffx.crystal.Resolution in project ffx by mjschnie.
the class TimerTest method main.
public static void main(String[] args) {
// Parameters collection from original Timer script
String pdbname = System.getProperty("pdbFile", "1N7S.pdb");
String mtzname = System.getProperty("mtzFile", null);
String cifname = System.getProperty("cifFile", null);
final boolean ciOnly = false;
final String info = "SNARE complex";
final double r = 19.412671496011;
final double rfree = 21.555930987573;
final double sigmaA = 0.9336853524690557;
final double sigmaW = 0.13192537249786418;
boolean ci = System.getProperty("ffx.ci", "false").equalsIgnoreCase("true");
if (!ci && ciOnly) {
crystalStats = null;
return;
}
int index = pdbname.lastIndexOf(".");
String name = pdbname.substring(0, index);
// load the structure
MolecularAssembly molecularAssembly;
File structure, mtzFile, cifFile;
structure = new File(pdbname);
PotentialsFileOpener opener = new PotentialsFileOpener(structure);
opener.run();
molecularAssembly = opener.getAssembly();
mtzFile = new File(mtzname);
cifFile = new File(cifname);
// load any properties associated with it
CompositeConfiguration properties = Keyword.loadProperties(structure);
// read in Fo/sigFo/FreeR
MTZFilter mtzFilter = new MTZFilter();
CIFFilter cifFilter = new CIFFilter();
Crystal crystal = Crystal.checkProperties(properties);
Resolution resolution = Resolution.checkProperties(properties);
if (crystal == null || resolution == null) {
if (mtzname != null) {
reflectionList = mtzFilter.getReflectionList(mtzFile);
} else {
reflectionList = cifFilter.getReflectionList(cifFile);
}
} else {
reflectionList = new ReflectionList(crystal, resolution);
}
refinementData = new DiffractionRefinementData(properties, reflectionList);
if (mtzname != null) {
// assertTrue(info + " mtz file should be read in without errors",
// mtzFilter.readFile(mtzFile, reflectionList, refinementData,
// properties));
} else {
// assertTrue(info + " cif file should be read in without errors",
// cifFilter.readFile(cifFile, reflectionList, refinementData,
// properties));
}
ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
ForceField forceField = forceFieldFilter.parse();
// associate molecular assembly with the structure, set up forcefield
molecularAssembly.setForceField(forceField);
PDBFilter pdbFile = new PDBFilter(structure, molecularAssembly, forceField, properties);
pdbFile.readFile();
pdbFile.applyAtomProperties();
molecularAssembly.finalize(true, forceField);
ForceFieldEnergy energy = ForceFieldEnergy.energyFactory(molecularAssembly, pdbFile.getCoordRestraints());
List<Atom> atomList = molecularAssembly.getAtomList();
Atom[] atomArray = atomList.toArray(new Atom[atomList.size()]);
// set up FFT and run it
parallelTeam = new ParallelTeam();
CrystalReciprocalSpace crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam, false);
crs.computeDensity(refinementData.fc);
refinementData.setCrystalReciprocalSpace_fc(crs);
crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam, true);
crs.computeDensity(refinementData.fs);
refinementData.setCrystalReciprocalSpace_fs(crs);
ScaleBulkMinimize scaleBulkMinimize = new ScaleBulkMinimize(reflectionList, refinementData, crs, parallelTeam);
scaleBulkMinimize.minimize(6, 1.0e-4);
SigmaAMinimize sigmaAMinimize = new SigmaAMinimize(reflectionList, refinementData, parallelTeam);
sigmaAMinimize.minimize(7, 2.0e-2);
SplineMinimize splineMinimize = new SplineMinimize(reflectionList, refinementData, refinementData.spline, SplineEnergy.Type.FOFC);
splineMinimize.minimize(7, 1e-5);
crystalStats = new CrystalStats(reflectionList, refinementData);
scaleBulkMinimize = new ScaleBulkMinimize(reflectionList, refinementData, refinementData.crs_fs, parallelTeam);
ScaleBulkEnergy scaleBulkEnergy = scaleBulkMinimize.getScaleBulkEnergy();
int n = scaleBulkMinimize.getNumberOfVariables();
double[] x = new double[n];
double[] g = new double[n];
scaleBulkMinimize.getCoordinates(x);
scaleBulkEnergy.energyAndGradient(x, g);
double delta = 1.0e-4;
double tolerance = 1.0e-4;
logger.info(String.format("SCATTER TEST"));
for (int i = 0; i < 30; i++) {
long time = -System.nanoTime();
scaleBulkEnergy.energyAndGradient(x, g);
time += System.nanoTime();
logger.info(String.format(" Time %12.8f", time * 1.0e-9));
}
}
Aggregations