use of ambit2.core.io.RawIteratingSDFReader in project ambit-mirror by ideaconsult.
the class SMARTSPropertiesGeneratorTest method testAromatic.
@Test
public void testAromatic() throws Exception {
MoleculeReader mr = new MoleculeReader();
AtomConfigurator config = new AtomConfigurator();
SMARTSPropertiesGenerator gen = new SMARTSPropertiesGenerator();
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("benzene.sdf")));
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
IAtomContainer c = config.process(mr.process(record));
CDKHueckelAromaticityDetector.detectAromaticity(c);
if (c.getAtomCount() <= 2)
continue;
// no SMARTSProp assigned, will be generated on the fly
Assert.assertNull(c.getProperty(gen.getProperty()));
testMatchAromatic(c);
// get the record anew, and set the property
c = mr.process(record);
record = gen.process(record);
Assert.assertNotNull(record.getRecordProperty(gen.getProperty()));
c.setProperty(gen.getProperty(), record.getRecordProperty(gen.getProperty()));
Assert.assertNotNull(c.getProperty(gen.getProperty()));
testMatchAromatic(c);
}
reader.close();
}
use of ambit2.core.io.RawIteratingSDFReader in project ambit-mirror by ideaconsult.
the class SMARTSPropertiesGeneratorTest method test.
@Test
public void test() throws Exception {
MoleculeReader mr = new MoleculeReader();
SMARTSPropertiesGenerator gen = new SMARTSPropertiesGenerator();
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("test.sdf")));
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
IAtomContainer c = mr.process(record);
if (c.getAtomCount() <= 2)
continue;
// no SMARTSProp assigned, will be generated on the fly
Assert.assertNull(c.getProperty(gen.getProperty()));
testMatch(c);
String[] properties = new String[] { "0110,03310503,02210503,033206050203,033206060102,02210601,02210601,043206060001,03210600,04310600,0210,03210600,03210600,044206060001,0110,044206060102,0110,03310602,0110,02210602,044206050203,0110,04410503,0110,0430,0210,0220,0110,", "0110,03310502,02210502,033206050102,033206060001,02210600,02210600,043206060003,03210603,04310603,0210,03210603,03210603,044206060003,0110,044206060001,0110,03310601,0110,02210601,044206050102,0110,04410502,0110,0430,0210,0220,0110,", "0110,03310500,02210500,033205060002,033206060102,02210601,02210601,043206060103,03210603,04310603,0210,03210603,03210603,044206060103,0110,044206060102,0110,03310602,0110,02210602,044205060002,0110,04410500,0110,0430,0210,0220,0110," };
for (String prop : properties) {
// get the record anew
c = mr.process(record);
c.removeProperty(gen.getProperty());
c.setProperty(gen.getProperty(), prop);
Assert.assertNotNull(c.getProperty(gen.getProperty()));
testMatch(c);
}
// get the record anew
c = mr.process(record);
record = gen.process(record);
Assert.assertNotNull(record.getRecordProperty(gen.getProperty()));
c.setProperty(gen.getProperty(), record.getRecordProperty(gen.getProperty()));
Assert.assertNotNull(c.getProperty(gen.getProperty()));
testMatch(c);
}
reader.close();
}
use of ambit2.core.io.RawIteratingSDFReader in project ambit-mirror by ideaconsult.
the class StructureKeysBitSetGeneratorTest method testTriazoleKeys.
/**
* aromatic :<{113, 852}> 113: c(c)n 852: c(cn)n sdf 8: N, 12 CC, 22 NC, 27
* C(C)N, 71 C, 444 C(CN)N, 911 NN
*
* @param cleanKekuleBonds
* @throws Exception
*/
public void testTriazoleKeys(boolean cleanKekuleBonds) throws Exception {
MoleculeReader mr = new MoleculeReader();
AtomConfigurator config = new AtomConfigurator();
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("triazole.sdf")));
BitSet bitsetKekule = null;
StructureKeysBitSetGenerator bitsetGenerator = new StructureKeysBitSetGenerator();
bitsetGenerator.setCleanKekuleBonds(cleanKekuleBonds);
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
IAtomContainer c = config.process(mr.process(record));
// CDKHueckelAromaticityDetector.detectAromaticity(c);
bitsetKekule = bitsetGenerator.process(c);
logger.fine(bitsetKekule.toString());
}
reader.close();
SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = parser.parseSmiles("c1cnn[nH]1");
for (IBond b : mol.bonds()) logger.fine(Boolean.toString(b.getFlag(CDKConstants.ISAROMATIC)));
mol = config.process(mol);
// CDKHueckelAromaticityDetector.detectAromaticity(mol);
for (IBond b : mol.bonds()) logger.fine(Boolean.toString(b.getFlag(CDKConstants.ISAROMATIC)));
BitSet bitsetAromatic = bitsetGenerator.process(mol);
logger.fine(bitsetAromatic.toString());
Assert.assertEquals(bitsetKekule, bitsetAromatic);
parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
mol = parser.parseSmiles("C1=CN=NN1");
for (IBond b : mol.bonds()) logger.fine(Boolean.toString(b.getFlag(CDKConstants.ISAROMATIC)));
mol = config.process(mol);
// CDKHueckelAromaticityDetector.detectAromaticity(mol);
for (IBond b : mol.bonds()) logger.fine(Boolean.toString(b.getFlag(CDKConstants.ISAROMATIC)));
BitSet bitsetKekuleSMILES = bitsetGenerator.process(mol);
logger.fine(bitsetKekuleSMILES.toString());
Assert.assertEquals(bitsetKekule, bitsetKekuleSMILES);
}
use of ambit2.core.io.RawIteratingSDFReader in project ambit-mirror by ideaconsult.
the class StructureKeysBitSetGeneratorTest method testBiphenylKeys.
public void testBiphenylKeys(boolean cleanKekuleBonds) throws Exception {
MoleculeReader mr = new MoleculeReader();
AtomConfigurator config = new AtomConfigurator();
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("biphenyl.sdf")));
BitSet bitsetKekule = null;
StructureKeysBitSetGenerator bitsetGenerator = new StructureKeysBitSetGenerator();
bitsetGenerator.setCleanKekuleBonds(cleanKekuleBonds);
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
IAtomContainer c = config.process(mr.process(record));
bitsetKekule = bitsetGenerator.process(c);
}
reader.close();
SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = parser.parseSmiles("c1ccccc1c2ccccc2");
BitSet bitsetAromatic = bitsetGenerator.process(mol);
Assert.assertEquals(bitsetKekule, bitsetAromatic);
}
use of ambit2.core.io.RawIteratingSDFReader in project ambit-mirror by ideaconsult.
the class FingerPrintGeneratorTest method testPolyAromatics.
@Test
public void testPolyAromatics() throws Exception {
MoleculeReader molreader = new MoleculeReader();
FingerprintGenerator gen = new FingerprintGenerator(new Fingerprinter());
InputStream in = FingerPrintGeneratorTest.class.getClassLoader().getResourceAsStream("ambit2/core/data/fp/polyaromatics.sdf");
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(in));
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
IAtomContainer mol = molreader.process(record);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance()).addImplicitHydrogens(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
gen.setHydrogens(false);
mol = AtomContainerManipulator.removeHydrogensPreserveMultiplyBonded(mol);
BitSet bs1 = gen.process(mol);
System.out.println(bs1);
ExtendedFingerprinter efp = new ExtendedFingerprinter();
System.out.println(efp.getClass().getName());
System.out.println(efp.getBitFingerprint(mol).asBitSet());
PubchemFingerprinter pfp = new PubchemFingerprinter(SilentChemObjectBuilder.getInstance());
System.out.println(pfp.getClass().getName());
System.out.println(pfp.getBitFingerprint(mol).asBitSet());
EStateFingerprinter esfp = new EStateFingerprinter();
System.out.println(esfp.getClass().getName());
System.out.println(esfp.getBitFingerprint(mol).asBitSet());
MACCSFingerprinter mfp = new MACCSFingerprinter();
System.out.println(mfp.getClass().getName());
System.out.println(mfp.getBitFingerprint(mol).asBitSet());
SubstructureFingerprinter sfp = new SubstructureFingerprinter();
System.out.println(sfp.getClass().getName());
System.out.println(sfp.getBitFingerprint(mol).asBitSet());
HybridizationFingerprinter hfp = new HybridizationFingerprinter();
System.out.println(hfp.getClass().getName());
System.out.println(hfp.getBitFingerprint(mol).asBitSet());
/*
BigInteger[] h16 = new BigInteger[16];
MoleculeTools.bitset2bigint16(bs1,64,h16);
new Random(10000);
BitSet bs2 = gen.process(molreader.process(record));
Assert.assertEquals(bs1,bs2);
MoleculeTools.bitset2bigint16(bs2,64,h16);
for (int i=0; i <16;i++) {
Assert.assertEquals(expected[i], h16[i]);
}
*/
}
/*
IStructureRecord record = new StructureRecord();
record.setContent();
MoleculeReader reader = new MoleculeReader();
reader.process(target)
*/
reader.close();
}
Aggregations