Moving to Python 3 with the CSD Python API means that some scripts will need to be updated. You can find some instructions to help you to do this here but below are a couple of scripts to run HBP calculations that have been updated.

You will still need to download the .docx template files from the original posts, and you can find instructions on how to run the scripts there as well.

You will also need to upgrade matplotlib to at least v.3.0.3 if you haven't done so already.


And here's one for a multi-component HBP calculation.

Hi Andy,

I am interested in using the script for the multi-component HBP calculations. However, I think a specific template is needed to run this script, which I cannot see here. Would it be possible to upload it?

Thanks a lot for the help!


Ok, I found it in the other discussion. Please discard the previous request.


Here's a new multi-component HBP script for Python 3 with better feedback.

Use this one instead of the one above, and remember to grab the template files from the other thread!

This is the latest version of the HBP script that should work with Python 3. The templates is also updated here, you can download them from the posts bellow.

The hbp_report_template.docx required for the script.

This is the latest version of the multi-component HBP script. The latest update provides a  Multi-component hydrogen bond propensity chart based on Co-former rank and the Multiple-Component Score. The templates have been also updated, you can download them from the posts bellow.

The mchbp_report_template.docx required for the script.

The mcpair_output_template.docx required for the script.

Hi Andrew and Ioana,

I have been trying to run this script but I got the following error.

(Screenshot attached).

I have copied the necessary files to the correct path. I have tried using different directory but still got the same error.


Dear Yuda,

Thanks for contacting us regarding the CSD-Materials scripts. Could you please activate our miniconda environment prior running the scripts. To do that in the cmd on Windows type: 

"C:\Program Files\CCDC\Python_API_2020\miniconda\Scripts\activate"

Note that your path to the python miniconda might be different, based on your CCDC package installation folder).

Let us know if this work, otherwise could you please email to ensure you get the support need it. 

Best wishes,



Dear Ioana,

Thank you for the assistance. It works!


 Thanks for providing this script. I had some trouble getting it work and thought these notes might help others.

- Should the line of code pasted below follow line 240? This addition would mirror the code on line 236.

coord_cols = [i for i in range(len(coordination_scores.predictions_for_label(a.label, 'a')[1]))]

- Line on 308 causes problems on linux

 coformer_files = glob.glob(r'%s\*.mol2' % library)

This should work on any OS

 coformer_files = glob.glob(os.path.join(library, '*.mol2')


- If the structure file is not in the working directory line  285 causes a problem. I changed it to these two lines

basename = os.path.basename(identifier)
prefix, _ = os.path.splitext(basename)
output_file = os.path.join(directory, '%s_MC_HBP_report.docx' % prefix)


- Line 332 can fail as the sorting key can receive a mix of strings and numbers. Changing 329 to the following helps

nan = float('nan')
mc_dictionary[coformer_name] = [nan, nan, nan, nan, nan, crystal.identifier]

You must be signed in to post in this forum.