Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unidentifiable C++ Exception with FMCS #3635

Closed
proteneer opened this issue Dec 12, 2020 · 1 comment
Closed

Unidentifiable C++ Exception with FMCS #3635

proteneer opened this issue Dec 12, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@proteneer
Copy link

Describe the bug
Using a custom AtomTyper and BondMCS parameters in conjunction results in an untranslated exception.

To Reproduce

mol_a = """338
                    3D
 Structure written by MMmdl.
 37 39  0  0  1  0            999 V2000
   27.6451    1.5396  -11.1263 O   0  0  0  0  0  0
   27.1573    0.3054  -11.6394 C   0  0  2  0  0  0
   26.5145    0.3811  -13.0370 C   0  0  0  0  0  0
   25.0296    0.6292  -12.8066 C   0  0  1  0  0  0
   24.8033   -0.0375  -11.4699 C   0  0  0  0  0  0
   26.0149   -0.2195  -10.7892 C   0  0  0  0  0  0
   26.0208   -0.7620   -9.4965 C   0  0  0  0  0  0
   24.8017   -1.0822   -8.8969 C   0  0  0  0  0  0
   23.6059   -0.9366   -9.5941 C   0  0  0  0  0  0
   23.6020   -0.4342  -10.9000 C   0  0  0  0  0  0
   22.4861   -0.2954  -11.6940 O   0  0  0  0  0  0
   21.2424   -0.5775  -11.1970 C   0  0  0  0  0  0
   20.6737   -1.8297  -11.4038 C   0  0  0  0  0  0
   19.4234   -2.1113  -10.8674 C   0  0  0  0  0  0
   18.8511   -3.3118  -11.0589 F   0  0  0  0  0  0
   18.7462   -1.1423  -10.1427 C   0  0  0  0  0  0
   19.2860    0.1245   -9.9701 C   0  0  0  0  0  0
   18.5760    1.1643   -9.2539 C   0  0  0  0  0  0
   20.5501    0.3903  -10.4736 C   0  0  0  0  0  0
   27.5283   -1.0639   -8.5710 S   0  0  0  0  0  0
   27.2110   -1.9989   -7.4925 O   0  0  0  0  0  0
   28.6000   -1.3708   -9.5178 O   0  0  0  0  0  0
   27.0777    1.2809  -13.8505 F   0  0  0  0  0  0
   18.0176    1.9927   -8.6784 N   0  0  0  0  0  0
   24.8400    1.9615  -12.6525 F   0  0  0  0  0  0
   26.6372   -0.7929  -13.6486 F   0  0  0  0  0  0
   27.9360    0.4657   -7.8636 N   0  0  0  0  0  0
   28.3611    1.8550  -11.6954 H   0  0  0  0  0  0
   27.9701   -0.4195  -11.7119 H   0  0  0  0  0  0
   24.3886    0.2707  -13.6271 H   0  0  0  0  0  0
   24.7736   -1.4789   -7.8939 H   0  0  0  0  0  0
   22.6914   -1.2459   -9.1138 H   0  0  0  0  0  0
   21.2074   -2.5951  -11.9425 H   0  0  0  0  0  0
   17.8099   -1.4198   -9.7083 H   0  0  0  0  0  0
   21.0016    1.3428  -10.2620 H   0  0  0  0  0  0
   27.2694    0.7696   -7.1547 H   0  0  0  0  0  0
   28.1746    1.1824   -8.5552 H   0  0  0  0  0  0
  1  2  1  0  0  0
  1 28  1  0  0  0
  2  3  1  0  0  0
  2  6  1  0  0  0
  2 29  1  0  0  0
  3  4  1  0  0  0
  3 23  1  0  0  0
  3 26  1  0  0  0
  4  5  1  0  0  0
  4 25  1  0  0  0
  4 30  1  0  0  0
  5  6  2  0  0  0
  5 10  1  0  0  0
  6  7  1  0  0  0
  7  8  2  0  0  0
  7 20  1  0  0  0
  8  9  1  0  0  0
  8 31  1  0  0  0
  9 10  2  0  0  0
  9 32  1  0  0  0
 10 11  1  0  0  0
 11 12  1  0  0  0
 12 13  2  0  0  0
 12 19  1  0  0  0
 13 14  1  0  0  0
 13 33  1  0  0  0
 14 15  1  0  0  0
 14 16  2  0  0  0
 16 17  1  0  0  0
 16 34  1  0  0  0
 17 18  1  0  0  0
 17 19  2  0  0  0
 18 24  3  0  0  0
 19 35  1  0  0  0
 20 21  2  0  0  0
 20 22  2  0  0  0
 20 27  1  0  0  0
 27 36  1  0  0  0
 27 37  1  0  0  0
M  END
$$$$"""

