Search in sources :

Example 1 with ForceFieldType

use of ffx.potential.parameters.ForceField.ForceFieldType in project ffx by mjschnie.

the class ForceFieldFilter method parse.

private void parse(String input, BufferedReader br) {
    // Split the line on the pound symbol to remove comments.
    input = input.split("#")[0];
    // Split the line into tokens between instances of 1 or more spaces.
    String[] tokens = input.trim().split(" +");
    // Check for the case of no tokens or a Keyword.
    if (tokens == null || parseKeyword(tokens)) {
        return;
    }
    try {
        ForceFieldType type = ForceFieldType.valueOf(tokens[0].toUpperCase());
        switch(type) {
            case ATOM:
                parseAtom(input, tokens);
                break;
            case ANGLE:
                parseAngle(input, tokens);
                break;
            case BIOTYPE:
                parseBioType(input, tokens);
                break;
            case BOND:
                parseBond(input, tokens);
                break;
            case CHARGE:
                parseCharge(input, tokens);
                break;
            case MULTIPOLE:
                parseMultipole(input, tokens, br);
                break;
            case OPBEND:
                parseOPBend(input, tokens);
                break;
            case STRBND:
                parseStrBnd(input, tokens);
                break;
            case PITORS:
                parsePiTorsion(input, tokens);
                break;
            case IMPTORS:
                parseImproper(input, tokens);
                break;
            case TORSION:
                parseTorsion(input, tokens);
                break;
            case TORTORS:
                parseTorsionTorsion(input, tokens, br);
                break;
            case UREYBRAD:
                parseUreyBradley(input, tokens);
                break;
            case VDW:
                parseVDW(input, tokens);
                break;
            case POLARIZE:
                parsePolarize(input, tokens);
                break;
            case RELATIVESOLV:
                parseRelativeSolvation(input, tokens);
                break;
            case ISOLVRAD:
                parseISolvRad(input, tokens);
                break;
            default:
                logger.log(Level.WARNING, "ForceField type recognized, but not stored:{0}", type);
        }
    } catch (Exception e) {
    // DANGER: this serves to skip blank lines in *.patch files but also hid an actual bug's exception
    // String message = "Exception parsing force field parametesr.\n";
    // logger.log(Level.WARNING, message, e);
    }
}
Also used : ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) ForceFieldType(ffx.potential.parameters.ForceField.ForceFieldType) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Example 2 with ForceFieldType

use of ffx.potential.parameters.ForceField.ForceFieldType in project ffx by mjschnie.

the class ForceFieldFilter method parse.

private void parse(CompositeConfiguration properties) {
    try {
        int numConfigs = properties.getNumberOfConfigurations();
        /**
         * Loop over the configurations starting with lowest precedence.
         * This way higher precedence entries will overwrite lower
         * precedence entries within the ForceField instance.
         */
        for (int n = numConfigs - 1; n >= 0; n--) {
            Configuration config = properties.getConfiguration(n);
            Iterator i = config.getKeys();
            while (i.hasNext()) {
                String key = (String) i.next();
                /**
                 * If the key is not recognized as a force field keyword,
                 * continue to the next key.
                 */
                if (!ForceField.isForceFieldKeyword(key)) {
                    continue;
                }
                String[] list = config.getStringArray(key);
                for (String s : list) {
                    // Add back the key to the input line.
                    s = key + " " + s;
                    // Split the line on the pound symbol to remove comments.
                    String input = s.split("#+")[0];
                    String[] tokens = input.trim().split(" +");
                    // Parse keywords.
                    if (parseKeyword(tokens)) {
                        continue;
                    }
                    // Parse force field types.
                    ForceFieldType type;
                    try {
                        type = ForceFieldType.valueOf(key.toUpperCase());
                    } catch (Exception e) {
                        break;
                    }
                    switch(type) {
                        case ATOM:
                            parseAtom(input, tokens);
                            break;
                        case ANGLE:
                            parseAngle(input, tokens);
                            break;
                        case BIOTYPE:
                            parseBioType(input, tokens);
                            break;
                        case BOND:
                            parseBond(input, tokens);
                            break;
                        case CHARGE:
                            parseCharge(input, tokens);
                            break;
                        case MULTIPOLE:
                            parseMultipole(input, tokens);
                            break;
                        case OPBEND:
                            parseOPBend(input, tokens);
                            break;
                        case STRBND:
                            parseStrBnd(input, tokens);
                            break;
                        case PITORS:
                            parsePiTorsion(input, tokens);
                            break;
                        case IMPTORS:
                            parseImproper(input, tokens);
                            break;
                        case TORSION:
                            parseTorsion(input, tokens);
                            break;
                        case TORTORS:
                            parseTorsionTorsion(input, tokens);
                            break;
                        case UREYBRAD:
                            parseUreyBradley(input, tokens);
                            break;
                        case VDW:
                            parseVDW(input, tokens);
                            break;
                        case POLARIZE:
                            parsePolarize(input, tokens);
                            break;
                        case ISOLVRAD:
                            parseISolvRad(input, tokens);
                            break;
                        case RELATIVESOLV:
                            parseRelativeSolvation(input, tokens);
                            break;
                        default:
                            logger.log(Level.WARNING, "ForceField type recognized, but not stored:{0}", type);
                    }
                }
            }
        }
    // forceField.checkPolarizationTypes();
    } catch (Exception e) {
        String message = "Exception parsing force field.";
        logger.log(Level.WARNING, message, e);
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Iterator(java.util.Iterator) ForceFieldString(ffx.potential.parameters.ForceField.ForceFieldString) ForceFieldType(ffx.potential.parameters.ForceField.ForceFieldType) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Aggregations

ForceFieldString (ffx.potential.parameters.ForceField.ForceFieldString)2 ForceFieldType (ffx.potential.parameters.ForceField.ForceFieldType)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 Iterator (java.util.Iterator)1 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)1 Configuration (org.apache.commons.configuration.Configuration)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1