Molecular inverse synthesis route planning method and planning system
Through the end-to-end Transformer model and coding strategy optimization, the problem of inefficient multi-step reverse synthesis route planning in molecular inverse synthesis is solved, and more efficient molecular inverse synthesis path planning is achieved. The pruning technology reduces invalid nodes and improves search Efficiency and accuracy.
Patent Information
- Application Number
- CN202411253711.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-09-09
AI Technical Summary
The existing molecular inverse synthesis methods are inefficient in multi-step inverse synthesis route planning, especially because the output of the single-step model is discretely encoded and the individual evaluation function depends on the output probability value of the Transformer model, resulting in a huge search space and many invalid nodes. Influences search efficiency.
The end-to-end Transformer model is used for single-step inverse synthesis, a feature coding strategy is designed, two arrays are used for individual encoding, a probability model is constructed and population is optimized through variation, pruning technology reduces the search space, and the model input is SMILES expression. The output is a feasible path.
The efficiency and accuracy of multi-step inverse synthesis are improved, invalid nodes are reduced, search space is optimized, and more efficient molecular inverse synthesis path planning is achieved.
Smart Images

Figure CN119207637A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of molecular retrosynthesis, and relates to a molecular retrosynthesis route planning method and a planning system. Background Art
[0002] Molecular retrosynthesis is a very important task, especially in drug synthesis and other related fields. Its goal is to identify the retrosynthetic route from the target product to the original reactants. The retrosynthetic process includes single-step retrosynthesis and multi-step retrosynthesis. Single-step retrosynthesis involves decomposing the target product into one or more molecules that can be used to synthesize it. Multi-step retrosynthesis uses a decomposed molecule as a new target product and repeats the single-step retrosynthetic process until a molecule is found that exists in the raw material data set or can be obtained by simple synthesis.
[0003] In recent years, the Transformer model has become a key technology in the field of artificial intelligence. It has demonstrated excellent performance in various tasks, such as machine translation and computer vision. In the molecular retrosynthesis task, which can be regarded as a machine translation problem, the Transformer architecture has made substantial progress in the single-step retrosynthesis process, bringing important breakthroughs to this field.
[0004] The planning of multi-step retrosynthetic routes has received significant attention. This approach usually utilizes search algorithms such as Monte Carlo tree search and A* algorithm. In this process, the single-step retrosynthetic model plays a vital role, and its quality greatly affects the effectiveness of the multi-step search. The single-step model learns the reaction rules from the dataset, and then iteratively calls the single-step model within the multi-step search framework to infer and identify the most suitable simulation route. This iterative process improves the overall quality and efficiency of multi-step retrosynthesis. Other scholars have adopted Monte Carlo tree search (MCTS) as a multi-step search algorithm and Transformer architecture as a single-step retrosynthetic model to plan retrosynthetic routes. This approach effectively predicts feasible routes for different target products. MCTS is a search algorithm known for its powerful search capabilities and is suitable for complex problems. However, the efficiency of MCTS depends on the complexity of the problem and the number of simulations required. On the other hand, the Transformer architecture performs well on different datasets.
[0005] In general, after calling the single-step model, the multi-step search process can search for retrosynthetic routes and solve the problem of automatic retrosynthetic path planning for organic molecules.
[0006] There are currently existing methods that apply evolutionary algorithms (EA) to the problem of molecular retrosynthesis, introducing innovative methods to the field. While this approach has significantly advanced the application of evolutionary algorithms in molecular synthesis, it has also highlighted areas that are in urgent need of further improvement. First, the method combines a single-step model with a multi-step search algorithm, where the output of the single-step model is discretely encoded but the genetic operator is continuously encoded. Within the framework of the evolutionary algorithm, this encoding method may not fully exploit the potential efficiency of the algorithm. Second, the individual evaluation function relies on the probability values of the elements within each individual and the similarity between the leaf node and the molecules in the raw material database to drive the population iteration. Considering that these probabilities are generated based on the output of the Transformer model of the previous labeling conditions, the evaluation function may benefit more from the principles of molecular synthesis rather than the output probability values of the transformer. In addition, the difference in molecular complexity between the original molecules in the database and the more complex branched molecules at the leaf nodes often leads to low similarity scores, which may hinder effective population iteration. Finally, the method defines a large search space in which many nodes correspond to invalid molecular expressions, significantly affecting the efficiency of the search. For example, patent CN114822703A discloses a molecular retrosynthesis method, which first takes the target molecule as the root node, then expands the node to obtain the second node, and so on, searches the entire search space by recursive traversal to determine the retrosynthetic path of the target molecule, thereby improving the accuracy of compound molecule retrosynthesis prediction. Summary of the invention
[0007] In order to solve the shortcomings of the above-mentioned technology, the present invention provides a molecular retrosynthetic route planning method, comprising the following steps:
[0008] Step 1: Train an end-to-end transformer model using an existing data set, where the transformer model is used to achieve single-step retrosynthesis;
[0009] Step 2: Design a coding strategy based on the characteristics of the retrosynthesis problem;
[0010] Step 3: Initialize the population according to the encoding strategy, with the number of individuals being n;
[0011] Step 4: Construct a probability model. The input of the probability model is the population, and the output is a probability model.
[0012] Step 5: Sample the population through the probability model to obtain n new solutions;
[0013] Step 6: Put the original population and the new solution together, evaluate them through f(x), and get the top n solutions with the highest scores. If the last element of the individual is in the raw material library, save the current route.
[0014] Step 7: Use these n solutions to construct a probability model and repeat step 4 until the population converges or the maximum number of iterations is reached.
[0015] In step 1 of the present invention, the data set comes from data sets USPTO_50K, USPTO_MIT and Pistachio.
[0016] In the single-step retrosynthesis process of the present invention, the molecular expression is represented by a SMILES expression.
[0017] Preferably, if there are multiple reactants, they are separated by periods ('.'); placeholders<RX_T> Represents the Tth type of reaction.
[0018] In step 2 of the present invention, the encoding strategy is to encode each individual in the population using two arrays, the first array represents the sorting of the single-step model output from the root node to the leaf node, and the second array represents the branch that each element in the first array may choose.
[0019] The multi-step retrosynthesis process of the present invention is modeled as a tree search problem in a k-ary tree with q layers; the multi-step retrosynthesis process includes multiple single-step reactions, and the goal is to find a feasible path from a root node to a leaf node; the root node of the tree is the target product, which is gradually expanded downward into a k-ary tree through a single-step model; the search tree will expand downward by q layers, and the leaf nodes of the last layer represent the terminal reactants in the retrosynthesis.
[0020] When the present invention expands the search tree through the single-step model, invalid nodes are removed.
[0021] In step 4 of the present invention, a probability model is constructed according to the formula in the variation mode:
[0022] Variation mode: The construction of the probability model, the variable of the i-th dimension has k different results, and the number of occurrences of the result is defined as c i,j , j∈[0,k-1]; where c i,j represents the number of times j appears in the i-th variable and is defined as:
[0023]
[0024] in, represents the value of the mth individual in the ith variable, and n represents the number of individuals in the population; is an indicator function, defined as:
[0025]
[0026] The probability matrix of generation t is defined as:
[0027]
[0028] Among them, τ represents a minimum value, and the probability model is constructed as follows:
[0029]
[0030] Where α represents the attenuation coefficient, which is defined as:
[0031]
[0032] Among them, t represents the current iteration number, t max represents the maximum number of iterations; the new solution x passes through the probability model P i,j Sampling is performed; the probability matrix is normalized to ensure that the sum of the probabilities in each column is equal to 1, so that the matrix is suitable as a probability distribution in random sampling; the probability model is defined as:
[0033]
[0034] After generating a new solution, the present invention will combine the new solution with the current solution, and then calculate their similarity through the evaluation function f(x), select the first n individuals to enter the next round of iteration, and this process will continue until the stopping criterion is met or the maximum number of iterations is reached.
[0035] Based on the above method, the present invention also proposes a molecular retrosynthesis route planning system, comprising: a memory and a processor; a computer program is stored in the memory, and when the computer program is executed by the processor, the above method is implemented.
[0036] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above method is implemented.
[0037] Compared with the prior art, the present invention models the problem of multi-branch molecular retrosynthesis and models the problem as a tree search problem. Then, the optimization problem is encoded by an evolutionary algorithm, a suitable encoding strategy is selected, a matching genetic operator is designed, and a certain pruning technique is used to reduce the search space, thereby improving the efficiency of the multi-step search algorithm. The invention has the characteristics of being transferable and learnable. The invention innovatively utilizes the problem information for encoding, innovatively utilizes the genetic operator matching the encoding method, and innovatively uses the pruning technique on the application problem. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 It is a schematic diagram of the complete process of molecular retrosynthesis of the present invention.
[0040] Figure 2 It is a schematic diagram of a single-step model of the present invention.
[0041] Figure 3 It is a schematic diagram of retrosynthesis problem modeling and pruning of the present invention.
[0042] Figure 4 It is a flow chart of the evolutionary algorithm of the present invention. DETAILED DESCRIPTION
[0043] The invention is further described in detail with reference to the following specific embodiments and drawings. The process, conditions, experimental methods, etc. for implementing the present invention, except for the contents specifically mentioned below, are all common knowledge and common common sense in the art and are not particularly limited by the present invention.
[0044] 1. Definition of multi-branch retrosynthesis problem
[0045] In the retrosynthetic process, Figure 1 As shown in the figure, the conversion from the target product P to the reactant R constitutes a single-step retrosynthesis process. In this process, the molecular expression is represented by a SMILES expression, which is similar to a machine translation task. Therefore, transformers commonly used for machine translation tasks are used for single-step retrosynthesis work. Figure 2 As shown, the input to this task is the product SMILES expression of the reaction (e.g.,<RX_T> NC(=O)c1cn(Cc2c(F)cccc2F)nn1), the expected output is the SMILES expression of k reactants. If there are multiple reactants, they are separated by periods ('.') (e.g., Fc1cccc(F)c1CBr.[N-]=[N+]=[N-]). Placeholder<RX_T> Represents the Tth type of reaction.
[0046] The multi-step retrosynthetic process includes multiple single-step reactions, effectively tracing back from the target product P to the intermediate molecule R and then to the raw material W, such as Figure 1 The goal of the multi-step search process is to find a feasible path from the root node to the leaf node. Figure 3As shown, the root node of the tree is the target product, which is gradually expanded downward into a k-ary tree through the single-step model. Assume that multi-step retrosynthesis involves q single-step retrosynthesis processes, x = (x 1 ,x 2 ,...,x q ), and x i ∈{0,1,...,k-1} represents the xth step of the ith single-step retrosynthesis i possible outputs. The search tree will be extended down q levels, with the leaf nodes at the last level representing the terminal reactants in the retrosynthesis. The retrosynthesis problem is now modeled as a tree search problem in a k-ary tree with q levels.
[0047] When expanding the search tree through a single-step model, not all k SMILES expressions output by the model are valid. Therefore, invalid nodes are removed, which effectively prunes the search tree, reduces the search space, and ensures that all nodes in the search space are valid, such as Figure 3 shown.
[0048] In order to verify the feasibility of the route, the present invention compares the leaf node with the raw material library and calculates the objective function, which is defined as follows:
[0049] f(x)=(-1)*DSC(x i ,δ) (1) where DSC represents the calculation of x i Similarity of molecular structure with δ. It is a library of organic molecular raw materials.
[0050] 2. Evolutionary optimization solves tree search problems
[0051] Encoding method: The retrosynthesis problem is a discrete problem and each node may be a multi-branch problem. Therefore, the encoding method of each individual in the population is performed using two arrays, which are set to x and y respectively. The dimensions of x and y are the same, where y represents the vth branch of each node in the search tree, y = (y 1 ,y 2 ,...,y q ), y i ∈{0,1,...,v-1}. The present invention currently solves the 2-branch problem, so v=2.
[0052] Variation mode: The construction of the probability model, the variable of the i-th dimension may have k different results, and the number of times the result occurs is defined as c i,j , j∈[0,k-1]. where c i,j represents the number of times j appears in the i-th variable and is defined as:
[0053]
[0054] in, represents the value of the mth individual in the ith variable, and n represents the number of individuals in the population. is an indicator function, defined as:
[0055]
[0056] Therefore, the probability matrix of the tth generation can be defined as:
[0057]
[0058] Among them, τ represents a minimum value, so the probability model can be constructed as:
[0059]
[0060] Where α represents the attenuation coefficient, which is defined as:
[0061]
[0062] Among them, t represents the current iteration number, t max represents the maximum number of iterations. Therefore, the new solution x can be obtained through the probability model P i,j Sampling is performed. The probability matrix is normalized to ensure that the sum of the probabilities in each column is equal to 1, making the matrix suitable as a probability distribution in random sampling. The probability model is defined as:
[0063]
[0064] Decoding and evaluation: After generating new solutions, these new solutions will be combined with the current solutions, and then their similarity will be calculated through the evaluation function f(x). The first n individuals are selected to enter the next round of iteration, and this process will continue until the stopping criteria is met or the maximum number of iterations is reached.
[0065] The molecular retrosynthesis method proposed by the present invention comprises the following steps:
[0066] Step 1: Train an end-to-end transformer model using the existing dataset to implement single-step retrosynthesis;
[0067] Step 2: Design an encoding strategy based on the characteristics of the retrosynthesis problem, that is, each individual in the population is encoded using two arrays. The first array represents the order of the single-step model outputs from the root node to the leaf node, and the second array represents the possible branching situations for each element in the first array.
[0068] Step 3: Initialize the population according to the above encoding strategy, with the number of individuals being n;
[0069] Step 4: Construct a probability model according to the formula in the above mutation method. The input of the probability model is the population, and the output is a probability model.
[0070] Step 5: Sample the population through the probability model to obtain n new solutions;
[0071] Step 6: Put the original population and the new solution together, evaluate them through f(x), and get the top n solutions with the highest scores. If the last element of the individual is in the raw material library, save the current route.
[0072] Step 7: Use these n solutions to construct a probability model and repeat step 4 until the population converges or the maximum number of iterations is reached.
[0073] like Figure 4 As shown, during the encoding process, both arrays in the individual are Figure 4 Search by .
[0074] In general, the present invention fully overcomes the discreteness and multi-branch problems of the retrosynthesis problem, finds a suitable encoding method and a matching genetic operator, and finally realizes the multi-branch retrosynthesis path search.
[0075] Example 1
[0076] Step 1: The formats of the target molecules and generated molecules in the existing dataset are as follows. They appear in pairs and are the input and output of the single-step end-to-end model respectively:
[0077] <RX_1> c1ccc(Cn2ccc3ccccc32)cc1 and ClCc1ccccc1.c1ccc2[nH]ccc2c1;
[0078] <RX_6> CCOc1ccc2ccccc2c1-c1c[nH]c(N)n1
[0079] CCOc1ccc2ccccc2c1-c1c[nH]c(NC(C)=O)n1;
[0080] A large number of data sets similar to the above characters are fed into the transformer model to achieve single-step synthesis.
[0081] Step 2: Encode the individuals in the population according to the two-branch characteristic of each node. Assuming that the length of the individual is 4 and the output of the single-step model is 10, the encoding result of the individual is as follows: [[2,3,1,5],[0,1,0,0]]. The first array represents the order of the single-step model output from the root node to the leaf node, and the second array represents the branch that each element in the first array may choose.
[0082] Step 3: Assuming the population size is 5, initialize the population according to the above individual encoding strategy:
[0083] [[2,3,1,5],[0,1,0,0]]
[0084] [[1,3,2,6],[1,1,0,0]]
[0085] [[9,2,1,7],[0,0,0,1]]
[0086] [[6,3,8,4],[1,1,0,1]]
[0087] [[2,5,3,1],[0,0,1,0]]
[0088] Step 4: According to formula 2 to formula 7, take the population initialized in step 3 as input, build a probability model, and use this probability model as a way for the evolutionary algorithm to generate new solutions. Use the following code to build the probability model:
[0089] import numpy as np
[0090] def update(self,Xs):
[0091] self.t+=1
[0092] gamma=self.cal_gamma(self.t)
[0093] [No,Dim]=Xs.shape
[0094] for d in range(Dim):
[0095] counts = np.bincount(Xs[:,d],minlength = self.M) #counts dimension is M*1
[0096] col_sum = np.sum(counts) + 1e-10 # add a very small positive number
[0097] self.Prob[:,d]=(1-gamma)*self.Prob[:,d]+gamma*counts.T / col_sum
[0098] self.Prob[:,d] = np.clip(self.Prob[:,d],0,1) #The dimension of self.Prob is M*D
[0099] Step 5: Sample the population through the probability model. The sampling method is as follows:
[0100] def sample(self,N):
[0101] col_probs=self.Prob / np.sum(self.Prob,axis=0)
[0102] Xs=np.apply_along_axis(lambda p:np.random.choice(self.M,size=N,p=p),axis=0,arr=col_probs)
[0103] return Xs
[0104] Sampling yields 5 new solutions, as follows:
[0105] [[3,1,2,5],[1,0,0,0]]
[0106] [[1,2,6,3],[1,1,0,1]]
[0107] [[5,1,3,8],[0,1,0,1]]
[0108] [[2,7,4,6],[1,0,0,1]]
[0109] [[3,1,0,8],[0,0,1,0]]
[0110] Step 6: Combine the original population with the newly liberated population to obtain the following 10 individuals
[0111] [[2,3,1,5],[0,1,0,0]]
[0112] [[1,3,2,6],[1,1,0,0]]
[0113] [[9,2,1,7],[0,0,0,1]]
[0114] [[6,3,8,4],[1,1,0,1]]
[0115] [[2,5,3,1],[0,0,1,0]]
[0116] [[3,1,2,5],[1,0,0,0]]
[0117] [[1,2,6,3],[1,1,0,1]]
[0118] [[5,1,3,8],[0,1,0,1]]
[0119] [[2,7,4,6],[1,0,0,1]]
[0120] [[3,1,0,8],[0,0,1,0]]
[0121] These 10 individuals are evaluated by f(x). During the evaluation process, the last molecule of the route is decoded to obtain the molecular SMILES expression, which is then compared with the molecules in the raw material database. The top 5 solutions with the highest scores are:
[0122] [[2,3,1,5],[0,1,0,0]]
[0123] [[1,3,2,6],[1,1,0,0]]
[0124] [[1,2,6,3],[1,1,0,1]]
[0125] [[5,1,3,8],[0,1,0,1]]
[0126] [[3,1,0,8],[0,0,1,0]]
[0127] Among them, [[5,1,3,8],[0,1,0,1]] satisfies the last element of the individual in the raw material library and saves the current route.
[0128] Step 7: Take these five solutions as input and repeat step 4 until the population converges or the maximum number of iterations is reached.
[0129] The protection content of the present invention is not limited to the above embodiments. Without departing from the spirit and scope of the inventive concept, changes and advantages that can be thought of by those skilled in the art are included in the present invention and are protected by the attached claims.
Claims
1. A molecular retrosynthetic route planning method, characterized in that: The following steps are involved: Step 1: Train an end-to-end transformer model using an existing data set, where the transformer model is used to achieve single-step retrosynthesis; Step 2: Design a coding strategy based on the characteristics of the retrosynthesis problem; Step 3: Initialize the population according to the encoding strategy, with the number of individuals being n; Step 4: Construct a probability model. The input of the probability model is the population, and the output is a probability model. Step 5: Sample the population through the probability model to obtain n new solutions; Step 6: Put the original population and the new solution together, evaluate them through f(x), and get the top n solutions with the highest scores. If the last element of the individual is in the raw material library, save the current route. Step 7: Use these n solutions to construct a probability model and repeat step 4 until the population converges or the maximum number of iterations is reached.
2. The molecular retrosynthetic route planning method according to claim 1, characterized in that: In step 1, the data set comes from the data sets USPTO_50K, USPTO_MIT and Pistachio.
3. The molecular retrosynthetic route planning method according to claim 1, characterized in that: In the single-step retrosynthesis process, the molecular expression is represented by a SMILES expression; Preferably, if there are multiple reactants, they are separated by periods ('.'); placeholders<RX_T> Represents the Tth type of reaction.
4. The molecular retrosynthetic route planning method according to claim 1, characterized in that: In step 2, the encoding strategy is to encode each individual in the population using two arrays, the first array represents the order of the single-step model output from the root node to the leaf node, and the second array represents the branch that each element in the first array may choose.
5. The molecular retrosynthetic route planning method according to claim 1, characterized in that: The multi-step retrosynthetic process is modeled as a tree search problem in a k-ary tree with q layers; the multi-step retrosynthetic process includes multiple single-step reactions, and the goal is to find a feasible path from the root node to the leaf node; the root node of the tree is the target product, which is gradually expanded downward into a k-ary tree through a single-step model; the search tree will expand downward q layers, and the leaf nodes of the last layer represent the terminal reactants in the retrosynthesis.
6. The molecular retrosynthetic route planning method according to claim 1, characterized in that: When expanding the search tree through the single-step model, invalid nodes are removed.
7. The molecular retrosynthetic route planning method according to claim 1, characterized in that: In step 4, a probability model is constructed according to the formula in the mutation method: Variation mode: The construction of the probability model, the variable of the i-th dimension has k different results, and the number of occurrences of the result is defined as c i,j , j∈[0,k-1]; where c i,j represents the number of times j appears in the i-th variable and is defined as: in, represents the value of the mth individual in the ith variable, and n represents the number of individuals in the population; is an indicator function, defined as: The probability matrix of generation t is defined as: Among them, τ represents a minimum value, and the probability model is constructed as follows: Where α represents the attenuation coefficient, which is defined as: Among them, t represents the current iteration number, t max represents the maximum number of iterations; the new solution x passes through the probability model P i,j Sampling is performed; the probability matrix is normalized to ensure that the sum of the probabilities in each column is equal to 1, so that the matrix is suitable as a probability distribution in random sampling; the probability model is defined as:
8. The molecular retrosynthetic route planning method according to claim 1, characterized in that: After generating a new solution, the new solution will be combined with the current solution, and then their similarity will be calculated by evaluating the function f(x). The first n individuals will be selected to enter the next round of iteration. This process will continue until the stopping criterion is met or the maximum number of iterations is reached.
9. A molecular retrosynthesis route planning system, characterized in that: include: Memory and processor; The memory stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Context sensing single-step inverse synthesis prediction method and device based on Transform
CN115798621A
Biosynthetic pathway prediction method and system based on deep learning
CN116825202A
Method and apparatus for automated design of chemical synthesis routes
US20030220716A1
System and method for evaluating chemical compound data using and applying a virtual landscape
WO2024138182A1
