Learning to Extend Molecular Scaffolds with Structural Motifs

1 INTRODUCTION . The problem of in silico drug discovery requires navigating a vast chemical space in order to find molecules of interest that satisfy various constraints on their properties and structure . This poses challenges well beyond those solvable by brute-force search , leading to the development of more sophisticated approaches . Recently , deep learning models are becoming an increasingly popular choice , because they can learn a distribution over drug-like molecules from raw data . While early generative models of molecules relied on the textual SMILES representation and reused architectures from natural language processing ( Segler et al. , 2018 ; Gómez-Bombarelli et al. , 2018 ; Winter et al. , 2019a ; Ahn et al. , 2020 ) , many recent approaches are built around molecular graphs ( De Cao & Kipf , 2018 ; Liu et al. , 2018 ; Li et al. , 2018b ; Assouel et al. , 2018 ; Simonovsky & Komodakis , 2018 ; Jin et al. , 2018 ; 2020 ; Bradshaw et al. , 2020 ) . Compared to SMILES-based methods , graph-based models that employ a sequential generator enjoy perfect validity of generated molecules , as they can enforce hard chemical constraints such as valence during generation . However , even if a molecule does not violate valence constraints , it is merely a sign of syntactic validity ; the molecule can still be semantically incorrect by containing unstable or unsynthesisable substructures . Intermediate states during atom-by-atom generation may contain atypical chemical fragments , such as alternating bond patterns corresponding to unfinished aromatic rings . Therefore , some works ( Rarey & Dixon , 1998 ; Jin et al. , 2018 ; 2020 ; Ståhl et al. , 2019 ) propose data-driven methods to mine common molecular fragments – referred to as motifs – which can be used to build molecules fragment-by-fragment instead of atom-by-atom . When motifs are employed , most partial molecules during generation are semantically sensible , as they do not contain half-built structures such as partial rings . A common additional constraint in drug discovery projects is the inclusion of a predefined subgraph , called a scaffold ( Schuffenhauer et al. , 2007 ; Schuffenhauer , 2012 ) . Generating molecules that contain a given scaffold can be approached by drawing many samples and discarding those that do not contain it . While simple , this method is not scalable , as the number of samples required may grow exponentially with scaffold size . Instead , some recent models can enforce the presence of a given scaffold ( Lim et al. , 2019 ; Li et al. , 2019 ; Arús-Pous et al. , 2020 ; Langevin et al. , 2020 ) . However , extending a generative model to perform scaffold-based generation is often non-trivial , as we discuss in Sect . 4 . In this work we make the following contributions : • In Sect . 2 we present MoLeR , a new graph-based generative model suitable for the commonly required task of extending partial molecules . It can use motifs ( molecule fragments ) to generate outputs ( similarly to Jin et al . ( 2018 ; 2020 ) ) , but integrates this with atom-by-atom generation . • We show experimentally in Sect . 3 that MoLeR ( a ) is able learn to generate molecules matching the distribution of the training data ( with and without scaffolds ) , ( b ) together with an off-the-shelf optimization method ( MSO ( Winter et al. , 2019b ) ) can be used for molecular optimization tasks , matching the state of the art methods in unconstrained optimization , and out-performing them on scaffold-constrained tasks , ( c ) is faster in training and inference than baseline methods . • We also perform experiments in Sect . 3 to analyze two design decisions that are understudied in the literature : the choice of the generation order and the size of the motif vocabulary . Our results show how varying these two parameters affects model performance . 2 OUR APPROACH . 2.1 DATA REPRESENTATION . Motifs Training our model relies on a set of fragmentsM – called the motif vocabulary – which we infer directly from data . For each training molecule , we decompose it into fragments by breaking some of the bonds ; as breaking rings is chemically challenging , we only consider acyclic bonds , i.e . bonds that do not lie on a cycle . We break all acyclic bonds adjacent to a cycle ( i.e . at least one endpoint lies on a cycle ) , as that separates the molecule into cyclic substructures , such as ring systems , and acyclic substructures , such as functional groups . We then aggregate the resulting fragments over the entire training set , and defineM as the n most common motifs , where n is a hyperparameter . Having selectedM , we pre-process molecules ( both for training and during inference ) by noting which atoms are covered by motifs belonging to the vocabulary . This is done by applying the same bond-breaking procedure as used for motif vocabulary extraction . During generation , our model can either add an entire motif in one step , or generate atoms and bonds one-by-one . This means that it can generate arbitrary structures , such as an unusual ring , even if they do not appear in the training data . Finally , note that in contrast to Jin et al . ( 2020 ) , we do not decompose ring systems into individual rings . This means that our motifs are atom-disjoint , and we consequently do not need to model a motif-specific attachment point vocabulary , as attaching a motif to a partial graph requires adding only a single bond , and thus there is only one attachment point . Molecule Representation We represent a molecule as a graph G = ( V , E ) , where vertices V are atoms , and edges E are bonds . Edges may also be annotated with extra features such as the bond type . Each node ( atom ) v ∈ V is associated with an initial node feature vector h ( init ) v , chosen as chemically relevant features ( Pocha et al. , 2020 ) , both describing the atom ( type , charge , mass , valence , and isotope information ) and its local neighborhood ( aromaticity and presence of rings ) . These features can be readily extracted using the RDKit library ( Landrum et al. , 2006 ) . Additionally , for atoms that are part of a motif , we concatenate h ( init ) v with the motif embedding ; for the other atoms we use a special embedding vector to signify the lack of a motif . We show this at the top of Fig . 1 . Throughout this paper we use Graph Neural Networks ( Li et al. , 2015 ; Kipf & Welling , 2016 ) to learn contextualized node representations hv . Motif embeddings are initialized randomly , and learned end-to-end with the rest of the model . 2.2 THE MOLER DECODER Algorithm 1 MoLeR Generative Procedure Input : vector z , scaffold as partial graph S Output : molecule M and probability p M , p← S , 1 while True do a , pa ← PickAtomOrMotif ( z , M ) p← p · pa if a = END_GEN then return M , p M ← AddAtomOrMotif ( M , a ) v } , p } ← PickAttachment ( z , M , a ) p← p · p } while True do b , pb ← PickBond ( z , M , v } ) p← p · pb if b = END_BONDS then break M ← AddBond ( M , b ) Our generative procedure is shown in Alg . 1 and example steps are shown at the bottom of Fig . 1 . It takes as input a conditioning input vector z , which can either be obtained from encoding ( in our setting of training it as an autoencoder ) or from sampling ( at inference time ) , and optionally a partial molecule to start generation from . Our generator constructs a molecule piece by piece . In each step , it first selects a new atom or entire motif to add to the current partial molecule , or to stop the generation . If generation continues , the new atom ( or an atom picked from the added motif ) is then in “ focus ” and connected to the partial molecule by adding one or several bonds . In practice , our decoder relies on three neural networks to implement the functions PickAtomOrMotif , PickAttachment and PickBond . These networks share a common GNN to process the partial molecule M , yielding high-level features hv for each atom v and an aggregated graph-level feature vector hmol . We call our model MoLeR , as each step is conditioned on the Molecule-Level Representation hmol . PickAtomOrMotif uses hmol as an input to an MLP that selects from the set of known atom types , motifs and a special END_GEN class to signal the end of the generation . PickAttachment is used to select which of the atoms in an added motif to connect to the partial molecule ( this is trivial in the case of adding a single atom ) . This is implemented by another MLP that computes a score for each added atom va using its representation hva and hmol . As motifs are often highly symmetric , we determine the symmetries using RDKit and only consider one atom per equivalence class . An example of this is shown in step ( 3 ) at the bottom of Fig . 1 , where only three of the five atoms in the newly-added motif are available as choices , as there are only three equivalence classes . Finally , PickBond is used to predict which bonds to add , using another MLP that scores each candidate bond between the focus atom v } and a potential partner vb using their representations hv } , hvb and hmol . We also consider a special , learned END_BONDS partner to allow the network to choose to stop adding bonds . Similarly to Liu et al . ( 2018 ) , we employ valence checks to mask out bonds that would lead to chemically invalid molecules . Moreover , if v } was selected as an attachment point in a motif , we mask out edges to other atoms in the same motif . The probability of a generation sequence is the product of probabilities of its steps ; we note that the probability of a molecule is the sum over the probability of all different generation sequences leading to it , which is infeasible to compute . However , note that steps are only conditioned on the input z and the current partial molecule M . Our decoding is therefore not fully auto-regressive , as it marginalizes over all different generation sequences yielding the partial molecule M . During training , we use a softmax over the candidates considered by each subnetwork to obtain a probability distribution . As there are many steps where there are several correct next actions ( e.g . many atoms could be added next ) , during training , we use a multi-hot objective that encourages the model to learn a uniform distribution over all correct choices . For more details about the architecture see App . B . 2.3 MOLECULE GENERATION ORDERS Algorithm 2 Determining a generation order Input : Target molecule M , partial mapping A from atoms to motifs that cover them t , V0 ← 0 , ∅ while |Vt| < |M | do . Not all atoms visited if t = 0 then ct ← ValidFirstAtoms ( M ) else ct ← ValidNextAtoms ( Vt , M ) at ∼ U ( ct ) . Sample at uniformly if at is covered by A then V+ ← A ( at ) . Add an entire motif else V+ ← { at } . Add a single atom Vt+1 , t← Vt ∪ V+ , t+ 1 As alluded to above , during training of MoLeR , we need to provide supervision for each individual step of the generative procedure , which is complicated by the fact that a single molecule may be generated in a variety of different orders . To define a concrete generation sequence , we first choose a starting atom , and then for every partial molecule choose the next atom from its frontier , i.e . atoms adjacent to already generated atoms . After each choice , if the currently selected atom is part of a motif , we add the entire motif into the partial graph at once . We formalize this concept as pseudocode in Algorithm 2 . In Sect . 3 , we evaluate orders that are commonly used in the literature : random , where ValidFirstAtoms returns all atoms and ValidNextAtoms all atoms on the frontier on the current partial graph , i.e. , a randomly chosen valid generation order ; canonical , which is fully deterministic and follows a canonical ordering ( Schneider et al. , 2015 ) of the atoms computed using RDKit ; and two variants of breadth-first search ( BFS ) , where we choose the first atom either randomly or as the first atom in canonical order , and then explore the remaining atoms in BFS order , breaking ties between equidistant next nodes randomly .

Summary: The paper study the problem of fragment-based molecule generation.  They propose a model MoLeR which consists of an encoder of molecular graph using Graph convolutional neural network (two GNN, one for complete molecules and one for partial molecules), a MLP decoder layer to predict the fragment, the attaching atom on the fragment, and the bonding atoms on the partial molecule. To train the model, it includes three losses for multi-task learning: a KL term between variational posterior and prior of latent representation, a self-reconstruction loss, and a property prediction MSE loss.  The paper conduct experiments on GulcaMol and show that it is able to generate molecules similar to the training molecule distribution, from scratch or from a given scaffold. It shows better results than LSTM, JTVAE, CDDD-MCTS, etc.