Search in sources :

Example 86 with Residue

use of ffx.potential.bonded.Residue in project ffx by mjschnie.

the class PhMD method tryCBMCStep.

private boolean tryCBMCStep(MultiResidue targetMulti) {
    if (CAUTIOUS) {
        throw new UnsupportedOperationException();
    }
    List<Residue> targets = new ArrayList<>();
    targets.add(targetMulti.getActive());
    // cost still scales with this, unfortunately
    int trialSetSize = 5;
    // irrelevant for manual step call
    int mcFrequency = 1;
    boolean writeSnapshots = false;
    System.setProperty("cbmc-type", "CHEAP");
    RosenbluthCBMC cbmc = new RosenbluthCBMC(mola, mola.getPotentialEnergy(), null, targets, mcFrequency, trialSetSize, writeSnapshots);
    boolean accepted = cbmc.cbmcStep();
    if (config.logTimings) {
        long took = System.nanoTime() - startTime;
        logger.info(String.format(" CBMC time: %1.3f", took * NS_TO_SEC));
    }
    return accepted;
}
Also used : RosenbluthCBMC(ffx.algorithms.mc.RosenbluthCBMC) TitrationUtils.inactivateResidue(ffx.potential.extended.TitrationUtils.inactivateResidue) MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) ArrayList(java.util.ArrayList)

Example 87 with Residue

use of ffx.potential.bonded.Residue in project ffx by mjschnie.

the class PhMD method recursiveMap.

/**
 * Finds Titration definitions for the given Residue and adds them to the given MultiResidue.
 * For three-state transitions, simply populate the enumeration with multiple titrations
 * from a shared state and this will include them in MultiResidue construction.
 */
private void recursiveMap(Residue member, MultiResidue multiRes) {
    // Map titrations for this member.
    Titration[] titrations = Titration.multiLookup(member);
    titrationMap.put(member, Arrays.asList(titrations));
    // For each titration, check whether it needs added as a MultiResidue option.
    for (Titration titration : titrations) {
        // Allow manual override of Histidine treatment.
        if ((titration.deprotForm == AminoAcid3.HID && config.histidineMode == HistidineMode.HIE_ONLY) || (titration.deprotForm == AminoAcid3.HIE && config.histidineMode == HistidineMode.HID_ONLY)) {
            continue;
        }
        // Find all the choices currently available to this MultiResidue.
        List<AminoAcid3> choices = new ArrayList<>();
        for (Residue choice : multiRes.getConsideredResidues()) {
            choices.add(choice.getAminoAcid3());
        }
        // If this Titration target is not a choice for the MultiResidue, then add it.
        if (!choices.contains(titration.protForm) || !(choices.contains(titration.deprotForm))) {
            String targetName = (member.getAminoAcid3() == titration.protForm) ? titration.deprotForm.toString() : titration.protForm.toString();
            int resNumber = member.getResidueNumber();
            ResidueType resType = member.getResidueType();
            Residue newChoice = new Residue(targetName, resNumber, resType);
            multiRes.addResidue(newChoice);
            titrationMap.put(newChoice, Arrays.asList(Titration.multiLookup(newChoice)));
        }
    }
}
Also used : ResidueType(ffx.potential.bonded.Residue.ResidueType) TitrationUtils.inactivateResidue(ffx.potential.extended.TitrationUtils.inactivateResidue) MultiResidue(ffx.potential.bonded.MultiResidue) Residue(ffx.potential.bonded.Residue) AminoAcid3(ffx.potential.bonded.ResidueEnumerations.AminoAcid3) ArrayList(java.util.ArrayList) Titration(ffx.potential.extended.TitrationUtils.Titration) TitrationUtils.performTitration(ffx.potential.extended.TitrationUtils.performTitration)

Example 88 with Residue

use of ffx.potential.bonded.Residue in project ffx by mjschnie.

the class RosenbluthCBMC method controlStep.

public boolean controlStep() {
    double temperature;
    if (thermostat != null) {
        temperature = thermostat.getCurrentTemperature();
    } else {
        temperature = 298.15;
    }
    double beta = 1.0 / (BOLTZMANN * temperature);
    int which = ThreadLocalRandom.current().nextInt(targets.size());
    Residue target = targets.get(which);
    RosenbluthChiAllMove cbmcMove = new RosenbluthChiAllMove(mola, target, -1, ffe, temperature, false, numMovesProposed, true);
    return cbmcMove.wasAccepted();
}
Also used : Residue(ffx.potential.bonded.Residue)

Example 89 with Residue

use of ffx.potential.bonded.Residue in project ffx by mjschnie.

the class RosenbluthCBMC method cbmcStep.

public boolean cbmcStep() {
    numMovesProposed++;
    boolean accepted;
    double temperature;
    if (thermostat != null) {
        temperature = thermostat.getCurrentTemperature();
    } else {
        temperature = 298.15;
    }
    double beta = 1.0 / (BOLTZMANN * temperature);
    // Select a target residue.
    int which = ThreadLocalRandom.current().nextInt(targets.size());
    Residue target = targets.get(which);
    RosenbluthChiAllMove cbmcMove = new RosenbluthChiAllMove(mola, target, trialSetSize, ffe, temperature, writeSnapshots, numMovesProposed, true);
    if (cbmcMove.getMode() == RosenbluthChiAllMove.MODE.CHEAP) {
        if (cbmcMove.wasAccepted()) {
            numMovesAccepted++;
        }
        return cbmcMove.wasAccepted();
    }
    double Wn = cbmcMove.getWn();
    double Wo = cbmcMove.getWo();
    double criterion = Math.min(1, Wn / Wo);
    double rng = ThreadLocalRandom.current().nextDouble();
    logger.info(String.format("    rng:    %5.2f", rng));
    if (rng < criterion) {
        cbmcMove.move();
        numMovesAccepted++;
        logger.info(String.format(" Accepted!  Energy: %.4f\n", cbmcMove.finalEnergy));
        accepted = true;
        write();
    } else {
        logger.info(String.format(" Denied.\n"));
        accepted = false;
    }
    return accepted;
}
Also used : Residue(ffx.potential.bonded.Residue)

