As part of the work for Ox Uni (Ruben Sanchez Garcia) we need to add an endpoint that can be used to find merge-like expansions, similar to this Python code:
def find_expansions(tx, smiles, synthon, number_hops=2):
"""
Expand fragment 'A' using the synthons generated from fragment 'B' using a neo4j
query. Query limited to compounds available from vendors, with HAC > 15
and a maximum of 2 hops away.
:param smiles: smiles of the fragment to expand
:type smiles: string
:param synthon: synthon of the generated synthon
:type synthon: string
:return: expansions
:rtype: set
"""
query = ("MATCH (fa:F2 {smiles: $smiles})"
"-[:FRAG*0..%(number_hops)d]-(:F2)" # to increase the number of hops, change '0..2' to '0..3'
"<-[e:FRAG]-(c:Mol) WHERE"
" c.hac > 15 AND"
" (split(e.label, '|')[1] = $synthon OR split(e.label, '|')[4] = $synthon)"
" RETURN DISTINCT c"%{"number_hops":number_hops})
expansions = set()
for record in tx.run(query, smiles=smiles, synthon=synthon):
node = record['c']
expansions.add(node['smiles'])
return expansions
As part of the work for Ox Uni (Ruben Sanchez Garcia) we need to add an endpoint that can be used to find merge-like expansions, similar to this Python code: