Search in sources :

Example 6 with XYZFilter

use of ffx.potential.parsers.XYZFilter 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 7 with XYZFilter

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

the class MainPanel method openInit.

/**
 * Attempts to load the supplied file
 *
 * @param file File to open
 * @param commandDescription Description of the command that created this
 * file.
 * @return a {@link java.lang.Thread} object.
 */
private UIFileOpener openInit(File file, String commandDescription) {
    if (file == null || !file.isFile() || !file.canRead()) {
        return null;
    }
    file = new File(FilenameUtils.normalize(file.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);
    /**
     * Run a Force Field X script.
     */
    if (extension.equalsIgnoreCase("ffx") || extension.equalsIgnoreCase("groovy")) {
        ModelingShell shell = getModelingShell();
        shell.runFFXScript(file);
        boolean shutDown = Boolean.parseBoolean(System.getProperty("ffx.shutDown", "true"));
        if (java.awt.GraphicsEnvironment.isHeadless() && shutDown) {
            exit();
        } else {
            return null;
        }
    }
    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    // Create a Force Field.
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    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);
    SystemFilter systemFilter = null;
    // Decide what parser to use.
    if (xyzFileFilter.acceptDeep(file)) {
        // Use the TINKER Cartesian Coordinate File Parser.
        systemFilter = new XYZFilter(file, newSystem, forceField, properties);
    } else if (intFileFilter.acceptDeep(file)) {
        // Use the TINKER Internal Coordinate File Parser.
        systemFilter = new INTFilter(file, newSystem, forceField, properties);
    } else {
        // Use the PDB File Parser.
        systemFilter = new PDBFilter(file, newSystem, forceField, properties);
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeFilter = systemFilter;
    UIFileOpener fileOpener = new UIFileOpener(systemFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    return fileOpener;
// return new UIFileOpener(systemFilter, this);
}
Also used : CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) ForceFieldFilter(ffx.potential.parsers.ForceFieldFilter) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) ForceField(ffx.potential.parameters.ForceField) SystemFilter(ffx.potential.parsers.SystemFilter) XYZFilter(ffx.potential.parsers.XYZFilter) File(java.io.File) PDBFilter(ffx.potential.parsers.PDBFilter) INTFilter(ffx.potential.parsers.INTFilter)

Aggregations

XYZFilter (ffx.potential.parsers.XYZFilter)7 File (java.io.File)7 PDBFilter (ffx.potential.parsers.PDBFilter)5 ForceField (ffx.potential.parameters.ForceField)4 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)4 ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)3 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)3 INTFilter (ffx.potential.parsers.INTFilter)3 SystemFilter (ffx.potential.parsers.SystemFilter)3 MolecularAssembly (ffx.potential.MolecularAssembly)2 Crystal (ffx.crystal.Crystal)1 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)1 ARCFileFilter (ffx.potential.parsers.ARCFileFilter)1 INTFileFilter (ffx.potential.parsers.INTFileFilter)1 PDBFileFilter (ffx.potential.parsers.PDBFileFilter)1 XYZFileFilter (ffx.potential.parsers.XYZFileFilter)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1