Search in sources :

Example 1 with AliphaticSymbolAtom

use of org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom in project cdk by cdk.

the class SmartsQueryVisitor method visit.

public Object visit(ASTExplicitAtom node, Object data) {
    IQueryAtom atom;
    String symbol = node.getSymbol();
    if ("*".equals(symbol)) {
        atom = new AnyAtom(builder);
    } else if ("A".equals(symbol)) {
        atom = new AliphaticAtom(builder);
    } else if ("a".equals(symbol)) {
        atom = new AromaticAtom(builder);
    } else if ("o".equals(symbol) || "n".equals(symbol) || "c".equals(symbol) || "s".equals(symbol) || "p".equals(symbol) || "as".equals(symbol) || "se".equals(symbol)) {
        String atomSymbol = symbol.substring(0, 1).toUpperCase() + symbol.substring(1);
        atom = new AromaticSymbolAtom(atomSymbol, builder);
    } else if ("H".equals(symbol)) {
        atom = new HydrogenAtom(builder);
        atom.setSymbol(symbol.toUpperCase());
        atom.setMassNumber(1);
    } else if ("D".equals(symbol)) {
        atom = new HydrogenAtom(builder);
        atom.setSymbol(symbol.toUpperCase());
        atom.setMassNumber(2);
    } else if ("T".equals(symbol)) {
        atom = new HydrogenAtom(builder);
        atom.setSymbol(symbol.toUpperCase());
        atom.setMassNumber(3);
    } else {
        atom = new AliphaticSymbolAtom(symbol, builder);
    }
    return atom;
}
Also used : AliphaticAtom(org.openscience.cdk.isomorphism.matchers.smarts.AliphaticAtom) AromaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AromaticSymbolAtom) HydrogenAtom(org.openscience.cdk.isomorphism.matchers.smarts.HydrogenAtom) AliphaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom) IQueryAtom(org.openscience.cdk.isomorphism.matchers.IQueryAtom) AromaticAtom(org.openscience.cdk.isomorphism.matchers.smarts.AromaticAtom) AnyAtom(org.openscience.cdk.isomorphism.matchers.smarts.AnyAtom)

Example 2 with AliphaticSymbolAtom

use of org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom in project ambit-mirror by ideaconsult.

the class TestUtilities method testCDKStrangeIsomorphism.

