use of org.openscience.cdk.interfaces.IChemObject in project ambit-mirror by ideaconsult.
the class MultiFingerprintsWriter method write.
@Override
public void write(IChemObject mol) throws CDKException {
for (int k = 0; k < tags.length; k++) tags[k] = null;
Iterator<Entry<Object, Object>> i = mol.getProperties().entrySet().iterator();
while (i.hasNext()) {
Entry<Object, Object> entry = i.next();
String p = entry.getKey() instanceof Property ? ((Property) entry.getKey()).getName() : entry.getKey().toString();
int index = Arrays.binarySearch(tags_to_keep, p);
if (index >= 0)
tags[index] = entry.getValue();
}
i = mol.getProperties().entrySet().iterator();
while (i.hasNext()) {
Entry<Object, Object> entry = i.next();
try {
Object[] record = mol2record(tags, entry.getKey().toString(), entry.getValue());
if (record != null) {
CSVPrinter writer = getWriter(entry.getKey().toString());
if (writer != null)
writer.printRecord(record);
}
} catch (Exception x) {
Logger.getGlobal().log(Level.WARNING, x.getMessage());
}
}
}
use of org.openscience.cdk.interfaces.IChemObject 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.interfaces.IChemObject in project ambit-mirror by ideaconsult.
the class ArffWriter method write.
public void write(IChemObject mol) throws CDKException {
try {
for (int i = 0; i < getHeader().size(); i++) {
Object o = getHeader().get(i);
if (i > 0)
writer.write(',');
Object p = mol.getProperty(o);
writer.write(p == null ? "?" : p.toString());
}
writer.write('\n');
} catch (IOException x) {
throw new CDKException(x.getMessage());
}
}
use of org.openscience.cdk.interfaces.IChemObject in project ambit-mirror by ideaconsult.
the class MDLV2000ReaderExtendedTest method testMixture.
@Test
public void testMixture() throws Exception {
IChemObject mol = readSGroup("mixture_unordered.mol");
Assert.assertNotNull(mol);
Assert.assertTrue(mol instanceof SuppleAtomContainer);
SuppleAtomContainer sca = (SuppleAtomContainer) mol;
sca.setFiltered(false);
Assert.assertEquals(11, sca.getBondCount());
Assert.assertEquals(15 + 4, sca.getAtomCount());
List<ISGroup> superatom = getGroup(sca);
Assert.assertNotNull(superatom);
Assert.assertEquals(4, superatom.size());
for (int i = 0; i < superatom.size(); i++) {
if (superatom.get(i) instanceof ComponentGroup) {
Assert.assertNotNull(superatom.get(i));
Assert.assertNull(((ComponentGroup) superatom.get(i)).getOrder());
} else if (superatom.get(i) instanceof ContainerGroup) {
Assert.assertEquals(3, ((ContainerGroup) superatom.get(i)).getComponents().size());
}
}
sca.setFiltered(true);
verify((IAtomContainer) mol, superatom, false, 15, 11, true);
verify((IAtomContainer) mol, superatom, true, 15, 11, true);
}
use of org.openscience.cdk.interfaces.IChemObject in project ambit-mirror by ideaconsult.
the class MDLV2000ReaderExtendedTest method testGeneric.
@Test
public void testGeneric() throws Exception {
IChemObject mol = readSGroup("generic.mol");
Assert.assertNotNull(mol);
Assert.assertTrue(mol instanceof SuppleAtomContainer);
SuppleAtomContainer sca = (SuppleAtomContainer) mol;
sca.setFiltered(false);
Assert.assertEquals(11, sca.getBondCount());
Assert.assertEquals(19, sca.getAtomCount());
List<ISGroup> superatom = getGroup(sca);
Assert.assertNotNull(superatom);
Assert.assertEquals(2, superatom.size());
Assert.assertNotNull(superatom.get(0));
Assert.assertNotNull(superatom.get(1));
sca.setFiltered(true);
verify((IAtomContainer) mol, superatom, false, 17, 11, false);
verify((IAtomContainer) mol, superatom, true, 17, 11, false);
}
Aggregations