Search in sources :

Example 6 with PDBFilter

use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.

the class PhDiscount method writeSnapshot.

private void writeSnapshot(String extension) {
    String basename = FilenameUtils.removeExtension(originalFilename);
    String filename;
    if (config.snapshots == Snapshots.INTERLEAVED) {
        if (basename.contains("_dyn")) {
            filename = basename.replace("_dyn", format("_dyn_%d.pdb", ++snapshotIndex));
        } else {
            filename = FilenameUtils.removeExtension(basename) + format("_dyn_%d.pdb", ++snapshotIndex);
        }
    } else {
        if (!extension.startsWith(".")) {
            extension = "." + extension;
        }
        filename = basename + format("_%d", ++snapshotIndex) + extension;
    }
    File file = new File(filename);
    PDBFilter writer = new PDBFilter(file, mola, null, null);
    writer.writeFile(file, false);
}
Also used : File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter)

Example 7 with PDBFilter

use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.

the class RosenbluthCBMC method write.

private void write() {
    if (writer == null) {
        writer = new PDBFilter(mola.getFile(), mola, null, null);
    }
    String filename = FilenameUtils.removeExtension(mola.getFile().toString());
    filename = mola.getFile().getAbsolutePath();
    if (!filename.contains("_mc")) {
        filename = FilenameUtils.removeExtension(filename) + "_mc.pdb";
    }
    File file = new File(filename);
    writer.writeFile(file, false);
}
Also used : PDBFilter(ffx.potential.parsers.PDBFilter) File(java.io.File)

Example 8 with PDBFilter

use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.

the class RosenbluthChiAllMove method engage_controlAll.

/**
 * For validation. Performs Monte Carlo chi moves WITHOUT biasing. Give ALL
 * CHIs a random theta simultaneously. Accept on the vanilla Metropolis
 * criterion.
 */
private boolean engage_controlAll() {
    report.append(String.format(" Rosenbluth Control Move: %4d  %s\n", moveNumber, target));
    double origEnergy = totalEnergy();
    double[] origChi = RotamerLibrary.measureRotamer(target, false);
    double[] newChi = new double[origChi.length];
    System.arraycopy(origChi, 0, newChi, 0, origChi.length);
    for (int i = 0; i < origChi.length; i++) {
        if (doChi[i]) {
            double theta = rand.nextDouble(360.0) - 180;
            newChi[i] = theta;
        }
    }
    proposedChis = newChi;
    Rotamer newState = createRotamer(target, newChi);
    RotamerLibrary.applyRotamer(target, newState);
    finalEnergy = totalEnergy();
    if (this.finalEnergy < CATASTROPHE_THRESHOLD) {
        report.append("\nWARNING: Multipole catastrophe in CBMC.\n");
        report.append("  Discarding move.\n");
        target.revertState(origState);
        updateAll();
        Wn = -1.0;
        Wo = 1000;
        logger.info(report.toString());
        return false;
    }
    double dU = finalEnergy - origEnergy;
    double criterion = FastMath.exp(-beta * dU);
    double rng = rand.nextDouble();
    report.append(String.format("    move (thetas):    "));
    for (int i = 0; i < newChi.length; i++) {
        report.append(String.format("%7.2f ", newChi[i]));
    }
    report.append(String.format("\n"));
    report.append(String.format("    orig, final, dU:  %.2g %.2g %.2g\n", origEnergy, finalEnergy, dU));
    report.append(String.format("    crit, rng:        %.2g %.2g\n", criterion, rng));
    if (rng < criterion) {
        accepted = true;
        numAccepted++;
        report.append(String.format(" Accepted! %5d    NewEnergy: %.4f    Chi:", numAccepted, finalEnergy));
        for (int k = 0; k < proposedChis.length; k++) {
            report.append(String.format(" %7.2f", proposedChis[k]));
        }
        report.append(String.format("\n"));
        updateAll();
        if (!noSnaps) {
            PDBFilter writer = new PDBFilter(mola.getFile(), mola, null, null);
            String filename = FilenameUtils.removeExtension(mola.getFile().toString());
            filename = mola.getFile().getAbsolutePath();
            if (!filename.contains("_mc")) {
                filename = FilenameUtils.removeExtension(filename) + "_mc.pdb";
            }
            File file = new File(filename);
            writer.writeFile(file, false);
        }
    } else {
        accepted = false;
        report.append(String.format(" Denied.   %5d    NewEnergy: %.4f    Chi:", numAccepted, origEnergy));
        for (int k = 0; k < origChi.length; k++) {
            report.append(String.format(" %7.2f", origChi[k]));
        }
        report.append(String.format("\n"));
        target.revertState(origState);
    }
    updateAll();
    endTime = System.nanoTime();
    double took = (endTime - startTime) * NS_TO_MS;
    if (logTimings) {
        report.append(String.format("   Timing (ms): %.2f", took));
    }
    logger.info(report.toString());
    return accepted;
}
Also used : Rotamer(ffx.potential.bonded.Rotamer) PDBFilter(ffx.potential.parsers.PDBFilter) File(java.io.File)

Example 9 with PDBFilter

use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.

the class SturmMethod method writePDBBackbone.

/**
 * Write out loop coordinates and determine oxygen placement.
 *
 * @param r_n
 * @param r_a
 * @param r_c
 * @param stt_res
 * @param end_res
 * @param molAss
 * @param counter
 * @param writeFile
 *
 * @return the File.
 */
