use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.
the class CrystalReciprocalSpaceTest method test1NSFPermanent.
@Test
public void test1NSFPermanent() {
String filename = "ffx/xray/structures/1NSF.pdb";
int index = filename.lastIndexOf(".");
String name = filename.substring(0, index);
// load the structure
ClassLoader cl = this.getClass().getClassLoader();
File structure = new File(cl.getResource(filename).getPath());
// load any properties associated with it
CompositeConfiguration properties = Keyword.loadProperties(structure);
Crystal crystal = new Crystal(115.996, 115.996, 44.13, 90.0, 90.0, 120.0, "P6");
Resolution resolution = new Resolution(1.89631);
ReflectionList reflectionList = new ReflectionList(crystal, resolution);
DiffractionRefinementData refinementData = new DiffractionRefinementData(properties, reflectionList);
ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
ForceField forceField = forceFieldFilter.parse();
// associate molecular assembly with the structure, set up forcefield
MolecularAssembly molecularAssembly = new MolecularAssembly(name);
molecularAssembly.setFile(structure);
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 parallelTeam = new ParallelTeam();
CrystalReciprocalSpace crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam);
crs.computeAtomicDensity(refinementData.fc);
// tests
ComplexNumber b = new ComplexNumber(-496.999, 431.817);
HKL hkl = reflectionList.getHKL(1, 9, 4);
ComplexNumber a = refinementData.getFc(hkl.index());
System.out.println("1 9 4: " + a.toString() + " | " + b.toString() + " | " + a.divides(b).toString());
assertEquals("1 9 4 reflection should be correct", -493.7799429881329, a.re(), 0.0001);
assertEquals("1 9 4 reflection should be correct", 460.7022632345927, a.im(), 0.0001);
b.re(-129.767);
b.im(-76.9812);
hkl = reflectionList.getHKL(5, 26, 8);
a = refinementData.getFc(hkl.index());
System.out.println("5 26 8: " + a.toString() + " | " + b.toString() + " | " + a.divides(b).toString());
assertEquals("5 26 8 reflection should be correct", -123.05535567943377, a.re(), 0.0001);
assertEquals("5 26 8 reflection should be correct", -74.59007322382718, a.im(), 0.0001);
}
use of ffx.potential.parsers.PDBFilter 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));
}
}
use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.
the class PotentialsUtils method saveAsSIFTPDB.
public void saveAsSIFTPDB(MolecularAssembly[] assemblies, File file, String[] resAndScore) {
if (assemblies == null) {
logger.info(" Assembly to save was null.");
} else if (file == null) {
logger.info(" No valid file provided to save assembly to.");
} else if (resAndScore == null) {
logger.info(" Res and score array was null.");
} else {
PDBFilter pdbFilter = new PDBFilter(file, Arrays.asList(assemblies), null, null);
pdbFilter.writeSIFTFile(file, false, resAndScore);
lastFilter = pdbFilter;
}
}
Aggregations