@Test
public void testCDKStrangeIsomorphism() throws Exception {
    // Testing CDK isomorphism of C**C against SCCS --> it gives wrong
    // result
    // Setting search query 'C**C'
    QueryAtomContainer q = new QueryAtomContainer(SilentChemObjectBuilder.getInstance());
    // setting atoms
    IQueryAtom a0 = new AliphaticSymbolAtom("C", q.getBuilder());
    q.addAtom(a0);
    IQueryAtom a1 = new AnyAtom(q.getBuilder());
    q.addAtom(a1);
    IQueryAtom a2 = new AnyAtom(q.getBuilder());
    q.addAtom(a2);
    IQueryAtom a3 = new AliphaticSymbolAtom("C", q.getBuilder());
    q.addAtom(a3);
    // setting bonds
    OrderQueryBond b0 = new OrderQueryBond(IBond.Order.SINGLE, q.getBuilder());
    b0.setAtoms(new IAtom[] { a0, a1 });
    q.addBond(b0);
    OrderQueryBond b1 = new OrderQueryBond(IBond.Order.SINGLE, q.getBuilder());
    b1.setAtoms(new IAtom[] { a1, a2 });
    q.addBond(b1);
    OrderQueryBond b2 = new OrderQueryBond(IBond.Order.SINGLE, q.getBuilder());
    b2.setAtoms(new IAtom[] { a2, a3 });
    q.addBond(b2);
    // Creating 'SCCS' target molecule
    AtomContainer target = new AtomContainer();
    // atoms
    IAtom ta0 = new Atom("S");
    target.addAtom(ta0);
    IAtom ta1 = new Atom("C");
    target.addAtom(ta1);
    IAtom ta2 = new Atom("C");
    target.addAtom(ta2);
    IAtom ta3 = new Atom("S");
    target.addAtom(ta3);
    // bonds
    IBond tb0 = new Bond();
    tb0.setAtoms(new IAtom[] { ta0, ta1 });
    tb0.setOrder(IBond.Order.SINGLE);
    target.addBond(tb0);
    IBond tb1 = new Bond();
    tb1.setAtoms(new IAtom[] { ta1, ta2 });
    tb1.setOrder(IBond.Order.SINGLE);
    target.addBond(tb1);
    IBond tb2 = new Bond();
    tb2.setAtoms(new IAtom[] { ta2, ta3 });
    tb2.setOrder(IBond.Order.SINGLE);
    target.addBond(tb2);
    // Isomorphism check
    boolean res = uit.isSubgraph(target, q);
    System.out.println("Mapping C**C against SCCS = " + res);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) QueryAtomContainer(org.openscience.cdk.isomorphism.matchers.QueryAtomContainer) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) AliphaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom) IQueryAtom(org.openscience.cdk.isomorphism.matchers.IQueryAtom) IBond(org.openscience.cdk.interfaces.IBond) OrderQueryBond(org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond) Bond(org.openscience.cdk.Bond) OrderQueryBond(org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond) IBond(org.openscience.cdk.interfaces.IBond) QueryAtomContainer(org.openscience.cdk.isomorphism.matchers.QueryAtomContainer) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) AnyAtom(org.openscience.cdk.isomorphism.matchers.smarts.AnyAtom) IQueryAtom(org.openscience.cdk.isomorphism.matchers.IQueryAtom) Atom(org.openscience.cdk.Atom) AliphaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom) IAtom(org.openscience.cdk.interfaces.IAtom) AnyAtom(org.openscience.cdk.isomorphism.matchers.smarts.AnyAtom) Test(org.junit.Test)

Example 3 with AliphaticSymbolAtom

use of org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom in project cdk by cdk.

the class SmartsQueryVisitor method visit.

public Object visit(ASTElement node, Object data) {
    String symbol = node.getSymbol();
    SMARTSAtom atom;
    if ("o".equals(symbol) || "n".equals(symbol) || "c".equals(symbol) || "s".equals(symbol) || "p".equals(symbol) || "as".equals(symbol) || "se".equals(symbol)) {
        String atomSymbol = symbol.substring(0, 1).toUpperCase() + symbol.substring(1);
        atom = new AromaticSymbolAtom(atomSymbol, builder);
    } else {
        atom = new AliphaticSymbolAtom(symbol, builder);
    }
    return atom;
}
Also used : AromaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AromaticSymbolAtom) SMARTSAtom(org.openscience.cdk.isomorphism.matchers.smarts.SMARTSAtom) AliphaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom)

Aggregations

AliphaticSymbolAtom (org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom)3 IQueryAtom (org.openscience.cdk.isomorphism.matchers.IQueryAtom)2 AnyAtom (org.openscience.cdk.isomorphism.matchers.smarts.AnyAtom)2 AromaticSymbolAtom (org.openscience.cdk.isomorphism.matchers.smarts.AromaticSymbolAtom)2 Test (org.junit.Test)1 Atom (org.openscience.cdk.Atom)1 AtomContainer (org.openscience.cdk.AtomContainer)1 Bond (org.openscience.cdk.Bond)1 IAtom (org.openscience.cdk.interfaces.IAtom)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1 IBond (org.openscience.cdk.interfaces.IBond)1 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)1 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)1 AliphaticAtom (org.openscience.cdk.isomorphism.matchers.smarts.AliphaticAtom)1 AromaticAtom (org.openscience.cdk.isomorphism.matchers.smarts.AromaticAtom)1 HydrogenAtom (org.openscience.cdk.isomorphism.matchers.smarts.HydrogenAtom)1 OrderQueryBond (org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond)1 SMARTSAtom (org.openscience.cdk.isomorphism.matchers.smarts.SMARTSAtom)1