use of org.openscience.cdk.smiles.smarts.SMARTSQueryTool in project MetFragRelaunched by ipb-halle.
the class SmartsGroup method removeDuplicates.
public void removeDuplicates() {
java.util.ArrayList<Object> newList = new java.util.ArrayList<Object>();
java.util.ArrayList<String> newSmiles = new java.util.ArrayList<String>();
for (int i = 0; i < this.list.size(); i++) {
String current = ((SMARTSQueryTool) this.list.get(i)).getSmarts();
if (!newList.contains(current)) {
newList.add(current);
newSmiles.add(this.smiles.get(i));
}
}
this.list = new java.util.ArrayList<Object>();
for (int i = 0; i < newList.size(); i++) {
SMARTSQueryTool sqt = new SMARTSQueryTool((String) newList.get(i), DefaultChemObjectBuilder.getInstance());
this.list.add(sqt);
}
this.smiles = newSmiles;
}
use of org.openscience.cdk.smiles.smarts.SMARTSQueryTool in project MetFragRelaunched by ipb-halle.
the class SmartsSubstructureExclusionScoreInitialiser method initScoreParameters.
@Override
public void initScoreParameters(Settings settings) {
String[] excludedSmarts = (String[]) settings.get(VariableNames.SCORE_SMARTS_EXCLUSION_LIST_NAME);
SMARTSQueryTool[] smartsQuerytools = null;
if (excludedSmarts != null && excludedSmarts.length != 0) {
smartsQuerytools = new SMARTSQueryTool[excludedSmarts.length];
for (int i = 0; i < excludedSmarts.length; i++) {
smartsQuerytools[i] = new SMARTSQueryTool(excludedSmarts[i], DefaultChemObjectBuilder.getInstance());
}
settings.set(VariableNames.SMARTS_SUBSTRUCTURE_EXCLUSION_SCORE_LIST_NAME, smartsQuerytools);
}
}
use of org.openscience.cdk.smiles.smarts.SMARTSQueryTool in project MetFragRelaunched by ipb-halle.
the class SmartsSubstructureInclusionScoreInitialiser method initScoreParameters.
@Override
public void initScoreParameters(Settings settings) {
String[] excludedSmarts = (String[]) settings.get(VariableNames.SCORE_SMARTS_INCLUSION_LIST_NAME);
SMARTSQueryTool[] smartsQuerytools = null;
if (excludedSmarts != null && excludedSmarts.length != 0) {
smartsQuerytools = new SMARTSQueryTool[excludedSmarts.length];
for (int i = 0; i < excludedSmarts.length; i++) {
smartsQuerytools[i] = new SMARTSQueryTool(excludedSmarts[i], DefaultChemObjectBuilder.getInstance());
}
settings.set(VariableNames.SMARTS_SUBSTRUCTURE_INCLUSION_SCORE_LIST_NAME, smartsQuerytools);
}
}
use of org.openscience.cdk.smiles.smarts.SMARTSQueryTool in project ambit-mirror by ideaconsult.
the class StructureKeysBitSetGeneratorTest method testBiphenyl4CDK.
@Test
public void testBiphenyl4CDK() throws Exception {
IteratingSDFReader reader = new IteratingSDFReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("biphenyl.sdf")), SilentChemObjectBuilder.getInstance());
IAtomContainer biphenyl_kekule = null;
while (reader.hasNext()) {
IChemObject o = reader.next();
Assert.assertTrue(o instanceof IAtomContainer);
biphenyl_kekule = (IAtomContainer) o;
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(biphenyl_kekule);
// well, Hydrogens are already in the file, but we need to mimic the
// generic read/processing workflow
CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(biphenyl_kekule.getBuilder());
hAdder.addImplicitHydrogens(biphenyl_kekule);
CDKHueckelAromaticityDetector.detectAromaticity(biphenyl_kekule);
MoleculeTools.convertImplicitToExplicitHydrogens(biphenyl_kekule);
biphenyl_kekule.setID("biphenyl_kekule");
break;
}
reader.close();
Assert.assertNotNull(biphenyl_kekule);
// get the biphenyl as aromatic smiles
SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer biphenyl_aromaticsmiles = parser.parseSmiles("c1ccccc1c2ccccc2");
biphenyl_aromaticsmiles.setID("biphenyl_aromatic");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(biphenyl_aromaticsmiles);
CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(biphenyl_aromaticsmiles.getBuilder());
hAdder.addImplicitHydrogens(biphenyl_aromaticsmiles);
CDKHueckelAromaticityDetector.detectAromaticity(biphenyl_aromaticsmiles);
MoleculeTools.convertImplicitToExplicitHydrogens(biphenyl_aromaticsmiles);
// get the biphenyl as Kekule smiles
IAtomContainer biphenyl_kekulesmiles = parser.parseSmiles("C1=C(C=CC=C1)C2=CC=CC=C2");
biphenyl_kekulesmiles.setID("biphenyl_kekulesmiles");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(biphenyl_kekulesmiles);
hAdder = CDKHydrogenAdder.getInstance(biphenyl_kekulesmiles.getBuilder());
hAdder.addImplicitHydrogens(biphenyl_kekulesmiles);
CDKHueckelAromaticityDetector.detectAromaticity(biphenyl_kekulesmiles);
MoleculeTools.convertImplicitToExplicitHydrogens(biphenyl_kekulesmiles);
UniversalIsomorphismTester uit = new UniversalIsomorphismTester();
Assert.assertTrue(uit.isIsomorph(biphenyl_aromaticsmiles, biphenyl_kekule));
Assert.assertTrue(uit.isIsomorph(biphenyl_aromaticsmiles, biphenyl_kekulesmiles));
Assert.assertTrue(uit.isIsomorph(biphenyl_kekulesmiles, biphenyl_kekule));
// #1 with the latest fix, we'll not find double bonds :)
ISmartsPattern smartsPattern_ambit = SmartsPatternFactory.createSmartsPattern(SmartsParser.smarts_nk, "[#6]=[#6]", false);
Assert.assertTrue(smartsPattern_ambit.match(biphenyl_aromaticsmiles) == 0);
Assert.assertTrue(smartsPattern_ambit.match(biphenyl_kekule) == 0);
Assert.assertTrue(smartsPattern_ambit.match(biphenyl_kekulesmiles) == 0);
// #1 with the latest fix, we'll not find double bonds :)
ISmartsPattern smartsPattern_fast = SmartsPatternFactory.createSmartsPattern(SmartsParser.smarts_fast, "[#6]=[#6]", false);
Assert.assertTrue(smartsPattern_fast.match(biphenyl_aromaticsmiles) == 0);
Assert.assertTrue(smartsPattern_fast.match(biphenyl_kekule) == 0);
Assert.assertTrue(smartsPattern_fast.match(biphenyl_kekulesmiles) == 0);
// #3 cdk does find double bonds in kekule representation
ISmartsPattern smartsPattern_cdk = SmartsPatternFactory.createSmartsPattern(SmartsParser.smarts_cdk, "[#6]=[#6]", false);
Assert.assertTrue(smartsPattern_cdk.match(biphenyl_aromaticsmiles) == 0);
// this is fixed in cdk 1.4.4
Assert.assertTrue(smartsPattern_cdk.match(biphenyl_kekule) == 0);
Assert.assertTrue(smartsPattern_cdk.match(biphenyl_kekulesmiles) == 0);
// same as #3 but using CDK code only
SMARTSQueryTool sqt = new SMARTSQueryTool("[#6]=[#6]", SilentChemObjectBuilder.getInstance());
// there is no any double bond in biphenyl, created via aromatic smiles
// Fixed in cdk 1.4.4
Assert.assertFalse(sqt.matches(biphenyl_aromaticsmiles));
// there is at least one :) double bond in the biphenyl , read from SDF
Assert.assertFalse(sqt.matches(biphenyl_kekule));
// there is at least one :) double bond in the biphenyl , read from SDF
Assert.assertFalse(sqt.matches(biphenyl_kekulesmiles));
}
use of org.openscience.cdk.smiles.smarts.SMARTSQueryTool in project cdk by cdk.
the class RecursiveTest method testBasicAmineOnDrugs_cdkAromaticModel.
@Category(SlowTest.class)
@Test
public void testBasicAmineOnDrugs_cdkAromaticModel() throws Exception {
String filename = "drugs.smi";
InputStream ins = this.getClass().getResourceAsStream(filename);
IteratingSMILESReader reader = new IteratingSMILESReader(ins, DefaultChemObjectBuilder.getInstance());
SMARTSQueryTool sqt = new SMARTSQueryTool("[NX3;H2,H1;!$(NC=O)]", DefaultChemObjectBuilder.getInstance());
sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()));
int nmatch = 0;
int nmol = 0;
READ: while (reader.hasNext()) {
IAtomContainer container = reader.next();
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(container);
// model
for (IAtom atom : container.atoms()) {
if (atom.getAtomTypeName() == null) {
continue READ;
}
}
if (sqt.matches(container)) {
nmatch++;
}
nmol++;
}
reader.close();
Assert.assertEquals(141, nmol);
Assert.assertEquals(4, nmatch);
}
Aggregations