# How to compute the synthetic accessibility score in Python?

I come from a mainly computer science background, but have become involved in a project related to artificial intelligence-based drug discovery. I made a model that generates novel molecules, for which I want to compute their synthetic accessibility score[1]. I am aware of the RDKIT library which is very helpful in computer-aided chemistry, however, I can't find any method/function for this purpose. If anyone knows a way, it would be much appreciated.

### References:

1. Ertl, P.; Schuffenhauer, A. Estimation of synthetic accessibility score of drug-like molecules based on molecular complexity and fragment contributions. J. Cheminf. 2009, 1 (1), No. 8. DOI: 10.1186/1758-2946-1-8.
• Suggestion across the aisle: Have a look on already working implementations, e.g. by the Reymond group; (1) AiZynthFinder: a fast, robust and flexible open-source software for retrosynthetic planning. J Cheminform 2020, 12, 70; doi.org/10.1186/s13321-020-00472-1, (2) Retrosynthetic accessibility score (RAscore) – rapid machine learned synthesizability classification from AI driven retrosynthetic planning., Chem. Sci., 2021, 12, 3339-3349; doi.org/10.1039/D0SC05401A. Both publications are open access with code mirrored on GitHub. Jan 1 at 10:17
• Not really an answer to the question, but more of a warning. Synthetic accessibility scores are very variable, especially when you’re looking at diverse molecules (compared to say a focused set of similar compounds). As you say you’re a non chemist, I’d be very careful applying it blindly as it’s unlikely to correlate with any actual ability to make the compound
– NotEvans.
Jan 1 at 13:10
• @NotEvans. +1 In this regard, Reymond group perhaps is more on the safer side as they still equally perform synthetic organic/bioorganic chemistry in the lab (RNA, peptides, etc; not classical total synthesis of natural products) than groups in without (e.g., von Lilienfeld group, more on physical/quantum chemistry only). Jan 1 at 13:30
• Thanks for all of the comments. I have found this library that does what I want tdcommons.ai/functions/oracles/#synthetic-accessibility-sa, please have a look at it and tell me what you think with respect to what you said earlier.
Jan 1 at 20:14

Ertl and Schuffenhauer, who developed the synthetic accessibility score, provide an implementation packaged with RDKit called sascorer.py.

This is provided in the Contrib folder of the RDKit repo; what this means is it isn't formally part of RDKit, but with a little work can be accessed from RDKit. An example of how to do this is given in an issue on the RDKit Github. I'll reproduce the code from iwatobipen here:

from rdkit import Chem
from rdkit.Chem import RDConfig
import os
import sys
sys.path.append(os.path.join(RDConfig.RDContribDir, 'SA_Score'))
# now you can import sascore!
import sascorer
mol = Chem.MolFromSmiles('NC(=O)c1ccccc1')
s = sascorer.calculateScore(mol)


The first section temporarily adds the Config directory to your path so you can import sascorer. If you don't want to include this every time you want to run this program, you will need to add this directory to your system path. The commands to do so vary by operating system.