This article implements the quantum-inspired method proposed by a team of researchers from King’s College Hospital and Fujitsu Spain .
The approach is to search compounds similar to Remdesivir (RDV), the only antiviral against SARS-CoV-2 currently approved for human use .
The full code of this python module is provided and fully parametrizable, to allow anyone to run it with custom configuration.
Moreover, the module can be more generally used to compare any molecule.
The algorithm compares an initial molecule (in our case RDV for SARS-CoV-2 antiviral) to a list of compounds loaded from an SDF file. For each possible pair, the Maximum Weighted Independent Set (MWIS) problem is resolved within the generated conflict graph. To do so, the RDKit open-source software is used for molecules handling, and D-WAVE simulated quantum annealer to solve the MWIS problem.
Thanks to quantum effects like tunnelling and entanglement, a quantum annealer finds the minimum value (i.e., ground state) for a given objective function. An objective function is expressed as a quadratic function of binary variables, as the hardware cannot encode constraints, the device is a quadratic unconstrained binary optimization (QUBO).
The QUBO formulation of our problem is shown on figure 1, variables are described in the paper .
The paper  is based on an other paper  from a researcher team from 1QBit who designed a novel graph-based approach for determining molecular similarity. All steps of the algorithm are detailed in  and .
To solve MWIS problem, we need a conflict graph generated by comparing each atoms and bonds of the two molecules to be compared with specific requirements. Vertices of the conflict graph represent possible matchings between the two molecules, while edges represent conflicts between those vertices.
When the MWIS problem is solved, we have a set of vertices as a result. To compute the similarity between the two molecules, we need to apply the formula shown on figure 2.
The SimilarMolSearcher.py script contains the function wich compare all molecules from an SDF file within an initial molecule. The main.py script contains an example on how to run it. It all comes down in simply calling the SimilarMolSearch function with some customizable parameters. The default parameters are the one defined in the paper , but can be customized.
The initial molecule is settable from its SMILES (Simplified Molecular Input Line Entry System) notation, for example, for RDV :
# SMILES format initial molecule to search a similar for (default remdesivir) smiles = 'CCC(CC)COC(=O)C(C)NP(=O)(OCC1C(C(C(O1)(C#N)C2=CC=C3N2N=CN=C3N)O)O)OC4=CC=CC=C4'
The sdf variable contains the sdf drug database path:
# path of the sdf drug database sdf = '20200113-L1300-FDA-approved-Drug-Library.sdf'
Following variables correspond to the algorithm parameters, by default they are setted with the paper values:
# algorithm variables wsim = 0.3 minsim = 0.75 wedges = 1 delta = 0.5
You can choose to write results in a csv file or not:
# output variables writetofile = False filename = "result.csv"
Finally, call the SimilarMolSearch function with all these parameters:
results = SimilarMolSearch(smiles, sdf, wsim, minsim, wedges, delta, writetofile, filename)
I test this module and compare it with the one used in the paper  by using the SimilarMolSearchMultipleTest function, I run the algorithm with the same 10 molecules they give their results (table 5 of paper ). We can see in table 1 that similarities are exacts or really close.
|Pairs||Paper QUBO similarity (%)||SimilarMolSearch QUBO similarity (%)|
 Drug repurposing based on a Quantum-Inspired method versus classical fingerprinting uncovers potential antivirals against SARS-CoV-2 including vitamin B12. https://doi.org/10.1101/2021.06.25.449609
 A Novel Graph-based Approach for Determining Molecular Similarity. https://arxiv.org/pdf/1601.06693.pdf