Search in sources :

Example 21 with PDBFilter

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

the class RosenbluthChiAllMove method write.

private void write() {
    if (noSnaps) {
        return;
    }
    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 22 with PDBFilter

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

the class RosenbluthOBMC method writeSnapshot.

private void writeSnapshot(String suffix) {
    if (!writeSnapshots) {
        return;
    }
    String filename = FilenameUtils.removeExtension(mola.getFile().toString()) + "." + suffix + "-" + numMovesProposed;
    if (snapshotInterleaving) {
        filename = mola.getFile().getAbsolutePath();
        if (!filename.contains("dyn")) {
            filename = FilenameUtils.removeExtension(filename) + "_dyn.pdb";
        }
    }
    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 23 with PDBFilter

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

the class AbstractOSRW method setOptimization.

public void setOptimization(boolean osrwOptimization, MolecularAssembly molAss) {
    this.osrwOptimization = osrwOptimization;
    this.molecularAssembly = molAss;
    File file = molecularAssembly.getFile();
    String fileName = FilenameUtils.removeExtension(file.getAbsolutePath());
    String ext = FilenameUtils.getExtension(file.getAbsolutePath());
    if (systemFilter == null) {
        if (ext.toUpperCase().contains("XYZ")) {
            optFile = new File(fileName + "_opt.xyz");
            systemFilter = new XYZFilter(optFile, molecularAssembly, null, null);
        } else {
            optFile = new File(fileName + "_opt.pdb");
            systemFilter = new PDBFilter(optFile, molecularAssembly, null, null);
        }
    }
}
Also used : XYZFilter(ffx.potential.parsers.XYZFilter) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter)

Example 24 with PDBFilter

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

the class MainPanel method openInit.

/**
 * Attempts to load the supplied file
 *
 * @param files Files to open
 * @param commandDescription Description of the command that created this
 * file.
 * @return a {@link java.lang.Thread} object.
 */
private UIFileOpener openInit(List<File> files, String commandDescription) {
    if (files == null) {
        return null;
    }
    File file = new File(FilenameUtils.normalize(files.get(0).getAbsolutePath()));
    // Set the Current Working Directory based on this file.
    setCWD(file.getParentFile());
    // Get "filename" from "filename.extension".
    String name = file.getName();
    String extension = FilenameUtils.getExtension(name);
    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    String[] patches = properties.getStringArray("patch");
    for (String patch : patches) {
        logger.info(" Attempting to read force field patch from " + patch + ".");
        CompositeConfiguration patchConfiguration = new CompositeConfiguration();
        patchConfiguration.addProperty("parameters", patch);
        forceFieldFilter = new ForceFieldFilter(patchConfiguration);
        ForceField patchForceField = forceFieldFilter.parse();
        forceField.append(patchForceField);
        if (RotamerLibrary.addRotPatch(patch)) {
            logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
        }
    }
    newSystem.setForceField(forceField);
    // Decide what parser to use.
    SystemFilter systemFilter = null;
    if (xyzFileFilter.acceptDeep(file)) {
        // Use the TINKER Cartesian Coordinate File Parser.
        systemFilter = new XYZFilter(files, newSystem, forceField, properties);
    } else if (intFileFilter.acceptDeep(file)) {
        // Use the TINKER Internal Coordinate File Parser.
        systemFilter = new INTFilter(files, newSystem, forceField, properties);
    } else {
        // Use the PDB File Parser.
        systemFilter = new PDBFilter(files, newSystem, forceField, properties);
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeFilter = systemFilter;
    // return new UIFileOpener(systemFilter, this);
    UIFileOpener fileOpener = new UIFileOpener(systemFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    return fileOpener;
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceField(ffx.potential.parameters.ForceField) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) SystemFilter(ffx.potential.parsers.SystemFilter) XYZFilter(ffx.potential.parsers.XYZFilter) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter) INTFilter(ffx.potential.parsers.INTFilter)

Example 25 with PDBFilter

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

the class MainPanel method saveAsPDB.

/**
 * Save the currently selected FFXSystem to a PDB file.
 *
 * @param file File to save the system to.
 * @since 1.0
 */
public void saveAsPDB(File file) {
    FFXSystem system = hierarchy.getActive();
    if (system == null) {
        logger.log(Level.INFO, " No active system to save.");
        return;
    }
    if (system.isClosing()) {
        logger.log(Level.INFO, " {0} is being closed and can no longer be saved.", system);
        return;
    }
    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) {
        logger.log(Level.INFO, " No filename is defined for {0}.", system);
        return;
    }
    PDBFilter pdbFilter = new PDBFilter(saveFile, system, null, null);
    if (pdbFilter.writeFile(saveFile, false)) {
        // Refresh Panels with the new System name
        hierarchy.setActive(system);
        activeFilter = pdbFilter;
    } else {
        logger.log(Level.INFO, " Save failed for: {0}", system);
    }
}
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