Search in sources :

Example 16 with Aromaticity

use of org.openscience.cdk.aromaticity.Aromaticity in project cdk by cdk.

the class RecursiveTest method testRecursiveSmarts27_cdkAromaticModel.

@Test
public void testRecursiveSmarts27_cdkAromaticModel() throws Exception {
    SMARTSQueryTool sqt = smarts("[NX3;H2,H1;!$(NC=O)]");
    IAtomContainer smi = smiles("CCCc1nc(c2n1[nH]c(nc2=O)c1cc(ccc1OCC)S(=O)(=O)N1CCN(CC1)CC)C");
    sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()));
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(smi);
    int[] result = SMARTSSearchTest.match(sqt, smi);
    Assert.assertEquals(1, result[0]);
    Assert.assertEquals(1, result[1]);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Aromaticity(org.openscience.cdk.aromaticity.Aromaticity) SMARTSQueryTool(org.openscience.cdk.smiles.smarts.SMARTSQueryTool) Test(org.junit.Test) SlowTest(org.openscience.cdk.test.SlowTest)

Example 17 with Aromaticity

use of org.openscience.cdk.aromaticity.Aromaticity in project cdk by cdk.

the class RecursiveTest method testRecursiveSmarts26_cdkAromaticModel.

@Test
public void testRecursiveSmarts26_cdkAromaticModel() throws Exception {
    SMARTSQueryTool sqt = smarts("[NX3;H2,H1;!$(NC=O)]");
    IAtomContainer smi = smiles("CCCc1cc(=O)nc([nH]1)S");
    sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()));
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(smi);
    int[] result = SMARTSSearchTest.match(sqt, smi);
    Assert.assertEquals(1, result[0]);
    Assert.assertEquals(1, result[1]);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Aromaticity(org.openscience.cdk.aromaticity.Aromaticity) SMARTSQueryTool(org.openscience.cdk.smiles.smarts.SMARTSQueryTool) Test(org.junit.Test) SlowTest(org.openscience.cdk.test.SlowTest)

Example 18 with Aromaticity

use of org.openscience.cdk.aromaticity.Aromaticity in project cdk by cdk.

the class RecursiveTest method testRecursive29_cdkAromaticModel.

@Test
public void testRecursive29_cdkAromaticModel() throws Exception {
    SMARTSQueryTool sqt = smarts("[NX3;H2,H1;!$(NC=O)]");
    IAtomContainer smi = smiles("Cc1cc(=O)c(c[nH]1)C(=O)NC(c1ccc(cc1)O)C(=O)NC1C(=O)N2C1SCC(=C2C(=O)O)CSc1nnnn1C");
    sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet()));
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(smi);
    int[] result = SMARTSSearchTest.match(sqt, smi);
    Assert.assertEquals(1, result[0]);
    Assert.assertEquals(1, result[1]);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Aromaticity(org.openscience.cdk.aromaticity.Aromaticity) SMARTSQueryTool(org.openscience.cdk.smiles.smarts.SMARTSQueryTool) Test(org.junit.Test) SlowTest(org.openscience.cdk.test.SlowTest)

Example 19 with Aromaticity

use of org.openscience.cdk.aromaticity.Aromaticity in project cdk by cdk.

the class AminoAcids method createAAs.

/**
 * Creates amino acid AminoAcid objects.
 *
 * @return aminoAcids, a HashMap containing the amino acids as AminoAcids.
 */
