use of org.openscience.cdk.isomorphism.matchers.OrderQueryBond in project cdk by cdk.
the class SMARTSTest method testSMARTS.
@Test
public void testSMARTS() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
SmilesParser sp = new SmilesParser(builder);
// acetic acid anhydride
IAtomContainer atomContainer = sp.parseSmiles("CC(=O)OC(=O)C");
QueryAtomContainer query = new QueryAtomContainer(builder);
AnyAtom atom1 = new AnyAtom(builder);
SymbolQueryAtom atom2 = new SymbolQueryAtom(builder);
atom2.setSymbol("C");
query.addAtom(atom1);
query.addAtom(atom2);
query.addBond(new OrderQueryBond(atom1, atom2, IBond.Order.DOUBLE, builder));
Assert.assertTrue(uiTester.isSubgraph(atomContainer, query));
}
use of org.openscience.cdk.isomorphism.matchers.OrderQueryBond in project cdk by cdk.
the class SMARTSTest method testImplicitHCountAtom.
@Test
public void testImplicitHCountAtom() throws Exception {
IAtomContainer container = createEthane();
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
// SMARTS [h3][h3]
QueryAtomContainer query1 = new QueryAtomContainer(builder);
SMARTSAtom atom1 = new ImplicitHCountAtom(3, builder);
SMARTSAtom atom2 = new ImplicitHCountAtom(3, builder);
query1.addAtom(atom1);
query1.addAtom(atom2);
query1.addBond(new OrderQueryBond(atom1, atom2, IBond.Order.SINGLE, builder));
Assert.assertTrue(uiTester.isSubgraph(container, query1));
}
use of org.openscience.cdk.isomorphism.matchers.OrderQueryBond in project cdk by cdk.
the class SMARTSTest method testImplicitHCountAtom2.
@Test
public void testImplicitHCountAtom2() throws Exception {
IAtomContainer container = createEthane();
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
// SMARTS [h3][h2]
QueryAtomContainer query1 = new QueryAtomContainer(builder);
SMARTSAtom atom1 = new ImplicitHCountAtom(3, builder);
SMARTSAtom atom2 = new ImplicitHCountAtom(2, builder);
query1.addAtom(atom1);
query1.addAtom(atom2);
query1.addBond(new OrderQueryBond(atom1, atom2, IBond.Order.SINGLE, builder));
Assert.assertFalse(uiTester.isSubgraph(container, query1));
}
use of org.openscience.cdk.isomorphism.matchers.OrderQueryBond in project cdk by cdk.
the class CDKMCSTest method testSFBug1708336.
/**
* @cdk.bug 1708336
* @throws Exception
*/
@Test
public void testSFBug1708336() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IAtomContainer atomContainer = builder.newInstance(IAtomContainer.class);
atomContainer.addAtom(builder.newInstance(IAtom.class, "C"));
atomContainer.addAtom(builder.newInstance(IAtom.class, "C"));
atomContainer.addAtom(builder.newInstance(IAtom.class, "N"));
atomContainer.addBond(0, 1, IBond.Order.SINGLE);
atomContainer.addBond(1, 2, IBond.Order.SINGLE);
IQueryAtomContainer query = new QueryAtomContainer(DefaultChemObjectBuilder.getInstance());
IQueryAtom a1 = new SymbolQueryAtom(DefaultChemObjectBuilder.getInstance());
a1.setSymbol("C");
AnyAtom a2 = new AnyAtom(DefaultChemObjectBuilder.getInstance());
IBond b1 = new OrderQueryBond(a1, a2, IBond.Order.SINGLE, DefaultChemObjectBuilder.getInstance());
IQueryAtom a3 = new SymbolQueryAtom(DefaultChemObjectBuilder.getInstance());
a3.setSymbol("C");
IBond b2 = new OrderQueryBond(a2, a3, IBond.Order.SINGLE, DefaultChemObjectBuilder.getInstance());
query.addAtom(a1);
query.addAtom(a2);
query.addAtom(a3);
query.addBond(b1);
query.addBond(b2);
List<List<CDKRMap>> list = CDKMCS.getSubgraphMaps(atomContainer, query, true);
Assert.assertTrue(list.isEmpty());
}
use of org.openscience.cdk.isomorphism.matchers.OrderQueryBond in project cdk by cdk.
the class SMARTSTest method testMatchInherited.
@Test
public void testMatchInherited() {
try {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
SymbolQueryAtom c1 = new SymbolQueryAtom(new org.openscience.cdk.Atom("C"));
SymbolAndChargeQueryAtom c2 = new SymbolAndChargeQueryAtom(new org.openscience.cdk.Atom("C"));
IAtomContainer c = TestMoleculeFactory.makeAlkane(2);
QueryAtomContainer query1 = new QueryAtomContainer(builder);
query1.addAtom(c1);
query1.addAtom(c2);
query1.addBond(new OrderQueryBond(c1, c2, Order.SINGLE, builder));
Assert.assertTrue(uiTester.isSubgraph(c, query1));
QueryAtomContainer query = new QueryAtomContainer(builder);
query.addAtom(c1);
query.addAtom(c2);
query.addBond(new AnyOrderQueryBond(c1, c2, Order.SINGLE, builder));
Assert.assertTrue(uiTester.isSubgraph(c, query));
} catch (CDKException exception) {
Assert.fail(exception.getMessage());
}
}
Aggregations