use of org.openscience.cdk.io.setting.StringIOSetting in project ambit-mirror by ideaconsult.
the class InteractiveIteratingMDLReader method next.
/* (non-Javadoc)
* @see org.openscience.cdk.io.iterator.IteratingMDLReader#next()
*/
public IAtomContainer next() {
Object o = super.next();
if (o instanceof IChemObject) {
Map properties = ((IChemObject) o).getProperties();
if (properties.size() > 0) {
fireIOSettingQuestion(new StringIOSetting("", Importance.MEDIUM, Property.IO_QUESTION.IO_START.toString(), ""));
Iterator i = properties.keySet().iterator();
while (i.hasNext()) {
String name = i.next().toString();
fireIOSettingQuestion(new StringIOSetting(name, Importance.MEDIUM, Property.IO_QUESTION.IO_TRANSLATE_NAME.toString(), name));
}
fireIOSettingQuestion(new StringIOSetting("", Importance.MEDIUM, Property.IO_QUESTION.IO_STOP.toString(), ""));
}
return (IAtomContainer) o;
}
return null;
}
use of org.openscience.cdk.io.setting.StringIOSetting in project ambit-mirror by ideaconsult.
the class IteratingDelimitedFileReaderComplexHeader method hasNext.
// TODO fix: returns false if a column without a header has some data
// (throws exception and the returns false)
/*
* (non-Javadoc)
*
* @see java.util.Iterator#hasNext()
*/
public boolean hasNext() {
if (isHeaderEmpty()) {
fireIOSettingQuestion(new StringIOSetting("", Importance.MEDIUM, Property.IO_QUESTION.IO_START.toString(), ""));
processHeader(input);
fireIOSettingQuestion(new StringIOSetting("", Importance.MEDIUM, Property.IO_QUESTION.IO_STOP.toString(), ""));
}
if (!nextAvailableIsKnown) {
hasNext = false;
// now try to parse the next Molecule
try {
if (input.ready()) {
extractRowKeyAndData(input.readLine().trim());
nextMolecule = null;
if (inchiIndex >= 0)
try {
if (inchiFactory == null)
inchiFactory = InChIGeneratorFactory.getInstance();
InChIToStructure c = inchiFactory.getInChIToStructure(values[inchiIndex].toString(), SilentChemObjectBuilder.getInstance());
nextMolecule = c.getAtomContainer();
} catch (Exception x) {
nextMolecule = null;
}
if ((nextMolecule == null) && (smilesIndex >= 0)) {
try {
if (values[smilesIndex] == null) {
nextMolecule = SilentChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
} else
nextMolecule = sp.parseSmiles(values[smilesIndex].toString());
} catch (InvalidSmilesException | ArrayIndexOutOfBoundsException x) {
// do not want to break if a record is faulty
logger.fine("Empty molecule!");
// just
nextMolecule = SilentChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
// create
nextMolecule.setProperty("SMILES", "Invalid SMILES");
}
}
if (nextMolecule == null)
nextMolecule = SilentChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
for (int i = 0; i < values.length; i++) if (values[i] != null) {
String cas = casTransformer.process(values[i].toString());
if (CASProcessor.isValidFormat(cas)) {
// if (getHeaderColumn(i) instanceof Property)
// getHeaderColumn(i).setLabel(Property.CAS);
values[i] = cas;
}
// else if
// (EINECS.isValidFormat(values[i].toString()))
// getHeaderColumn(i).setLabel(Property.EC);
nextMolecule.setProperty(getHeaderColumn(i), values[i].toString().trim());
} else
nextMolecule.removeProperty(getHeaderColumn(i));
/*
* if (nextMolecule.getAtomCount() > 0) { hasNext = true; }
* else { hasNext = false; }
*/
hasNext = true;
} else {
hasNext = false;
}
} catch (Exception exception) {
logger.log(Level.SEVERE, "Error while reading next molecule: ", exception);
hasNext = true;
}
if (!hasNext)
nextMolecule = null;
nextAvailableIsKnown = true;
}
return hasNext;
}
use of org.openscience.cdk.io.setting.StringIOSetting in project ambit-mirror by ideaconsult.
the class IteratingFilesWithHeaderReader method addHeaderColumn.
protected void addHeaderColumn(String name) {
header.add(createPropertyByColumnName(name));
fireIOSettingQuestion(new StringIOSetting(name, Importance.MEDIUM, Property.IO_QUESTION.IO_TRANSLATE_NAME.toString(), name));
}
use of org.openscience.cdk.io.setting.StringIOSetting in project ambit-mirror by ideaconsult.
the class IteratingXLSReader method hasNext.
public boolean hasNext() {
if (isHeaderEmpty()) {
fireIOSettingQuestion(new StringIOSetting("", Importance.MEDIUM, Property.IO_QUESTION.IO_START.toString(), ""));
processHeader();
fireIOSettingQuestion(new StringIOSetting("", Importance.MEDIUM, Property.IO_QUESTION.IO_STOP.toString(), ""));
}
try {
return iterator.hasNext();
} catch (Exception x) {
logger.log(Level.SEVERE, x.getMessage(), x);
return false;
}
}
use of org.openscience.cdk.io.setting.StringIOSetting 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");
}
Aggregations