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
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
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"]
substructure = mol_component # save the rest of substructure
# let's look in the other Molecule other_molecule
substructure_search = ccdc.search.SubstructureSearch()
# 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.