[docs]@functools.lru_cache(maxsize=128)defbuild_atom_map(can:str,mod:str)->AtomMap:can_lig=get_ligand(can,noh=True)# Canonicalmod_lig=get_ligand(mod,noh=True)# Modifiedcutoff={"ALA":2,"ARG":6,"ASN":3,"ASP":3,"CYS":2,"GLN":4,"GLU":4,"GLY":2,"HIS":4,"ILE":3,"LEU":3,"LYS":5,"MET":4,"PHE":5,"PRO":2,"SER":2,"THR":2,"TRP":6,"TYR":6,"VAL":2,}k=cutoff[can]# How far from CA?shortest_paths=nx.single_source_shortest_path_length(mod_lig.graph,"CA")nodes_to_remove=[nodefornode,distinshortest_paths.items()ifdist>k]mod_lig.graph.remove_nodes_from(nodes_to_remove)scores=[]# Heuristicismags=nx.isomorphism.ISMAGS(can_lig.graph,mod_lig.graph)largest_common_subgraph=list(ismags.largest_common_subgraph())fori,subinenumerate(largest_common_subgraph):if"CA"notinsub:continuescore=0fork,vinsub.items():ifk==v:score+=10elifk[0]!=v[0]:score-=100else:passscores.append((i,score))scores.sort(key=lambdax:x[1],reverse=True)e=largest_common_subgraph[scores[0][0]]mapping={v:kfork,vine.items()ifk[0]==v[0]}removed=set(mod_lig.graph.nodes).difference(mapping.keys())returnAtomMap(mapping=mapping,removed=removed)