Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Result JSONs or lines from a JSONL file can be loaded into Python using RetroMol

### Using custom rules

RetroMol comes with a default set of retrosynthetic rules for modular natural products. See [the default rules](src/retromol/data/) for examples of the included rules.
RetroMol comes with a default set of retrosynthetic rules for modular natural products. See the [rule-writing guide](src/retromol/data/README.md) for all supported settings, examples, and how matching and reaction rules work together.

## Attribution

Expand Down
19 changes: 19 additions & 0 deletions gui/src/client/src/components/workspace/WorkspaceRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ function MatchingRuleRow({ rule }: { rule: MatchingRule }) {
</Box>
)}

{rule.terminal && (
<Typography variant="body2" color="text.secondary">
{rule.preserveAcrossRoutes
? "Protect this fragment from subdivision across alternative routes."
: "Stop at this fragment within its own route; allow other routes to divide it differently."}
</Typography>
)}
<PropsList props={rule.props} />
</Stack>
</Stack>
Expand Down Expand Up @@ -202,6 +209,18 @@ function ReactionRuleRow({ rule }: { rule: ReactionRule }) {
</Box>
</Box>

{Object.keys(rule.productMaxMatches).length > 0 && (
<Box>
<Typography variant="caption" color="text.secondary">
Maximum matches per product
</Typography>
{Object.entries(rule.productMaxMatches).map(([pattern, limit]) => (
<Typography key={pattern} variant="body2" sx={{ fontFamily: "monospace" }}>
{pattern}: {limit}
</Typography>
))}
</Box>
)}
<PropsList props={rule.props} />
</Stack>
</Collapse>
Expand Down
2 changes: 2 additions & 0 deletions gui/src/client/src/features/rules/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const MatchingRuleSchema = z.object({
pseudonyms: z.array(z.string()),
terminal: z.boolean(),
stereochemistry: z.boolean(),
preserveAcrossRoutes: z.boolean(),
props: z.record(z.string(), z.any()),
});
export type MatchingRule = z.output<typeof MatchingRuleSchema>;
Expand All @@ -19,6 +20,7 @@ export const ReactionRuleSchema = z.object({
name: z.string(),
smarts: z.string(),
allowedInBulk: z.boolean(),
productMaxMatches: z.record(z.string(), z.number().int().nonnegative()),
props: z.record(z.string(), z.any()),
});
export type ReactionRule = z.output<typeof ReactionRuleSchema>;
Expand Down
2 changes: 2 additions & 0 deletions gui/src/server/routes/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def rule_set() -> tuple[Response, int]:
"pseudonyms": r.pseudonyms,
"terminal": r.terminal,
"stereochemistry": r.stereochemistry,
"preserveAcrossRoutes": r.preserve_across_routes,
"props": r.props,
}
for r in rules.matching_rules
Expand All @@ -129,6 +130,7 @@ def rule_set() -> tuple[Response, int]:
"name": r.name,
"smarts": r.smarts,
"allowedInBulk": r.allowed_in_bulk,
"productMaxMatches": r.product_max_matches,
"props": r.props,
}
for r in rules.reaction_rules
Expand Down
191 changes: 191 additions & 0 deletions src/retromol/data/README.md

Large diffs are not rendered by default.

Loading
Loading