I would like to find a way to search the CCDC database structures and rank them in order of % void space.  I have been a thread discussing this based on Rhombohedral space groups only.  Is it possible for me to perform such a search on the entire database, or might there even be a .py script out there for such a task?



Many thanks

Hi Martin,

There is no direct method in the API to search on spacegroup, so one has to fall back on enumeration of the database.  I believe the following will do what you want:

import time

from ccdc import io, utilities
csd = io.EntryReader('csd')

start = time.time()
hits = []

for i, e in enumerate(csd):
    if i and i % 1000 == 0:
        utilities.Timer.progress(start, i, len(csd), '%d hits' % len(hits))
    if not e.has_3d_structure:
    c = e.crystal
    if not c.spacegroup_symbol.startswith('R'):
    hits.append((c.void_volume(), e.identifier))


This works by rejecting structures with no 3d information (they won't support a void volume calculation) and rejecting structures which do not have a rhombohdral space group.  If you like you can change this line to test different space groups.

At the end you will have a list of void_volume, refcode pairs which you can write in any format you care.

Hope this is helpful,

Best wishes

Dear Richard,


Many thanks for this, I will hopefully be able to get this running soon after figuring out what my issue (below) is.  Looks to be python related rather than the script/CCDC system.



Many thanks again


Traceback (most recent call last):
File "C:/Users/lpb16197/Desktop/CSD_void/void_space.py", line 3, in <module>
from ccdc import io, utilities
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\site-packages\csd_python_api-1.5.1-py2.7.egg\ccdc\io.py", line 87, in <module>
from ccdc.entry import Entry
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\site-packages\csd_python_api-1.5.1-py2.7.egg\ccdc\entry.py", line 50, in <module>
from ccdc.crystal import Crystal
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\site-packages\csd_python_api-1.5.1-py2.7.egg\ccdc\crystal.py", line 39, in <module>
from ccdc.molecule import Molecule, _file_object_factory
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\site-packages\csd_python_api-1.5.1-py2.7.egg\ccdc\molecule.py", line 73, in <module>
from ccdc.utilities import UncertainValue, nested_class, bidirectional_dict, _detect_format
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\site-packages\csd_python_api-1.5.1-py2.7.egg\ccdc\utilities.py", line 33, in <module>
import tempfile
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\tempfile.py", line 35, in <module>
from random import Random as _Random
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\random.py", line 49, in <module>
import hashlib as _hashlib
File "C:\Program Files (x86)\CCDC\Python_API_2018\miniconda\lib\hashlib.py", line 138, in <module>
AttributeError: 'module' object has no attribute 'openssl_md_meth_names'

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.


Many thanks Paul, the script now runs, but it does suffer a time-out after 180 seconds of running.  I will need to investigate further before starting to grab the data I am looking to source


As you may tell, this is the first time I have started to look at using the Python API

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:

Many thanks yet again for your help.


I am running the code from Mercury - I have tried running from a python IDE, but encounters an import error tryign to load CCDC module.  Should I be using something other than Mercury?


I apologise for what are likely basic questions - if there is a good reference that might help me get up and running with this rather than continually pestering this forum a recommendation would be greatfully received


The script now appears to complete and outputs a .m2a file.  I can open this in a text editor, but doest contain useful information, an example is shown below:


    "options": {
        "interface_version": 3,
        "identifier": "AABHTZ",
        "selected_atoms": [

        "distances": [

        "angles": [

        "torsions": [

        "database_path": "C:/Program Files (x86)/CCDC/CSD_2018/CSD_539/as539be_ASER.sqlite",
        "program_executable_path": "C:/Program Files (x86)/CCDC/CSD_2018/Mercury/mercury.exe",
        "working_directory_path": "C:\\Users\\lpb16197\\Desktop\\CSD_void/AABHTZ/void_space/2018_04_25_22_14_44",
        "output_base": "C:\\Users\\lpb16197\\Desktop\\CSD_void/AABHTZ/void_space/2018_04_25_22_14_44/AABHTZ_void_space",
        "conquest_path": "C:\\Program Files (x86)\\CCDC\\CSD_2018\\ConQuest\\exe\\csds.exe"

Hi Martin,

if you want to run scripts which take longer than three minutes, you can invoke python directly from a shell prompt:

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

python name_of_your_script.py

This will not need the mercury interface.

Best wishes



Thanks for the good ideas to bring it. I know a lot more. :)[url=http://www.ufa007.com][color=#e1e1e1][size=1px] สมัครufabet

[/size][/color][/url]  :J

You must be signed in to post in this forum.