Example 90 with Residue

use of ffx.potential.bonded.Residue in project ffx by mjschnie.

the class RosenbluthOBMC method mcStep.

/**
 * Does all the work for a move. Moveset is a continuous 360 degree spin of
 * the chi[0] torsion. U_or in Frenkel's notation (uDep here) is the
 * associated torsion energy. Evaluation criterion: P_accept = Min( 1,
 * (Wn/Wo)*exp(-beta(U[n]-U[o]) )
 */
private boolean mcStep() {
    numMovesProposed++;
    boolean accepted;
    // Select a target residue.
    int which = ThreadLocalRandom.current().nextInt(targets.size());
    Residue target = targets.get(which);
    ResidueState origState = target.storeState();
    List<ROLS> chiList = target.getTorsionList();
    Torsion chi0 = getChiZeroTorsion(target);
    writeSnapshot("orig");
    /* Create old and new trial sets, calculate Wn and Wo, and choose a move bn.
            When doing strictly chi[0] moves, Frenkel/Smit's 'old' and 'new' configurations
            are the same state. The distinction is made here only to aid in future generalization.
         */
    List<MCMove> oldTrialSet = createTrialSet(target, origState, trialSetSize - 1);
    List<MCMove> newTrialSet = createTrialSet(target, origState, trialSetSize);
    report = new StringBuilder();
    report.append(String.format(" Rosenbluth Rotamer MC Move: %4d\n", numMovesProposed));
    report.append(String.format("    residue:   %s\n", target.toString()));
    report.append(String.format("    chi0:      %s\n", chi0.toString()));
    MCMove proposal = calculateRosenbluthFactors(target, chi0, origState, oldTrialSet, origState, newTrialSet);
    /* Calculate the independent portion of the total old-conf energy.
            Then apply the move and calculate the independent total new-conf energy.
         */
    setState(target, origState);
    writeSnapshot("uIndO");
    double uIndO = getTotalEnergy() - getTorsionEnergy(chi0);
    proposal.move();
    writeSnapshot("uIndN");
    double uIndN = getTotalEnergy() - getTorsionEnergy(chi0);
    // Apply acceptance criterion.
    double temperature = thermostat.getCurrentTemperature();
    double beta = 1.0 / (BOLTZMANN * temperature);
    double dInd = uIndN - uIndO;
    double dIndE = FastMath.exp(-beta * dInd);
    double criterion = (Wn / Wo) * FastMath.exp(-beta * (uIndN - uIndO));
    double metropolis = Math.min(1, criterion);
    double rng = ThreadLocalRandom.current().nextDouble();
    report.append(String.format("    theta:     %3.2f\n", ((RosenbluthChi0Move) proposal).theta));
    report.append(String.format("    criterion: %1.4f\n", criterion));
    report.append(String.format("       Wn/Wo:     %.2f\n", Wn / Wo));
    report.append(String.format("       uIndN,O:  %7.2f\t%7.2f\n", uIndN, uIndO));
    report.append(String.format("       dInd(E):  %7.2f\t%7.2f\n", dInd, dIndE));
    report.append(String.format("    rng:       %1.4f\n", rng));
    if (rng < metropolis) {
        numMovesAccepted++;
        report.append(String.format(" Accepted.\n"));
        accepted = true;
    } else {
        proposal.revertMove();
        report.append(String.format(" Denied.\n"));
        accepted = false;
    }
    logger.info(report.toString());
    // Cleanup.
    Wn = 0.0;
    Wo = 0.0;
    return accepted;
}
Also used : ROLS(ffx.potential.bonded.ROLS) Residue(ffx.potential.bonded.Residue) ResidueState(ffx.potential.bonded.ResidueState) Torsion(ffx.potential.bonded.Torsion)

Aggregations

Residue (ffx.potential.bonded.Residue)102 MultiResidue (ffx.potential.bonded.MultiResidue)66 Rotamer (ffx.potential.bonded.Rotamer)44 Atom (ffx.potential.bonded.Atom)41 RotamerLibrary.applyRotamer (ffx.potential.bonded.RotamerLibrary.applyRotamer)39 ArrayList (java.util.ArrayList)30 Polymer (ffx.potential.bonded.Polymer)29 IOException (java.io.IOException)20 Molecule (ffx.potential.bonded.Molecule)13 NACorrectionException (ffx.potential.bonded.NACorrectionException)13 MSNode (ffx.potential.bonded.MSNode)12 ResidueState (ffx.potential.bonded.ResidueState)11 Bond (ffx.potential.bonded.Bond)10 Crystal (ffx.crystal.Crystal)8 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)8 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)8 File (java.io.File)8 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)7 TitrationUtils.inactivateResidue (ffx.potential.extended.TitrationUtils.inactivateResidue)6 BufferedWriter (java.io.BufferedWriter)6