use of ffx.potential.parameters.ForceField.ForceFieldName in project ffx by mjschnie.
the class ForceFieldFilter method parse.
/**
* <p>
* parse</p>
*
* @return a {@link ffx.potential.parameters.ForceField} object.
*/
public ForceField parse() {
try {
if (forceFieldFile != null) {
/**
* Parse an external (ie. not in the FFX jar) parameter file.
*/
if (!forceFieldFile.exists()) {
logger.log(Level.INFO, " {0} does not exist.", forceFieldFile);
return null;
} else if (!forceFieldFile.canRead()) {
logger.log(Level.INFO, " {0} can not be read.", forceFieldFile);
return null;
}
parse(new FileInputStream(forceFieldFile));
} else {
/**
* Parse an internal parameter file and add it to the composite
* configuration.
*/
String forceFieldString = properties.getString("forcefield", "AMOEBA-BIO-2009");
ForceFieldName ff;
try {
ff = ForceField.ForceFieldName.valueOf(forceFieldString.toUpperCase().replace('-', '_'));
logger.info(" Loading force field: " + ff.toString());
} catch (Exception e) {
logger.warning("Defaulting to force field: AMOEBA_BIO_2009");
ff = ForceField.ForceFieldName.AMOEBA_BIO_2009;
}
URL url = ForceField.getForceFieldURL(ff);
if (url != null) {
forceField.forceFieldURL = url;
try {
PropertiesConfiguration config = new PropertiesConfiguration(url);
properties.addConfiguration(config);
} catch (ConfigurationException e) {
logger.warning(e.toString());
}
}
}
/**
* Overwrite parameters of the forceFieldFile with those from the
* CompositeConfiguration.
*/
if (properties != null) {
parse(properties);
}
// forceField.checkPolarizationTypes();
} catch (FileNotFoundException e) {
String message = "Exception parsing force field.";
logger.log(Level.WARNING, message, e);
}
return forceField;
}
Aggregations