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;
}
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);
}
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;
}
Aggregations