Search in sources :

Example 16 with ParallelTeam

use of edu.rit.pj.ParallelTeam 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));
    }
}
Also used : ParallelTeam(edu.rit.pj.ParallelTeam) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceFieldEnergy(ffx.potential.ForceFieldEnergy) ReflectionList(ffx.crystal.ReflectionList) ForceField(ffx.potential.parameters.ForceField) PDBFilter(ffx.potential.parsers.PDBFilter) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) Atom(ffx.potential.bonded.Atom) PotentialsFileOpener(ffx.potential.utils.PotentialsFileOpener) MolecularAssembly(ffx.potential.MolecularAssembly) CIFFilter(ffx.xray.parsers.CIFFilter) File(java.io.File) MTZFilter(ffx.xray.parsers.MTZFilter) Crystal(ffx.crystal.Crystal) Resolution(ffx.crystal.Resolution)

Aggregations

ParallelTeam (edu.rit.pj.ParallelTeam)16 IOException (java.io.IOException)7 Random (java.util.Random)7 File (java.io.File)5 Crystal (ffx.crystal.Crystal)4 MolecularAssembly (ffx.potential.MolecularAssembly)4 Atom (ffx.potential.bonded.Atom)4 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)4 IntegerForLoop (edu.rit.pj.IntegerForLoop)3 ParallelRegion (edu.rit.pj.ParallelRegion)3 ReflectionList (ffx.crystal.ReflectionList)3 Resolution (ffx.crystal.Resolution)3 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)3 NACorrectionException (ffx.potential.bonded.NACorrectionException)3 HKL (ffx.crystal.HKL)2 ComplexNumber (ffx.numerics.ComplexNumber)2 MultiResidue (ffx.potential.bonded.MultiResidue)2 Residue (ffx.potential.bonded.Residue)2 ForceField (ffx.potential.parameters.ForceField)2 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)2