mol_b = """43
                    3D
 Structure written by MMmdl.
 34 35  0  0  1  0            999 V2000
   27.3206    0.2092  -11.5444 C   0  0  0  0  0  0
   24.8104   -0.0377  -11.5023 C   0  0  0  0  0  0
   26.0342   -0.2249  -10.8317 C   0  0  0  0  0  0
   26.0391   -0.7726   -9.5293 C   0  0  0  0  0  0
   24.8129   -1.0870   -8.9213 C   0  0  0  0  0  0
   23.6118   -0.9391   -9.6083 C   0  0  0  0  0  0
   23.6108   -0.4248  -10.9220 C   0  0  0  0  0  0
   22.4761   -0.3049  -11.6918 O   0  0  0  0  0  0
   21.2375   -0.5838  -11.1900 C   0  0  0  0  0  0
   20.6642   -1.8394  -11.3980 C   0  0  0  0  0  0
   19.4099   -2.1222  -10.8637 C   0  0  0  0  0  0
   18.7315   -1.1370  -10.1413 C   0  0  0  0  0  0
   19.2646    0.1136   -9.9710 C   0  0  0  0  0  0
   18.5795    1.1649   -9.2431 C   0  0  0  0  0  0
   20.5604    0.4002  -10.4797 C   0  0  0  0  0  0
   27.5401   -1.0912   -8.5545 S   0  0  0  0  0  0
   27.1859   -2.0084   -7.4841 O   0  0  0  0  0  0
   28.6206   -1.4509   -9.4586 O   0  0  0  0  0  0
   27.9627    0.5938   -7.7916 C   0  0  0  0  0  0
   27.7984    1.5671   -8.6677 F   0  0  0  0  0  0
   27.0861    0.7983   -6.7353 F   0  0  0  0  0  0
   24.7409    0.7017  -13.0762 Cl  0  0  0  0  0  0
   27.6879    1.5242  -11.1857 O   0  0  0  0  0  0
   18.0013    1.9953   -8.6849 N   0  0  0  0  0  0
   28.1313   -0.4949  -11.3851 H   0  0  0  0  0  0
   27.2003    0.1946  -12.6299 H   0  0  0  0  0  0
   24.7742   -1.4735   -7.9133 H   0  0  0  0  0  0
   22.6888   -1.2338   -9.1280 H   0  0  0  0  0  0
   21.2029   -2.5876  -11.9606 H   0  0  0  0  0  0
   18.9769   -3.1014  -11.0060 H   0  0  0  0  0  0
   17.7565   -1.3858   -9.7173 H   0  0  0  0  0  0
   21.0066    1.3603  -10.3264 H   0  0  0  0  0  0
   28.9730    0.5924   -7.4558 H   0  0  0  0  0  0
   28.4959    1.7705  -11.6621 H   0  0  0  0  0  0
  1  3  1  0  0  0
  1 23  1  0  0  0
  1 25  1  0  0  0
  1 26  1  0  0  0
  2  3  2  0  0  0
  2  7  1  0  0  0
  2 22  1  0  0  0
  3  4  1  0  0  0
  4  5  2  0  0  0
  4 16  1  0  0  0
  5  6  1  0  0  0
  5 27  1  0  0  0
  6  7  2  0  0  0
  6 28  1  0  0  0
  7  8  1  0  0  0
  8  9  1  0  0  0
  9 10  2  0  0  0
  9 15  1  0  0  0
 10 11  1  0  0  0
 10 29  1  0  0  0
 11 12  2  0  0  0
 11 30  1  0  0  0
 12 13  1  0  0  0
 12 31  1  0  0  0
 13 14  1  0  0  0
 13 15  2  0  0  0
 14 24  3  0  0  0
 15 32  1  0  0  0
 16 17  2  0  0  0
 16 18  2  0  0  0
 16 19  1  0  0  0
 19 20  1  0  0  0
 19 21  1  0  0  0
 19 33  1  0  0  0
 23 34  1  0  0  0
M  END
$$$$"""


import numpy as np
from rdkit import Chem
from rdkit.Chem import rdFMCS

romol_a = Chem.MolFromMolBlock(mol_a, removeHs=False)
romol_b = Chem.MolFromMolBlock(mol_b, removeHs=False)

class CompareDist(rdFMCS.MCSAtomCompare):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def compare(self, p, mol1, atom1, mol2, atom2):
        x_i = mol1.GetConformer(0).GetPositions()[atom1]
        x_j = mol2.GetConformer(0).GetPositions()[atom2]
        if np.linalg.norm(x_i-x_j) > 0.5:
            return False
        else:
            return True

# atom typer + complete rings fails
mcs_params = rdFMCS.MCSParameters()
mcs_params.AtomTyper = CompareDist()
mcs_params.BondCompareParameters.CompleteRingsOnly = 1 

# atom typer only works
# mcs_params = rdFMCS.MCSParameters()
# mcs_params.AtomTyper = CompareDist()
# mcs_params.BondCompareParameters.CompleteRingsOnly = 0 # Works

# complete rings only works
# mcs_params = rdFMCS.MCSParameters()
# mcs_params.BondCompareParameters.CompleteRingsOnly = 1 # Works

res = rdFMCS.FindMCS(
    [romol_a, romol_b],
    mcs_params
)

Expected behavior
CustomAtomTyper + CompleteRings fails with an untranslated exception but using either one alone proceeds without error.

Configuration (please complete the following information):

  • RDKit version: 2020.03.01
  • OS: Ubuntu 20.04
  • Python version (if relevant): 3.6.7
  • Are you using conda? yes
  • If you are using conda, which channel did you install the rdkit from? rdkit

Additional context
Add any other context about the problem here.

@proteneer proteneer added the bug label Dec 12, 2020
@ptosco ptosco self-assigned this Dec 12, 2020
@ptosco
Copy link
Contributor

ptosco commented Dec 12, 2020

@proteneer Thanks for reporting this with a reproducible - I am on it.

ptosco added a commit to ptosco/rdkit that referenced this issue Dec 13, 2020
@greglandrum greglandrum added this to the 2020_09_4 milestone Dec 17, 2020
greglandrum pushed a commit that referenced this issue Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants