You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace matched-substructure SVG image output with completeSmiles
Remove the SVG depiction feature from substructure search: the func:withImages
input, func:matchedImage output, the with_images engine flag / matched_images
field, and the highlight_match_svg helper (plus its rdDepictor/rdMolDraw2D
imports).
Add a func:completeSmiles output instead: the original, complete SMILES string
of the matching compound as stored in the service (repeated per matched-fragment
row), complementing the per-match matchedSmiles/matchedSmarts.
Docs regenerated and tests updated accordingly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+3-17Lines changed: 3 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,7 +280,6 @@ differently by RDKit:
280
280
|`func:dbNames`|`UnionType[str, NoneType]`|`None`| Optional database name to limit the search. |
281
281
|`func:minMatchCount`|`int`|`1`| Minimum number of substructure matches required. |
282
282
|`func:useChirality`|`bool`|`False`| If true, both tetrahedral (R/S) and double-bond (E/Z) stereochemistry are enforced during matching. Defaults to false. Most meaningful for SMILES queries; SMARTS encodes its own stereo in the pattern. |
283
-
|`func:withImages`|`bool`|`False`| If true, populate func:matchedImage with an SVG of the database molecule, matched substructure highlighted. Defaults to false (rendering is comparatively expensive). |
284
283
285
284
**Outputs:**
286
285
@@ -290,7 +289,7 @@ differently by RDKit:
290
289
|`func:matchCount`|`int`| Number of matches found (1 if boolean match). |
291
290
|`func:matchedSmiles`|`str`| SMILES of the matched fragment, rendered from the target (stereo preserved). |
292
291
|`func:matchedSmarts`|`str`| SMARTS of the matched fragment, rendered from the target (stereo preserved). |
293
-
|`func:matchedImage`|`str`|SVG depiction of the database molecule with the matched substructure highlighted (empty unless func:withImages is true). |
292
+
|`func:completeSmiles`|`str`|The original, complete SMILES string of the matching compound as stored in the service. |
Copy file name to clipboardExpand all lines: src/mol_search_sparql_service/sparql_service.py
+12-31Lines changed: 12 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,8 @@ class SubstructureSearchResult:
23
23
"""SMILES of the matched fragment, rendered from the target (stereo preserved)."""
24
24
matchedSmarts: str
25
25
"""SMARTS of the matched fragment, rendered from the target (stereo preserved)."""
26
-
matchedImage: str
27
-
"""SVG depiction of the database molecule with the matched substructure highlighted (empty unless func:withImages is true)."""
26
+
completeSmiles: str
27
+
"""The original, complete SMILES string of the matching compound as stored in the service."""
28
28
29
29
30
30
@dataclass
@@ -178,7 +178,6 @@ def substructure_search(
178
178
db_names: str|None=None,
179
179
min_match_count: int=1,
180
180
use_chirality: bool=False,
181
-
with_images: bool=False,
182
181
) ->list[SubstructureSearchResult]:
183
182
"""Perform substructure search using a SMARTS or SMILES query pattern.
184
183
@@ -199,7 +198,6 @@ def substructure_search(
199
198
db_names: Optional database name to limit the search.
200
199
min_match_count: Minimum number of substructure matches required.
201
200
use_chirality: If true, both tetrahedral (R/S) and double-bond (E/Z) stereochemistry are enforced during matching. Defaults to false. Most meaningful for SMILES queries; SMARTS encodes its own stereo in the pattern.
202
-
with_images: If true, populate func:matchedImage with an SVG of the database molecule, matched substructure highlighted. Defaults to false (rendering is comparatively expensive).
203
201
204
202
Example (SMARTS):
205
203
```sparql
@@ -214,28 +212,16 @@ def substructure_search(
214
212
}
215
213
```
216
214
217
-
Example (SMILES):
215
+
Example (SMILES, with the complete molecule SMILES):
218
216
```sparql
219
217
PREFIX func: <urn:sparql-function:>
220
-
SELECT ?result ?matchCount ?matchedSmiles ?matchedSmarts WHERE {
218
+
SELECT ?result ?matchCount ?matchedSmiles ?completeSmiles WHERE {
221
219
[] a func:SubstructureSearch ;
222
220
func:smiles "c1ccccc1" ;
223
221
func:result ?result ;
224
222
func:matchCount ?matchCount ;
225
223
func:matchedSmiles ?matchedSmiles ;
226
-
func:matchedSmarts ?matchedSmarts .
227
-
}
228
-
```
229
-
230
-
Example (with highlighted SVG image):
231
-
```sparql
232
-
PREFIX func: <urn:sparql-function:>
233
-
SELECT ?result ?matchedImage WHERE {
234
-
[] a func:SubstructureSearch ;
235
-
func:smiles "c1ccccc1" ;
236
-
func:withImages true ;
237
-
func:result ?result ;
238
-
func:matchedImage ?matchedImage .
224
+
func:completeSmiles ?completeSmiles .
239
225
}
240
226
```
241
227
"""
@@ -259,27 +245,22 @@ def substructure_search(
259
245
min_match_count=min_match_count,
260
246
use_chirality=use_chirality,
261
247
query_type=query_type,
262
-
with_images=with_images,
263
248
)
264
-
# Emit one row per distinct matched fragment so each match's SMILES,
265
-
# SMARTS and image are individually bindable. Compounds with no
266
-
# renderable fragment still surface once with empty fragment strings.
249
+
# Emit one row per distinct matched fragment so each match's SMILES and
250
+
# SMARTS are individually bindable. completeSmiles is the full original
251
+
# molecule SMILES, repeated on every row for that compound. Compounds
252
+
# with no renderable fragment still surface once with empty fragments.
267
253
rows= []
268
254
forrinresults:
269
-
# matched_images is parallel to the fragment lists when with_images
0 commit comments