use of org.openscience.cdk.aromaticity.Aromaticity in project cdk by cdk.
the class SMARTSSearchTest method testLogicalOrLowAnd6_cdkAromaticity.
@Test
public void testLogicalOrLowAnd6_cdkAromaticity() throws Exception {
SMARTSQueryTool sqt = smarts("[#7,C;+0,+1]");
IAtomContainer smi = smiles("[Na+].[Na+].[O-]C(=O)c1ccccc1c2c3ccc([O-])cc3oc4cc(=O)ccc24");
sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()));
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(smi);
int[] results = match(sqt, smi);
Assert.assertEquals(8, results[0]);
}
use of org.openscience.cdk.aromaticity.Aromaticity in project ErtlFunctionalGroupsFinder by zielesny.
the class ErtlFunctionalGroupsFinderEvaluationTest method testCycleFinderDependency.
/**
* Test for analyzing molecules in an SD file for six different CycleFinder settings supplied by the cdk: all(),
* vertexShort(), relevant(), essential(), tripleShort() and cdkAromaticSet().
* <p>
* (Functional groups occurring multiple times in the same molecule are counted multiple times)
*
* @throws java.lang.Exception if initializeWithFileOperations() throws an exception or an unexpected exception occurs
*/
@Test
public void testCycleFinderDependency() throws Exception {
this.initializeWithFileOperations(ErtlFunctionalGroupsFinderEvaluationTest.SD_FILE_PATH, ErtlFunctionalGroupsFinderEvaluationTest.CYCLE_FINDER_TEST_IDENTIFIER);
Assume.assumeTrue(this.isTestAbleToRun);
System.out.println("\nLoading file with path: " + ErtlFunctionalGroupsFinderEvaluationTest.SD_FILE_PATH);
File tmpSDFile = new File(ErtlFunctionalGroupsFinderEvaluationTest.SD_FILE_PATH);
int tmpRequiredNumberOfReaders = 6;
IteratingSDFReader[] tmpReaders = new IteratingSDFReader[tmpRequiredNumberOfReaders];
try {
for (int i = 0; i < tmpRequiredNumberOfReaders; i++) {
IteratingSDFReader tmpReader = new IteratingSDFReader(new FileInputStream(tmpSDFile), DefaultChemObjectBuilder.getInstance(), true);
tmpReaders[i] = tmpReader;
}
} catch (FileNotFoundException aFileNotFoundException) {
System.out.println("\nSD file could not be found. Test is ignored.");
Assume.assumeTrue(false);
return;
}
Aromaticity tmpDaylightModelAll = new Aromaticity(ElectronDonation.daylight(), Cycles.all());
Aromaticity tmpDaylightModelVertexShort = new Aromaticity(ElectronDonation.daylight(), Cycles.vertexShort());
Aromaticity tmpDaylightModelRelevant = new Aromaticity(ElectronDonation.daylight(), Cycles.relevant());
Aromaticity tmpDaylightModelEssential = new Aromaticity(ElectronDonation.daylight(), Cycles.essential());
Aromaticity tmpDaylightModelTripleShort = new Aromaticity(ElectronDonation.daylight(), Cycles.tripletShort());
Aromaticity tmpDaylightModelCdkAromaticSet = new Aromaticity(ElectronDonation.daylight(), Cycles.cdkAromaticSet());
boolean tmpAreMultiplesCounted = false;
this.calculateAbsoluteFGFrequencies(tmpReaders[0], "all", tmpDaylightModelAll, tmpAreMultiplesCounted);
this.calculateAbsoluteFGFrequencies(tmpReaders[1], "vertexShort", tmpDaylightModelVertexShort, tmpAreMultiplesCounted);
this.calculateAbsoluteFGFrequencies(tmpReaders[2], "relevant", tmpDaylightModelRelevant, tmpAreMultiplesCounted);
this.calculateAbsoluteFGFrequencies(tmpReaders[3], "essential", tmpDaylightModelEssential, tmpAreMultiplesCounted);
this.calculateAbsoluteFGFrequencies(tmpReaders[4], "tripletShort", tmpDaylightModelTripleShort, tmpAreMultiplesCounted);
this.calculateAbsoluteFGFrequencies(tmpReaders[5], "cdkAromaticSet", tmpDaylightModelCdkAromaticSet, tmpAreMultiplesCounted);
System.out.println("\nAll analyses are done!");
for (IteratingSDFReader tmpReader : tmpReaders) {
tmpReader.close();
}
this.saveData();
System.out.println("\nFinished!");
System.out.println("\nNumber of occured exceptions: " + this.exceptionsCounter);
}
use of org.openscience.cdk.aromaticity.Aromaticity in project ambit-mirror by ideaconsult.
the class AutomaticSmirksTestUtilities method applySmirks.
public List<String> applySmirks(String smrk, String smi) {
try {
SMIRKSManager smrkMan = new SMIRKSManager(SilentChemObjectBuilder.getInstance());
smrkMan.setFlagSSMode(SmartsConst.SSM_MODE.SSM_NON_IDENTICAL_FIRST);
smrkMan.setFlagProcessResultStructures(true);
smrkMan.setFlagClearHybridizationBeforeResultProcess(true);
smrkMan.setFlagClearImplicitHAtomsBeforeResultProcess(true);
smrkMan.setFlagClearAromaticityBeforeResultProcess(true);
smrkMan.setFlagAddImplicitHAtomsOnResultProcess(true);
smrkMan.setFlagConvertAddedImplicitHToExplicitOnResultProcess(false);
smrkMan.setFlagConvertExplicitHToImplicitOnResultProcess(true);
smrkMan.getSmartsParser().mSupportDoubleBondAromaticityNotSpecified = false;
smrkMan.setFlagApplyStereoTransformation(true);
SMIRKSReaction reaction = smrkMan.parse(smrk);
if (!smrkMan.getErrors().equals(""))
throw new RuntimeException("Invalid SMIRKS: " + smrkMan.getErrors());
IAtomContainer target = smilesParser.parseSmiles(smi);
for (IAtom atom : target.atoms()) if (atom.getFlag(CDKConstants.ISAROMATIC))
atom.setFlag(CDKConstants.ISAROMATIC, false);
for (IBond bond : target.bonds()) if (bond.getFlag(CDKConstants.ISAROMATIC))
bond.setFlag(CDKConstants.ISAROMATIC, false);
// do not add Hs: https://sourceforge.net/p/cdk/mailman/message/34608714/
// AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(target);
// CDKHydrogenAdder adder = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
// adder.addImplicitHydrogens(target);
MoleculeTools.convertImplicitToExplicitHydrogens(target);
// for our project, we want to use daylight aromaticity
// CDKHueckelAromaticityDetector.detectAromaticity(target);
Aromaticity aromaticity = new Aromaticity(ElectronDonation.daylight(), Cycles.or(Cycles.all(), Cycles.edgeShort()));
aromaticity.apply(target);
IAtomContainerSet resSet2 = smrkMan.applyTransformationWithSingleCopyForEachPos(target, null, reaction, SmartsConst.SSM_MODE.SSM_ALL);
List<String> result = new ArrayList<String>();
if (resSet2 != null)
for (int i = 0; i < resSet2.getAtomContainerCount(); i++) {
IAtomContainer mol = resSet2.getAtomContainer(i);
AtomContainerManipulator.suppressHydrogens(mol);
String smiles = SmilesGenerator.absolute().create(mol);
result.add(smiles);
}
return result;
} catch (Exception e) {
System.err.println(e.getMessage());
System.err.println("SMIRKS " + smrk);
System.err.println("SMILES " + smi);
// e.printStackTrace();
return null;
}
}
use of org.openscience.cdk.aromaticity.Aromaticity in project MORTAR by FelixBaensch.
the class ErtlFunctionalGroupsFinderFragmenter method setAromaticityInstance.
// </editor-fold>
//
// <editor-fold desc="Private methods">
/**
* Sets only the instance, not the property! So it is safe for the property to call this method when overriding set().
*/
private void setAromaticityInstance(ElectronDonation anElectronDonation, CycleFinder aCycleFinder) throws NullPointerException {
Objects.requireNonNull(anElectronDonation, "Given electron donation model is null.");
Objects.requireNonNull(aCycleFinder, "Given cycle finder algorithm is null.");
this.aromaticityModelInstance = new Aromaticity(anElectronDonation, aCycleFinder);
}
use of org.openscience.cdk.aromaticity.Aromaticity in project cdk by cdk.
the class SMARTSQueryToolTest method setAromaticity.
@Test
public void setAromaticity() throws Exception {
SMARTSQueryTool sqt = new SMARTSQueryTool("[a]", DefaultChemObjectBuilder.getInstance());
IAtomContainer furan = smiles("O1C=CC=C1");
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(furan);
sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.mcb()));
assertTrue(sqt.matches(furan, true));
sqt.setAromaticity(new Aromaticity(ElectronDonation.piBonds(), Cycles.mcb()));
assertFalse(sqt.matches(furan, true));
}
Aggregations