Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 064b0a3

Browse files
johnmayegonw
authored andcommitted
Additional test for converting "Molecules" to queries using the useful SMARTS therom: D=X+h.
1 parent 813c120 commit 064b0a3

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/matchers/QueryAtomContainer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,14 @@ public static void create(IAtomContainer dst,
17941794
if (optset.contains(IS_IN_CHAIN) && !atom.isInRing())
17951795
expr.and(new Expr(IS_IN_CHAIN));
17961796
if (optset.contains(IMPL_H_COUNT))
1797-
expr.and(new Expr(IMPL_H_COUNT));
1797+
expr.and(new Expr(IMPL_H_COUNT, atom.getImplicitHydrogenCount()));
1798+
if (optset.contains(TOTAL_H_COUNT)) {
1799+
int hcount = atom.getImplicitHydrogenCount();
1800+
for (IBond bond : src.getConnectedBondsList(atom))
1801+
if (bond.getOther(atom).getAtomicNumber() == AtomRef.H)
1802+
hcount++;
1803+
expr.and(new Expr(TOTAL_H_COUNT, hcount));
1804+
}
17981805
if (optset.contains(RING_BOND_COUNT)) {
17991806
int rbonds = 0;
18001807
for (IBond bond : src.getConnectedBondsList(atom))

tool/smarts/src/test/java/org/openscience/cdk/smarts/MolToQueryTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ public void elementAndConnectivityDegree() throws InvalidSmilesException {
9494
Expr.Type.ELEMENT, Expr.Type.TOTAL_DEGREE);
9595
}
9696

97+
@Test
98+
public void elementAndConnectivityAndTotHydrogenCount() throws InvalidSmilesException {
99+
test("[#6X3H1]1~[#6X3H1]~[#6X3H1]~[#6X3H1]~[#7X2H0]~[#6X3H0]~1~[#6X4H3]", "c1cccnc1C",
100+
Expr.Type.ELEMENT, Expr.Type.TOTAL_DEGREE, Expr.Type.TOTAL_H_COUNT);
101+
}
102+
103+
@Test
104+
public void elementAndConnectivityAndImplHydrogenCount() throws InvalidSmilesException {
105+
test("[#6X3h1]1~[#6X3h1]~[#6X3h1]~[#6X3h1]~[#7X2h0]~[#6X3h0]~1~[#6X4h3]", "c1cccnc1C",
106+
Expr.Type.ELEMENT, Expr.Type.TOTAL_DEGREE, Expr.Type.IMPL_H_COUNT);
107+
}
108+
97109
@Test
98110
public void complexDocExample() throws InvalidSmilesException {
99111
test("[nx2+0]1:[cx2+0]:[cx2+0]:[cx2+0](=[O&x0+0]):[cx2+0]:[cx2+0]:1",

0 commit comments

Comments
 (0)