Hi all,

playing with CSD Python API for about a month. I am not a chemist, thus some phrasing might sound funny to you and apologies in advance for not being able to post reproducible code. 

LONG STORY SHORT:

in a loop using ccdc.search.SubstructureSearch(), I am looking for a matching substructure in a molecule and sometimes get

WARNING: Matching failed for one 3D molecule, at least once the match was too complex to compute

I am trying to catch those warnings in order to be able to see which pairs of molecules actually give me this. Introduction of standard python 

import warnings
warnings.filterwarnings('error')

did not help. I still get warnings in stderr. Digging in API leads me to .pyd

Do you have an idea where this can be coming from? Can I catch it without externally monitoring my stderr?

System and venv

Windows 7

Virtual environment

backports.functools-lru-cache==1.5
csd-python-api==1.5.3
cycler==0.10.0
kiwisolver==1.0.1
lxml==3.8.0
matplotlib==2.2.3
numpy==1.15.2
olefile==0.46
pandas==0.23.4
Pillow==4.3.0
psutil==5.4.7
pyparsing==2.2.2
python-dateutil==2.7.3
pytz==2018.5
scipy==1.1.0
six==1.11.0

 

LONG STORY:

let's say I have a molecule with Azide (azide_molecule) in it. I know that C atom to which azide is attached has label, say "C1" (c_label) I want to delete Azide and search within the database for mols that have this leftover substructure. I do smth like that:

for mol_component in azide_molecule.components:  # loop through all components
# if found component with azide
if c_label in list(map(lambda x: x.label, mol_component.atoms)):
# delete azido
for component_atom in mol_component.atoms:
if component_atom.label in azide_labels: # labels of N atoms, like azide_labels = ["N1", "N2", "N3"]
mol_component.remove_atom(component_atom)
substructure = mol_component # save the rest of substructure

# let's look in the other Molecule other_molecule
substructure_search = ccdc.search.SubstructureSearch()
substructure_search.add_substructure(ccdc.search.MoleculeSubstructure(substructure))

# I suspect at this moment I get the warning. But I am not sure.
hits = substructure_search.search(database=other_molecule)

I suspect at the moment when I call search() I get the warning, but I am not sure.

Will be happy to get any help or suggestions.

Hi Vladimir,

the warning is issued by the underlying C++ code, and is not under the control of the python API.  The only thing I can think of is to record the identifiers of the molecules involved before performing the search, possibly using ccdc.utilities.Logger, then inspecting the output.

I'm sorry I can't be any more helpful at the moment.

Best wishes

Richard

Hey Richard,

Thank you very much for a quick reply! Yeah, I was afraid that it is the case. I will try the Logger solution and post my answer here.

Best wishes,

Vladimir

Hi,

I have been encountering the same error.

The error only occurs when I try to search within a database, for example I was trying to search only those in the Best R-Factor subset. If I do not state a database it works fine, but I end up with redeterminations which I did not want in my results.

I don't know whether this is of any use to finding a solution to the problem.

Thanks,

Sarah

 

 

You must be signed in to post in this forum.