public static synchronized AminoAcid[] createAAs() {
    if (aminoAcids != null) {
        return aminoAcids;
    }
    // amino-acids only have benzene aromaticity so we can run a simple
    // alternating pi-bond arom model to keep things in a consistent state
    Aromaticity arom = new Aromaticity(ElectronDonation.cdk(), Cycles.all(6));
    // Create set of AtomContainers
    aminoAcids = new AminoAcid[20];
    IChemFile list = new ChemFile();
    CMLReader reader = new CMLReader(AminoAcids.class.getClassLoader().getResourceAsStream("org/openscience/cdk/templates/data/list_aminoacids.cml"));
    try {
        list = reader.read(list);
        List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(list);
        Iterator<IAtomContainer> iterator = containersList.iterator();
        int counter = 0;
        while (iterator.hasNext()) {
            IAtomContainer ac = iterator.next();
            LOGGER.debug("Adding AA: ", ac);
            // convert into an AminoAcid
            AminoAcid aminoAcid = new AminoAcid();
            Iterator<IAtom> atoms = ac.atoms().iterator();
            for (Object next : ac.getProperties().keySet()) {
                LOGGER.debug("Prop class: " + next.getClass().getName());
                LOGGER.debug("Prop: " + next);
                if (next instanceof DictRef) {
                    DictRef dictRef = (DictRef) next;
                    // logger.debug("DictRef type: " + dictRef.getType());
                    if (dictRef.getType().equals("pdb:residueName")) {
                        aminoAcid.setProperty(RESIDUE_NAME, ac.getProperty(dictRef).toString().toUpperCase());
                        aminoAcid.setMonomerName(ac.getProperty(dictRef).toString());
                    } else if (dictRef.getType().equals("pdb:oneLetterCode")) {
                        aminoAcid.setProperty(RESIDUE_NAME_SHORT, ac.getProperty(dictRef));
                    } else if (dictRef.getType().equals("pdb:id")) {
                        aminoAcid.setProperty(ID, ac.getProperty(dictRef));
                        LOGGER.debug("Set AA ID to: " + ac.getProperty(dictRef));
                    } else {
                        LOGGER.error("Cannot deal with dictRef!");
                    }
                }
            }
            while (atoms.hasNext()) {
                IAtom atom = atoms.next();
                String dictRef = atom.getProperty("org.openscience.cdk.dict");
                if (dictRef != null && dictRef.equals("pdb:nTerminus")) {
                    aminoAcid.addNTerminus(atom);
                } else if (dictRef != null && dictRef.equals("pdb:cTerminus")) {
                    aminoAcid.addCTerminus(atom);
                } else {
                    aminoAcid.addAtom(atom);
                }
            }
            for (IBond bond : ac.bonds()) {
                aminoAcid.addBond(bond);
            }
            AminoAcidManipulator.removeAcidicOxygen(aminoAcid);
            aminoAcid.setProperty(NO_ATOMS, "" + aminoAcid.getAtomCount());
            aminoAcid.setProperty(NO_BONDS, "" + aminoAcid.getBondCount());
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(aminoAcid);
            arom.apply(aminoAcid);
            if (counter < aminoAcids.length) {
                aminoAcids[counter] = aminoAcid;
            } else {
                LOGGER.error("Could not store AminoAcid! Array too short!");
            }
            counter++;
        }
        reader.close();
    } catch (CDKException | IOException exception) {
        LOGGER.error("Failed reading file: ", exception.getMessage());
        LOGGER.debug(exception);
    }
    return aminoAcids;
}
Also used : DictRef(org.openscience.cdk.dict.DictRef) CMLReader(org.openscience.cdk.io.CMLReader) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Aromaticity(org.openscience.cdk.aromaticity.Aromaticity) IAminoAcid(org.openscience.cdk.interfaces.IAminoAcid) AminoAcid(org.openscience.cdk.AminoAcid) CDKException(org.openscience.cdk.exception.CDKException) IChemFile(org.openscience.cdk.interfaces.IChemFile) IBond(org.openscience.cdk.interfaces.IBond) IOException(java.io.IOException) IChemFile(org.openscience.cdk.interfaces.IChemFile) ChemFile(org.openscience.cdk.ChemFile) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 20 with Aromaticity

use of org.openscience.cdk.aromaticity.Aromaticity in project MetFragRelaunched by ipb-halle.

the class MoleculeFunctions method getAtomContainerFromSMILES.

public static IAtomContainer getAtomContainerFromSMILES(String smiles) throws Exception {
    SmilesParser sp = new SmilesParser(SilentChemObjectBuilder.getInstance());
    IAtomContainer molecule = sp.parseSmiles(smiles);
    for (int i = 0; i < molecule.getAtomCount(); i++) {
        if (molecule.getAtom(i).getSymbol().equals("H"))
            continue;
        else {
            java.util.List<IAtom> atoms = molecule.getConnectedAtomsList(molecule.getAtom(i));
            short numDs = 0;
            for (IAtom atom : atoms) if (atom.getSymbol().equals("H") && (atom.getMassNumber() != null && atom.getMassNumber() == 2))
                numDs++;
            molecule.getAtom(i).setProperty(VariableNames.DEUTERIUM_COUNT_NAME, numDs);
        }
    }
    try {
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
        Aromaticity arom = new Aromaticity(ElectronDonation.cdk(), Cycles.cdkAromaticSet());
        arom.apply(molecule);
    } catch (CDKException e) {
        e.printStackTrace();
    }
    return molecule;
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Aromaticity(org.openscience.cdk.aromaticity.Aromaticity) CDKException(org.openscience.cdk.exception.CDKException) BitSetFingerprint(org.openscience.cdk.fingerprint.BitSetFingerprint) IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint) IAtom(org.openscience.cdk.interfaces.IAtom)

Aggregations

Aromaticity (org.openscience.cdk.aromaticity.Aromaticity)23 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)15 Test (org.junit.Test)10 CDKException (org.openscience.cdk.exception.CDKException)10 IBond (org.openscience.cdk.interfaces.IBond)7 SMARTSQueryTool (org.openscience.cdk.smiles.smarts.SMARTSQueryTool)6 SlowTest (org.openscience.cdk.test.SlowTest)5 FastBitArray (de.ipbhalle.metfraglib.FastBitArray)4 IAtom (org.openscience.cdk.interfaces.IAtom)4 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 FileNotFoundException (java.io.FileNotFoundException)3 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)3 IteratingSDFReader (org.openscience.cdk.io.iterator.IteratingSDFReader)3 ExplicitHydrogenRepresentationException (de.ipbhalle.metfraglib.exceptions.ExplicitHydrogenRepresentationException)2 IOException (java.io.IOException)2 BitSetFingerprint (org.openscience.cdk.fingerprint.BitSetFingerprint)2 IBitFingerprint (org.openscience.cdk.fingerprint.IBitFingerprint)2 SmilesParser (org.openscience.cdk.smiles.SmilesParser)2 SMIRKSManager (ambit2.smarts.SMIRKSManager)1