public File writePDBBackbone(double[][] r_n, double[][] r_a, double[][] r_c, int stt_res, int end_res, MolecularAssembly molAss, int counter, boolean writeFile) {
    Polymer[] newChain = molAss.getChains();
    ArrayList<Atom> backBoneAtoms;
    double[] xyz_n = new double[3];
    double[] xyz_a = new double[3];
    double[] xyz_c = new double[3];
    xyz_o[0][0] = 0.0;
    xyz_o[0][1] = 0.0;
    xyz_o[0][2] = 0.0;
    xyz_o[4][0] = 0.0;
    xyz_o[4][1] = 0.0;
    xyz_o[4][2] = 0.0;
    ArrayList<Atom> OAtoms = new ArrayList<>();
    for (int i = stt_res + 1; i < end_res; i++) {
        Residue newResidue = newChain[0].getResidue(i);
        backBoneAtoms = newResidue.getBackboneAtoms();
        for (Atom backBoneAtom : backBoneAtoms) {
            switch(backBoneAtom.getAtomType().name) {
                case "C":
                    xyz_c[0] = r_c[i - stt_res][0];
                    xyz_c[1] = r_c[i - stt_res][1];
                    xyz_c[2] = r_c[i - stt_res][2];
                    backBoneAtom.moveTo(xyz_c);
                    break;
                case "N":
                    xyz_n[0] = r_n[i - stt_res][0];
                    xyz_n[1] = r_n[i - stt_res][1];
                    xyz_n[2] = r_n[i - stt_res][2];
                    backBoneAtom.moveTo(xyz_n);
                    break;
                case "CA":
                    xyz_a[0] = r_a[i - stt_res][0];
                    xyz_a[1] = r_a[i - stt_res][1];
                    xyz_a[2] = r_a[i - stt_res][2];
                    backBoneAtom.moveTo(xyz_a);
                    break;
                case "HA":
                    newResidue.deleteAtom(backBoneAtom);
                    break;
                case "H":
                    newResidue.deleteAtom(backBoneAtom);
                    break;
                case "O":
                    OAtoms.add(backBoneAtom);
                    break;
                default:
                    newResidue.deleteAtom(backBoneAtom);
                    break;
            }
        }
        ArrayList<Atom> sideChainAtoms = newResidue.getSideChainAtoms();
        for (Atom sideChainAtom : sideChainAtoms) {
            newResidue.deleteAtom(sideChainAtom);
        }
    }
    int oCount = 0;
    for (int i = stt_res + 1; i < end_res; i++) {
        Residue newResidue = newChain[0].getResidue(i);
        backBoneAtoms = newResidue.getBackboneAtoms();
        Atom CA = new Atom("CA");
        Atom N = new Atom("N");
        Atom C = new Atom("C");
        Atom O = OAtoms.get(oCount);
        for (Atom backBoneAtom : backBoneAtoms) {
            switch(backBoneAtom.getAtomType().name) {
                case "C":
                    C = backBoneAtom;
                    break;
                case "N":
                    N = backBoneAtom;
                    break;
                case "CA":
                    CA = backBoneAtom;
                    break;
                default:
                    break;
            }
        }
        BondedUtils.intxyz(O, C, 1.2255, CA, 122.4, N, 180, 0);
        xyz_o[i - stt_res][0] = O.getX();
        xyz_o[i - stt_res][1] = O.getY();
        xyz_o[i - stt_res][2] = O.getZ();
        oCount++;
    }
    File file = molAss.getFile();
    /**
     * for (int i = stt_res; i <= end_res; i++) { double[] xyz =
     * molAss.getBackBoneAtoms().get(i).getXYZ(); }
     */
    String filename = FilenameUtils.removeExtension(file.getAbsolutePath());
    if (!filename.contains("_loop")) {
        filename = filename + "_loop";
    }
    File modifiedFile = new File(filename + ".pdb_" + counter);
    PDBFilter modFilter = new PDBFilter(modifiedFile, molAss, null, null);
    if (writeFile) {
        modFilter.writeFile(modifiedFile, true);
    }
    return (modifiedFile);
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter)

Example 10 with PDBFilter

use of ffx.potential.parsers.PDBFilter in project ffx by mjschnie.

the class MainPanel method saveAsPDB.

/**
 * <p>
 * saveAsPDB</p>
 *
 * @param activeSystems an array of {@link ffx.potential.MolecularAssembly}
 * objects.
 * @param file a {@link java.io.File} object.
 */
public void saveAsPDB(MolecularAssembly[] activeSystems, File file) {
    File saveFile = file;
    if (saveFile == null) {
        resetFileChooser();
        fileChooser.setCurrentDirectory(pwd);
        fileChooser.setFileFilter(pdbFileFilter);
        fileChooser.setAcceptAllFileFilterUsed(false);
        int result = fileChooser.showSaveDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) {
            saveFile = fileChooser.getSelectedFile();
            pwd = saveFile.getParentFile();
        }
    }
    if (saveFile != null) {
        PDBFilter pdbFilter = new PDBFilter(saveFile, Arrays.asList(activeSystems), null, null);
        pdbFilter.writeFile(saveFile, false);
        activeFilter = pdbFilter;
    }
}
Also used : File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter)

Aggregations

PDBFilter (ffx.potential.parsers.PDBFilter)33 File (java.io.File)29 IOException (java.io.IOException)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 ForceField (ffx.potential.parameters.ForceField)6 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)6 Atom (ffx.potential.bonded.Atom)5 XYZFilter (ffx.potential.parsers.XYZFilter)5 Crystal (ffx.crystal.Crystal)4 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)4 MolecularAssembly (ffx.potential.MolecularAssembly)4 Rotamer (ffx.potential.bonded.Rotamer)4 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)4 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 MultiResidue (ffx.potential.bonded.MultiResidue)3 NACorrectionException (ffx.potential.bonded.NACorrectionException)3 Residue (ffx.potential.bonded.Residue)3 ResidueState (ffx.potential.bonded.ResidueState)3 INTFilter (ffx.potential.parsers.INTFilter)3