aurio9923

Building a Compound Workspace with Claude Code: ChemOmni (4) Choosing Bioisostere Replacements from a Rule Table

When you look for bioisosteres of a substructure of a compound, you can ask, for example in ChemOmni, “Give me bioisosteres of this amide,” and the SMILES of the replaced structures come back at once. But whether a structure is a suitable replacement, whether the same replacement could be made at other places, and whether any known options are missing cannot be told until a person checks. In the previous article (Letting the AI Propose Analogs), 3 of the 119 proposals the AI wrote had a reason that did not match the structure.

So this time I added rule-based bioisostere replacement to ChemOmni. The AI writes neither the structure after the replacement nor the SMARTS that defines it. It only chooses IDs from the rule table; RDKit finds every place where the rules fit, merges the results that are the same by symmetry, and lays them out in a grid tab labeled with the rule names. I tried it on imatinib, sending the same requests six times each to OpenAI’s gpt-6.1-terra.

Source code: https://github.com/aurio9923/chemomni (MIT license)

The rule table and two tools

The rule table has 80 rules in 8 groups (amides and esters 11, carboxylic acids 9, heteroaryl switches 10, linkers 8, phenols and polar groups 8, phenyl rings 11, saturated rings and chains 11, substituents 12). One rule consists of the reaction that defines the replacement (SMARTS), a name, a class, risk notes, sources, and tests on real drugs and similar molecules. Table 1 shows one rule as an example: the replacement of an amide by a 1,2,3-triazole.

