use of org.openscience.cdk.io.setting.BooleanIOSetting in project ambit-mirror by ideaconsult.
the class MoleculeTools method readMolfile.
public static IAtomContainer readMolfile(String molfile) throws Exception {
MDLV2000Reader r = null;
try {
StringReader reader = new StringReader(molfile);
r = new MDLV2000Reader(reader);
r.addSetting(new BooleanIOSetting("AddStereoElements", IOSetting.Importance.HIGH, "Assign stereo configurations to stereocenters utilising 2D/3D coordinates.", "false"));
/*
* Properties customSettings = new Properties();
* customSettings.setProperty("AddStereoElements", "false");
* PropertiesListener listener = new
* PropertiesListener(customSettings);
* r.addChemObjectIOListener(listener);
*/
IAtomContainer mol = r.read(new AtomContainer());
reader.close();
return mol;
} finally {
try {
r.close();
} catch (Exception x) {
}
}
}
use of org.openscience.cdk.io.setting.BooleanIOSetting in project cdk by cdk.
the class TextGUIListener method processIOSettingQuestion.
/**
* Processes the IOSettings by listing the question, giving the options
* and asking the user to provide their choice.
*
* <p>Note: if the input reader is <code>null</code>, then the method
* does not wait for an answer, and takes the default.
*/
@Override
public void processIOSettingQuestion(IOSetting setting) {
// post the question
if (setting.getLevel().ordinal() <= this.level.ordinal()) {
// output the option name
this.out.print("[" + setting.getName() + "]: ");
// post the question
this.out.print(setting.getQuestion());
if (setting instanceof BooleanIOSetting) {
BooleanIOSetting boolSet = (BooleanIOSetting) setting;
boolean set = boolSet.isSet();
if (set) {
this.out.print(" [Yn]");
} else {
this.out.print(" [yN]");
}
} else if (setting instanceof OptionIOSetting) {
OptionIOSetting optionSet = (OptionIOSetting) setting;
List<String> settings = optionSet.getOptions();
for (int i = 0; i < settings.size(); i++) {
this.out.println();
String option = settings.get(i);
this.out.print((i + 1) + ". " + option);
if (option.equals(setting.getSetting())) {
this.out.print(" (Default)");
}
}
} else {
this.out.print(" [" + setting.getSetting() + "]");
}
this.out.println();
this.out.flush();
// get the answer, only if input != null
if (this.in == null) {
// don't really ask questions. This is intentional behaviour to
// allow for listing all questions. The settings is now defaulted,
// which is the intention too.
} else {
boolean gotAnswer = false;
while (!gotAnswer) {
try {
this.out.print("> ");
this.out.flush();
String answer = in.readLine();
if (answer.length() == 0) {
// pressed ENTER -> take default
} else if (setting instanceof OptionIOSetting) {
((OptionIOSetting) setting).setSetting(Integer.parseInt(answer));
} else if (setting instanceof BooleanIOSetting) {
if (answer.equalsIgnoreCase("n") || answer.equalsIgnoreCase("no")) {
answer = "false";
}
if (answer.equalsIgnoreCase("y") || answer.equalsIgnoreCase("yes")) {
answer = "true";
}
setting.setSetting(answer);
} else {
setting.setSetting(answer);
}
gotAnswer = true;
} catch (IOException exception) {
this.out.println("Cannot read from STDIN. Skipping question.");
} catch (NumberFormatException exception) {
this.out.println("Answer is not a number.");
} catch (CDKException exception) {
this.out.println();
this.out.println(exception);
}
}
}
}
}
use of org.openscience.cdk.io.setting.BooleanIOSetting in project cdk by cdk.
the class GaussianInputWriter method initIOSettings.
private void initIOSettings() {
List<String> basisOptions = new ArrayList<>();
basisOptions.add("6-31g");
basisOptions.add("6-31g*");
basisOptions.add("6-31g(d)");
basisOptions.add("6-311g");
basisOptions.add("6-311+g**");
basis = new OptionIOSetting("Basis", IOSetting.Importance.MEDIUM, "Which basis set do you want to use?", basisOptions, "6-31g");
List<String> methodOptions = new ArrayList<>();
methodOptions.add("rb3lyp");
methodOptions.add("b3lyp");
methodOptions.add("rhf");
method = new OptionIOSetting("Method", IOSetting.Importance.MEDIUM, "Which method do you want to use?", methodOptions, "b3lyp");
List<String> commandOptions = new ArrayList<>();
commandOptions.add("energy calculation");
commandOptions.add("geometry optimization");
commandOptions.add("IR frequency calculation");
commandOptions.add("IR frequency calculation (with Raman)");
command = addSetting(new OptionIOSetting("Command", IOSetting.Importance.HIGH, "What kind of job do you want to perform?", commandOptions, "energy calculation"));
comment = addSetting(new StringIOSetting("Comment", IOSetting.Importance.LOW, "What comment should be put in the file?", "Created with CDK (http://cdk.sf.net/)"));
memory = addSetting(new StringIOSetting("Memory", IOSetting.Importance.LOW, "How much memory do you want to use?", "unset"));
shell = addSetting(new BooleanIOSetting("OpenShell", IOSetting.Importance.MEDIUM, "Should the calculation be open shell?", "false"));
proccount = addSetting(new IntegerIOSetting("ProcessorCount", IOSetting.Importance.LOW, "How many processors should be used by Gaussian?", "1"));
usecheckpoint = new BooleanIOSetting("UseCheckPointFile", IOSetting.Importance.LOW, "Should a check point file be saved?", "false");
}
use of org.openscience.cdk.io.setting.BooleanIOSetting in project cdk by cdk.
the class IteratingSDFReader method initIOSettings.
private void initIOSettings() {
forceReadAs3DCoords = new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.Importance.LOW, "Should coordinates always be read as 3D?", "false");
addSetting(forceReadAs3DCoords);
}
Aggregations