rdkit / mmpdb

A package to identify matched molecular pairs and use them to predict property changes.
Other
214 stars 58 forks source link

mmpdb fragment fails with RDKit 2024.03.6 or newer #65

Closed ricrogz closed 2 weeks ago

ricrogz commented 1 month ago

mmpdb 3.1, with RDKit 2024.03.6 or newer fails when trying to use mmpdb fragment:

$ mmpdb fragment --delimiter tab --max-rotatable-bonds 30 input.smi -j1 --output output.fragments
/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_db.py:61: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
  _schema_template = importlib.resources.read_text(
/tmp/testinternal/lib/python3.11/importlib/resources/_legacy.py:80: DeprecationWarning: open_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
  with open_text(package, resource, encoding, errors) as fp:
Failure: file 'input.smi', line 1, record #1: first line starts 'N=C1/C(=N/Nc2cccc(Cl)c2)C(=O)N=C2N=NNN12 ...'
/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_db.py:68: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
  return importlib.resources.read_text(
Traceback (most recent call last):
  File "/tmp/test/mmpdb_venv/bin/mmpdb", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/tmp/testinternal/lib/python3.11/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/testinternal/lib/python3.11/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/tmp/testinternal/lib/python3.11/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/testinternal/lib/python3.11/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/testinternal/lib/python3.11/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/cli/fragment_click.py", line 215, in make_fragment_options_wrapper
    return command(**kwargs)
           ^^^^^^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/cli/smi_utils.py", line 98, in make_input_options_wrapper
    return command(**kwargs)
           ^^^^^^^^^^^^^^^^^
  File "/tmp/testinternal/lib/python3.11/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/cli/fragment.py", line 268, in fragment
    writer.write_records(records)
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_db.py", line 311, in write_records
    for rec in fragment_records:
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_records.py", line 192, in make_fragment_records
    fragments = result.get()
                ^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_records.py", line 133, in get
    return self.f(*self.args)
           ^^^^^^^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_records.py", line 41, in _as_list
    return list(method(normalized_mol, fragment_filter, num_normalized_heavies))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_algorithm.py", line 819, in fragment_mol
    for fragmentation in fragmentations:
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_algorithm.py", line 689, in make_multiple_cuts
    smiles_index_to_atom_index = get_atom_order_in_smiles(fragmented_mol)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/mmpdb_venv/lib/python3.11/site-packages/mmpdblib/fragment_algorithm.py", line 90, in get_atom_order_in_smiles
    assert s[i:] == "]", (s, i, s[i:])
           ^^^^^^^^^^^^
AssertionError: ('[22,10,21,4,3,2,1,0,19,18,17,16,15,14,12,13,20,5,6,7,8,9,23,11]', 60, '11]')

I know what the issue is, and will post a Pull Request soon.