ItemContent
ID and nameamide_to_click_triazole: secondary amide → triazole (click type)
Reaction[#6:1][CX3R0](=O)[NX3H1R0][#6;!$(C=O):2]>>[#6:1]c1cn([#6:2])nn1
ClassNonclassical
Risk notesPotency: the hydrogen-bond donor is limited to the weakly polarized methine hydrogen, so potency can drop at sites that need a strong donor. Metabolism: a nitrogen atom with a lone pair can coordinate to the heme iron of cytochrome enzymes and inhibit them (both with medium confidence)
SourcesKumari et al. (J Med Chem 2020), Meanwell (J Med Chem 2011)
Tests2 molecules in which the replacement should occur (acetaminophen and others), 1 in which it should not (a tertiary benzamide)

Table 1. The contents of one rule.

I checked the rule table entry by entry, and 80 rules are enabled. The sources are 20 papers and reviews, and every DOI exists in Crossref. Each rule comes with tests: 174 molecules in all in which the replacement should occur (with the expected products) and 95 in which it should not. When I re-ran the reactions with RDKit, the former gave the expected products (for 3 of them after normalizing the way the tautomer is written) and the latter gave nothing.

The two tools implemented inside the app are these. find_bioisosteres returns the rules that fit the selected part (the whole molecule if nothing is selected), together with the number of places, the number of products, and risk notes (at most 2 per rule). apply_bioisosteres takes IDs that find returned, applies them at every place where they fit, and lays the products out in a new tab. At most 20 products appear in the tab. When there are more, it returns how many others there were and which rules have no product on the tab. The AI only chooses IDs and does not write the SMILES after the replacement. Each product is labeled with the rule’s ID and name, and the replaced part is shown in red.

Trying it on imatinib

I used the same imatinib as before and made the following four requests to gpt-6.1-terra, six times each. Before each request I selected the target substructure in the editor (Example 4 is the one scenario in which nothing is selected). All requests were typed in Japanese, so the chat in the screenshots is in Japanese; I give English translations of the requests here.

Example 1: Select the amide and ask

Give me bioisosteres of the selected amide

The AI looked up the rules that fit with find_bioisosteres and applied the 11 it found with apply_bioisosteres (Figure 1). Eleven products lined up in a new tab, and each tile shows the rule’s ID, the similarity to the parent, and the replaced part highlighted in red. The values in the property table are calculated by RDKit. The reversed amide (#9) has the same molecular formula as the parent, so its MW, cLogP, and TPSA do not differ from the parent’s (493.62, 4.59, 86.3 Ų), and this table alone cannot tell them apart. In 5 of the 6 runs, it applied the same 11 rules.

The ChemOmni screen: 11 rules applied to the selected amide, with 11 products lined up in a new tab. The chat shows the rule IDs and names, the similarity to the parent, drawings with the replaced part in red, and a table of properties An enlargement of the chat panel on the right of the screen above, from top to bottom: the question “Give me bioisosteres of the selected amide,” the calls to find_bioisosteres (11 rule(s) fit) and apply_bioisosteres (11 product(s)), tiles for the parent and 11 products (rule IDs and names, similarity to the parent, the replaced part in red), the table of properties, and the AI’s answer
Figure 1. Result of Example 1 (gpt-6.1-terra). The upper image is the whole screen: the newly opened tab on the left and the chat on the right. The lower image is an enlargement of the chat output: the results of find and apply, the 11 products (rule IDs and names, similarity, the replaced part in red), the table of properties, and the AI’s answer. The chat is in Japanese because the request was.

Example 2: Select the ring on the benzamide side and ask

Replace the selected phenyl ring with a bioisostere

When the para-disubstituted phenyl ring on the benzamide side is selected, 5 rules fit (bicyclo[1.1.1]pentane, bicyclo[2.2.2]octane, thiophene, thiazole, and cyclohexane), and the result was 6 products (Figure 2). The thiazole can be oriented in two ways, which gives two products (#4 and #6). In all 6 runs, the rules and products were the same: 5 rules and 6 products.

The ChemOmni screen: 5 rules applied to the phenyl ring on the benzamide side, with 6 products lined up in the tab. The chat shows the rule IDs and names, drawings with the replaced part in red, and a table of properties An enlargement of the chat panel on the right of the screen above, from top to bottom: the question “Replace the selected phenyl ring with a bioisostere,” the calls to find_bioisosteres (5 rule(s) fit) and apply_bioisosteres (6 product(s)), tiles for the parent and 6 products (rule IDs and names, similarity to the parent, the replaced part in red), the table of properties, and the AI’s answer
Figure 2. Result of Example 2 (gpt-6.1-terra). The upper image is the whole screen and the lower image is an enlargement of the chat output. Five rules give 6 products. The thiazoles (#4 and #6) are two products that differ in orientation. The chat is in Japanese because the request was.

Example 3: Send the same request with a different ring selected

When I sent the same sentence with the central tolyl ring (the ring with three substituents) selected, find_bioisosteres returned “0 rule(s) fit,” and no products appeared (Figure 3). A rule fits only when the part it replaces lies entirely inside the selection. The rules that replace a para-disubstituted phenylene do not fit this trisubstituted ring. The tool also returned that there are rules that fit outside the selection (19 for the whole molecule; 5 within the group when one was specified), and the AI told me so and did not make any replacement.

The ChemOmni screen: the central tolyl ring is selected in green, and the chat shows “find_bioisosteres · 0 rule(s) fit” and the AI’s answer that no rule fits An enlargement of the chat panel on the right of the screen above: after the question “Replace the selected phenyl ring with a bioisostere,” the call to find_bioisosteres (0 rule(s) fit) appears, and the AI answers that no replacement rule applies to the selected phenyl ring, that this ring has three substituents, and that the rules fit at another position
Figure 3. Result of sending the same request with the central tolyl ring (green) selected (gpt-6.1-terra). The upper image is the whole screen and the lower image is an enlargement of the chat output. No rule fits inside the selection, so no products appear. The chat is in Japanese because the request was.

In all 6 runs, the AI did not go on to apply anything and answered that no rule fits. Every answer mentions that the rules that fit are outside the selection.

Example 4: Ask without selecting anything

Tell me where in this compound a bioisosteric replacement might be possible

When I asked without selecting anything, find_bioisosteres examined the whole molecule and returned that 19 rules fit. There are four places where they fit: the amide (11 rules), the para-disubstituted phenyl ring connecting the amide and the piperazine (5 rules), the piperazine ring (1 rule, replacement by a diazaspiroheptane), and the methyl group on the aromatic ring (2 rules, chlorine and trifluoromethyl). No rule fits the pyridine ring, the pyrimidine ring, or the NH of the aminopyrimidine. In all 6 runs it named these four places.

Checking the results

I checked the records of 24 runs (4 requests × 6 runs) in the following three ways.

Do the products match what the rules give?

Separately from the app, I applied the reactions of the rule table to the parent with RDKit, rebuilt the products at every position, and compared them with the products the app showed. In the 18 runs that produced products, all matched; in the 6 runs that produced none (Example 3), no rule had been applied, and that matched too. In all 24 runs, no product was missing and none was extra. Because the AI does not write structures, what is checked here is whether the tool applies the rules the AI chose at every position.

How many rules the AI chose

The AI applied every rule that fit in 5 of 6 runs of Example 1 (11 rules), in 6 of 6 of Example 2 (5 rules), and in 6 of 6 of Example 4 (19 rules). In the remaining run of Example 1, it specified the “amides and esters group” in find_bioisosteres, so only 9 rules came back and the result was 9 products. The sulfonamide and urea rules are in another group (linkers), so the AI never learned that they exist. Its answer only stated the number, “9 kinds,” and did not say that the other groups also contain amide replacements. A reader is more likely to take it that this is all the amide replacements there are.

Chat answers

I also checked, in the chat answers, the places that mention the number of products and the risks. In the 12 runs of Examples 1 and 2, the number of products stated first agreed with the number in the tab (11 or 9 in Example 1, 6 in Example 2). The risk statements that appeared in the answers to Examples 1, 2, and 4 (that oxadiazoles lose hydrogen-bond-donor ability, reactive metabolites of thioamides, the new stereocenter of trifluoroethylamines, interaction of triazoles and imidazoles with metabolic enzymes, reactive metabolites of thiophenes, cis/trans isomerism of cyclohexane, and so on) agreed with what the risk notes the AI received say. There was no discrepancy.

Design decisions

  • The AI does not write structures; it chooses rule IDs. The definition of each replacement lives in the rule table that a person has checked. The AI can choose only IDs that find returned.
  • RDKit finds every place where a rule fits. Places that are the same by symmetry are merged into one, and so are products that two rules give as the same molecule.
  • Only replacements whose replaced part lies inside the selection are applied. The parts you did not select do not change.
  • Two steps. First it shows the rules that fit and their risk notes, and the AI then chooses and applies.
  • Limit the products to 20. At most 20 products appear in the tab. When there are more, the result returns how many others there were, the rules that have no product on the tab, and how to narrow down.

Next time

Next time I will introduce importing and exporting SDF files. It lays out several structures on a numbered grid, adds properties, and writes them out as SDF or CSV.

Notes

  • Model: OpenAI gpt-6.1-terra (Responses API; reasoning effort low is the app’s default). Figures 1–3 are also results of this model.
  • Language: all requests were sent in Japanese, so the AI’s answers are in Japanese. The requests quoted in the text are my translations. This article translates the results of the Japanese runs; the runs were not repeated in English.
  • Repetition: each of the 4 requests was sent 6 times (24 runs in all), redrawing imatinib each time, selecting the part again, and sending the request in a new chat.
  • Structure: imatinib Cc1ccc(NC(=O)c2ccc(CN3CCN(C)CC3)cc2)cc1Nc1nccc(-c2cccnc2)n1.
  • Checking the products: I applied the reactions of the rule table to the parent with RDKit 2026.09.2 RunReactants and compared the SMILES, normalized without stereochemistry, with the products in the app’s tab.
  • Checking the rule table: 80 rules (4 of the 84 are not applicable). I looked up the 20 source DOIs in Crossref and re-ran the tests with RDKit (174 molecules in which the replacement should occur and 95 in which it should not; 3 of the former agreed after normalizing the way the tautomer is written).
  • Chat answers: I compared the number of products and the places that mention risks with the results of the tools and with the risk notes the AI received.