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 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.
Hey *,
I am Vladimir, a Data Scientist working in collaboration with Karlsruhe Institute of Technology on the problem of Azide polarity. CCDC is an awesome source of data and I thank you for creating the API.