|
9 | 9 | import pyparsing as pp |
10 | 10 | from numpy.typing import ArrayLike |
11 | 11 | from pyparsing import pyparsing_common as ppc |
| 12 | +from rdkit.Chem.inchi import MolBlockToInchiAndAuxInfo |
12 | 13 | from phydat import phycon |
13 | 14 |
|
14 | 15 | from .. import vmat |
@@ -340,38 +341,10 @@ def inchi_with_numbers(geo, stereo=True, gra=None): |
340 | 341 | gra = graph_base.set_stereo_from_geometry(gra, geo) |
341 | 342 |
|
342 | 343 | mlf, key_map_inv = molfile_with_atom_mapping(gra, geo=geo) |
343 | | - rdm = rdkit_.from_molfile(mlf) |
344 | | - ich, aux_info = rdkit_.to_inchi(rdm, with_aux_info=True) |
| 344 | + ich, aux_info = MolBlockToInchiAndAuxInfo(mlf) |
345 | 345 |
|
346 | 346 | nums_lst = _parse_sort_order_from_aux_info(aux_info) |
347 | 347 | nums_lst = tuple(tuple(map(key_map_inv.__getitem__, nums)) for nums in nums_lst) |
348 | | - |
349 | | - # Assuming the MolFile InChI works, the above code is all we need. What |
350 | | - # follows is to correct cases where it fails. |
351 | | - # This only appears to work sometimes, so when it doesn't, we fall back on |
352 | | - # the original inchi output. |
353 | | - if geo is not None: |
354 | | - gra = graph_base.set_stereo_from_geometry(gra, geo) |
355 | | - gra = graph_base.implicit(gra) |
356 | | - sub_ichs = inchi_base.split(ich) |
357 | | - |
358 | | - failed = False |
359 | | - |
360 | | - new_sub_ichs = [] |
361 | | - for sub_ich, nums in zip(sub_ichs, nums_lst): |
362 | | - sub_gra = graph_base.subgraph(gra, nums, stereo=True) |
363 | | - sub_ich = _connected_inchi_with_graph_stereo(sub_ich, sub_gra, nums) |
364 | | - if sub_ich is None: |
365 | | - failed = True |
366 | | - break |
367 | | - |
368 | | - new_sub_ichs.append(sub_ich) |
369 | | - |
370 | | - # If it worked, replace the InChI with our forced-stereo InChI. |
371 | | - if not failed: |
372 | | - ich = inchi_base.join(new_sub_ichs) |
373 | | - ich = inchi_base.standard_form(ich) |
374 | | - |
375 | 348 | return ich, nums_lst |
376 | 349 |
|
377 | 350 |
|
|
0 commit comments