• RE: Searching the database based on structure void space

    Are you running from the Mercury or Hermes script menus? These have timeouts encoded (as they lock the interface). This search will take longer than 3 minutes to run over the whole CSD. To test, you can add the following at the top of the enumerate. It will only check the first 1000 entries. You may have to adjust it if you don't find any hits in the first 1000.

        if i > 1000:
  • RE: Searching the database based on structure void space

    One thing that might work to fix that error is to open a console (might need to Run as Administrator) and run the following:

    C:\Program Files (x86)\CCDC\Python_AP I_2018\miniconda\Scripts\activate

    conda install openssl

    This should force the update/repair of any missing bits of the openssl libraries.


  • Script to check your structure prior to publication (from 2016 Spring BCA & 2016 ACA meetings)

    This is a script to check some of the geometric and crystallographic features of a structure before publishing it (including publishing it as a CSD-Communication). It's intended to act as a complement to CheckCIF and flag features that are worth taking a second look. It was presented by CCDC's Pete Wood at the BCA Spring Meeting 2016 in Nottingham, UK and by myself (CCDC's Paul Sanschagrin) during the "Would You Publish This?" session at the 2016 ACA Conference in Denver, Colorado, USA. To use it, you must have the CSD Python API installed. Then, add a new folder to the Mercury CSD Python API menu via options, if you don't have a script folder already added there, and place the script there. We welcome feedback, criticisms, and suggestions for improvement.


  • Providing input to a Mercury called script

    I am looking to write a script to be called via the Mercury scripts menu that will ask the user for some input and use this to do something with a structure loaded in Mercury. Any ideas on best way to do this? PyQT vs. Tkinter?



  • RE: Output search results as program runs


    Unfortunately, it isn't possible to have the API produce output as it goes. It would be possible to break your search into two searches, one for your donor patterns and then a second using the hits from that for your acceptor patterns. This may not be any faster as I've never tested it but you would get an intermediate hit list. If you also defining distance and/or angle constraints, you could run the second search with the same setup as you originally had but only run against the filtered set.


  • RE: Technical Help FAQs

    We have seen some cases in Windows where the pip installation of the CSD Python API fails due to an error building the lxml Python package. The end of the installation output will look something like:

        Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
        error: command 'C:\\Users\\someuser\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

    Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\someuser\\appdata\\local\\temp\\pip-build-bznxq6\\lxml\\setup.py';
    exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
    install --record c:\users\db-ser~1\appdata\local\temp\pip-9laak8-record\install-record.txt
    --single-version-externally-managed --compile" failed with error code 1 in

    (The last line may be wrapped differently as it is very long.)

    The simplest solution is to download the binary wheel package from here:
    (If that link doesn't work, you can go to here:
    and download the file named lxml‑3.5.0‑cp27‑none‑win32.whl . )

    You would then install it using pip install lxml‑3.5.0‑cp27‑none‑win32.whl. Once this is done, rerun the CSD API pip install.

  • RE: smiles search



    I agree it would be a worthwhile addition. I have added it to our system as an enhancement request. However, it won't be included in the next release in November as that is currently undergoing final bug fixing. Hopefully next year.

  • RE: smiles search



    It's not possible to do an exact SMILES search at the moment. The best option is likely to do the substructure search and then check each resulting hit for the expected atom count. You do have to take care to consider if you want to include hydrogens in the count and how you want to handle matches in multi-component systems. The hit.molecule object will include all components. There is also a hit.matched_components list which will contain only those molecular components which match the search so you would check these. If you want to match complete systems, you can just check the hit.molecule. To quickly count the atoms use the following:

    len([mol.atoms) # all atoms
    len([a for a in mol.atoms if a.atomic_number > 1]) # non-hydrogens


  • Downloading the SQLite Database

    The API documentation has the wrong link to download the SQLite DB. The correct location/method to obtain this is to request a set of download links from the main CSDS download page (you will need your site number and confirmation code):


    There will be links in this email to the SQLite download.

  • Script to generate Mogul data from for a series of compounds

    This is a script to generate Mogul data for a series of compounds from the command line. A complete usage message can be displayed by using the -h or --help options. Basic usage is:

    python mogul_data.py test_molecules.mol2 mogul_data.csv

    The output file will contain a header line followed by lines of Mogul data for each bond, bond angle, torsion angle, and ring of each molecule in the input file.