use of org.openscience.cdk.fingerprint.Fingerprinter in project ambit-mirror by ideaconsult.
the class SimilarityDepict method getBitSet.
protected BitSet[] getBitSet(String[] smiles) {
int n = smiles.length > max ? max : smiles.length;
BitSet[] bitset = new BitSet[n];
for (int i = 0; i < n; i++) try {
IAtomContainer molecule = getMolecule(smiles[i]);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
CDKHueckelAromaticityDetector.detectAromaticity(molecule);
molecule = AtomContainerManipulator.removeHydrogensPreserveMultiplyBonded(molecule);
if (fingerprinter == null)
fingerprinter = new Fingerprinter();
bitset[i] = fingerprinter.getBitFingerprint(molecule).asBitSet();
} catch (Exception x) {
bitset[i] = null;
}
return bitset;
}
use of org.openscience.cdk.fingerprint.Fingerprinter in project ambit-mirror by ideaconsult.
the class CallableFingerprintsModelCreator method createProcessors.
protected ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> createProcessors() throws Exception {
ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> p1 = new ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor>();
p1.add(new ProcessorStructureRetrieval());
p1.add(new MoleculeReader());
p1.add(new FingerprintGenerator(new Fingerprinter()));
p1.add(new DefaultAmbitProcessor<BitSet, BitSet>() {
/**
*/
private static final long serialVersionUID = -2978697147490545478L;
public BitSet process(BitSet target) throws AmbitException {
builder.getTrainingData().add(target);
return target;
}
});
p1.setAbortOnError(true);
return p1;
}
use of org.openscience.cdk.fingerprint.Fingerprinter in project ambit-mirror by ideaconsult.
the class MoleculeTools method getFingerPrint.
public static BitSet getFingerPrint(String smiles, int fpLength) throws Exception {
SmilesParserWrapper sp = SmilesParserWrapper.getInstance();
IAtomContainer mol = sp.parseSmiles(smiles);
if (fingerprinter == null)
fingerprinter = new Fingerprinter(fpLength);
return fingerprinter.getBitFingerprint(mol).asBitSet();
}
use of org.openscience.cdk.fingerprint.Fingerprinter in project ambit-mirror by ideaconsult.
the class FingerPrintGeneratorTest method test.
@Test
public void test() throws Exception {
BigInteger[] expected = /*{
new BigInteger("1126174803623952"),
new BigInteger("1152961362175993860"),
new BigInteger("2305843011903291728"),
new BigInteger("25769820160"),
new BigInteger("1099511627776"),
new BigInteger("33554496"),
new BigInteger("8864814662912"),
new BigInteger("4803285265416200"),
new BigInteger("9223372050830336000"),
new BigInteger("2454675102173515776"),
new BigInteger("1152921504611041536"),
new BigInteger("155684661740175875"),
new BigInteger("6917529131798265856"),
new BigInteger("310748377023266816"),
new BigInteger("67110400"),
new BigInteger("2305843009213710336")};
*/
{ new BigInteger("576462128137896992"), new BigInteger("10376293541473171584"), new BigInteger("2305843009214747777"), new BigInteger("72127962782121984"), new BigInteger("52776558133248"), new BigInteger("0"), new BigInteger("338649581355264"), new BigInteger("4366794756"), new BigInteger("17730770043904"), new BigInteger("2314887591865356288"), new BigInteger("2305844109263241488"), new BigInteger("2400709834665132544"), new BigInteger("13835058125075449856"), new BigInteger("10741891072"), new BigInteger("9007208196998144"), new BigInteger("18014398511644672") };
MoleculeReader molreader = new MoleculeReader();
FingerprintGenerator gen = new FingerprintGenerator(new Fingerprinter());
InputStream in = FingerPrintGeneratorTest.class.getClassLoader().getResourceAsStream("ambit2/core/data/fp/fptest.mol");
RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(in));
while (reader.hasNext()) {
IStructureRecord record = reader.nextRecord();
BitSet bs1 = gen.process(molreader.process(record));
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)
*/
}
use of org.openscience.cdk.fingerprint.Fingerprinter in project ambit-mirror by ideaconsult.
the class QueryInfo2Query method createQuerySubstructure.
protected QueryPrescreenBitSet createQuerySubstructure(QueryInfo target) throws AmbitException {
if (QueryInfo.METHOD_SUBSTRUCTURE.equals(target.getMethod())) {
if (target.getMolecule() == null)
return null;
FingerprintGenerator g = new FingerprintGenerator(new Fingerprinter());
BitSet bitset = g.process(target.getMolecule());
QueryPrescreenBitSet qs = new QueryPrescreenBitSet();
qs.setValue(bitset);
return qs;
} else
return null;
}
Aggregations