Machine learning method and system based on SMILES
By preprocessing the SMILES string with BASE64 encoding, the problem that One-hot encoding cannot extract the semantics between characters is solved, which improves the performance of machine learning tasks, especially the model accuracy in novel molecular design and molecular property prediction tasks.
Patent Information
- Application Number
- CN202110290375.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-18
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2041-03-18
AI Technical Summary
In existing technologies, one-hot encoding of SMILES strings can only extract character information and cannot handle the implicit semantics between characters, which limits the performance of SMILES-based machine learning tasks.
The SMILES string is preprocessed using BASE64 encoding technology to convert the characters into BASE64 characters. The vector matrix is obtained through One-Hot encoding and used as a training set for training the machine learning model.
Effective extraction of the implicit semantics between SMILES characters improves the performance of machine learning tasks, especially in novel molecular design and molecular property prediction tasks, enhancing the model's reconstruction and prediction accuracy.
Smart Images

Figure CN115114970B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine learning, and in particular relates to a machine learning method and system based on SMILES. Background Art
[0002] The Simplified Molecular Input Line Entry Specification (SMILES) string is widely used in the field of molecular description. It was created by David Weininger in 1986. It uses a single line of text to describe the molecular structure and is a typical "linear symbol". Thanks to its simple syntax and shorter text, SMILES is the most widely used string symbol in the field of molecular description today. SMILES converts chemical structures into strings based on specific rules and chemical symbols, and uses simplified chiral specifications (@ or @@) to distinguish molecular stereostructures. The symbol "@" indicates that the following atoms are listed counterclockwise, and the symbol "@@" indicates that the following atoms are listed clockwise. In addition, SMILES can also represent structures such as branches and cycles. Table 1 shows the SMILES corresponding to 5 different molecules.
[0003] molecular SMILES String Ethane CC carbon dioxide O=C=O Acetic acid CC(=O)O benzene c1ccccc1 phenol Oc1ccccc1
[0004] Table 1
[0005] When using SMILES data for certain chemical tasks, such as new molecule design and molecular property prediction, the SMILES data needs to be converted into vector form through certain encoding methods (such as One-hot encoding) to input into the machine learning model for training.
[0006] China's national invention "A quantitative structure-activity method and device based on SMILES" (application publication number: CN111312340A, application date: June 19, 2020) proposed a SMILES-based attribute prediction model, which converts the SMILES string into the corresponding One-Hot digital code and uses the Embedding layer to process the One-Hot digital code.
[0007] China's national invention "Method and system for predicting the activity of small drug molecules based on a bidirectional long-short memory model" (application publication number: CN111640471A, application date: September 8, 2020) proposes a method for predicting the activity of small drug molecules based on a bidirectional long-short memory model. The model is trained using SMILES data, and the SMILES expressions of all molecules are standardized during the preprocessing process, and then the preprocessed data set is One-hot encoded.
[0008] The traditional one-hot encoding process of SMILES is as follows Figure 1 shown. Figure 1 As can be seen, the molecular structure is first converted into SMILES, and then all SMILES are traversed to combine different characters into a non-repeating character set (Charset). Then each SMILES is traversed, and for each character, an array with the same length as the Charset and all values are 0 is established, and the position of the character in the Charset is found, and the value of the corresponding position in the array is set to 1. Each SMILES is represented by multiple array sets of this type (SMILES length). It can be clearly seen that the One-hot encoding method can only extract character information in the process of encoding SMILES, and cannot process the implicit semantics between characters. The One-hot matrix only contains the information of each character, not the information between characters. This limits the performance of machine learning tasks based on SMILES. Summary of the invention
[0009] To solve the above problems, the present invention pre-processes the SMILES corresponding to the chemical molecule through BASE64 encoding technology to extract the implicit semantics between SMILES characters and improve the performance of machine learning tasks based on SMILES. The machine learning method of the present invention specifically includes: converting the SMILES string into multiple BASE64 characters; obtaining the vector matrix of the BASE64 characters through One-Hot encoding; using the vector matrix as a training set to train the machine learning model to perform chemical tasks.
[0010] The machine learning method described in the present invention, wherein the step of obtaining the BASE64 character comprises: converting each character of the SMILES string into a first byte represented by ASCII binary code; converting all the first bytes into a second byte represented by BASE64 binary code; generating a corresponding decimal BASE64 code index for the second byte, and obtaining the corresponding BASE64 character.
[0011] The machine learning method described in the present invention, wherein the step of obtaining the second byte includes: selecting 3 adjacent first bytes in order from front to back, connecting them end to end in sequence to obtain a 24-bit byte, dividing the 24-bit byte evenly into 4 6-bit bytes, and adding 2 bits of 0 to the head of each 6-bit byte to obtain the second byte; traversing all the first bytes; when the remaining first bytes are less than 3, connecting the remaining first bytes end to end in sequence and filling 24 bits with 0 to obtain the 24-bit byte.
[0012] The machine learning method described in the present invention, wherein the chemical task includes: a new molecule design task based on SMILES, and a molecular property prediction task based on SMILES.
[0013] The present invention also proposes a SMILES-based machine learning system, comprising: a preprocessing module, used to convert a SMILES string into multiple BASE64 characters; a data extraction module, used to obtain a vector matrix of the BASE64 characters through One-Hot encoding; and a model training module, used to use the vector matrix as a training set to train a machine learning model to perform chemical tasks.
[0014] The machine learning system described in the present invention, wherein the preprocessing module includes: a first conversion module, used to convert each character of the SMILES string into a first byte represented by ASCII binary code; a second conversion module, used to convert all the first bytes into second bytes represented by BASE64 binary code; a third conversion module, used to generate a corresponding decimal BASE64 encoding index for the second byte and obtain the corresponding BASE64 character.
[0015] The machine learning system described in the present invention, wherein the second conversion module specifically includes: a division module, used to divide the first byte to obtain the second byte, wherein 3 adjacent first bytes are selected in order from front to back, and are sequentially connected end to end to obtain a 24-bit byte, the 24-bit byte is evenly divided into 4 6-bit bytes, and 2 bits of 0 are added to the head of each 6-bit byte to obtain the second byte; a traversal module, used to call the division module to traverse all the first bytes, and when the remaining first bytes are less than 3, the remaining first bytes are sequentially connected end to end and 24 bits are filled with 0 to obtain the 24-bit byte.
[0016] The machine learning system described in the present invention, wherein the chemical task includes: a new molecule design task based on SMILES, and a molecular property prediction task based on SMILES.
[0017] The present invention also proposes a computer-readable storage medium storing computer-executable instructions, characterized in that when the computer-executable instructions are executed, the SMILES-based machine learning method as described above is implemented.
[0018] The present invention also proposes a data processing device, comprising the computer-readable storage medium as described above. When the processor of the data processing device calls and executes the computer-executable instructions in the computer-readable storage medium, it performs SMILES-based machine learning to perform chemical tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1It is a schematic diagram of the One-hot encoding SMILES process in the prior art.
[0020] Figure 2 It is a flow chart of the SMILES-based machine learning method of the present invention.
[0021] Figure 3 It is a schematic diagram of the effect of the SMILES-based machine learning method of the present invention.
[0022] Figure 4 It is a schematic diagram of a data processing device of the present invention. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation method described herein is only used to explain the present invention and is not used to limit the present invention.
[0024] The present invention designs a SMILES preprocessing method based on BASE64 encoding technology. The method can preprocess SMILES before one-hot encoding SMILES, extract the implicit semantics between SMILES characters, and improve the performance of SMILES machine learning tasks.
[0025] BASE64 is the most common and basic binary encoding method for transmitting 8-bit byte codes on the Internet. It is a method for converting non-ASCII character data into ASCII characters. It uses 64 printable characters (including az, AZ, 0-9, / , +) to represent binary data 0-63 (as shown in Table 2).
[0026] index Corresponding characters index Corresponding characters index Corresponding characters index Corresponding characters 0 A 16 Q 32 g 48 w 1 B 17 R 33 h 49 x 2 C 18 S 34 i 50 y 3 D 19 T 35 j 51 z 4 E 20 U 36 k 52 0 5 F 21 V 37 l 53 1 6 G 22 W 38 m 54 2 7 H 23 X 39 n 55 3 8 I 24 Y 40 o 56 4 9 J 25 Z 41 p 57 5 10 K 26 a 42 q 58 6 11 L 27 b 43 r 59 7 12 M 28 c 44 s 60 8 13 N 29 d 45 t 61 9 14 O 30 e 46 u 62 + 15 P 31 f 47 v 63 /
[0027] Table 2
[0028] The BASE64 encoding works by converting three 8-bit bytes into four 6-bit bytes, and then adding two 0s in front of the 6-bit bytes to form an 8-bit byte. Three bytes have 24 bits, which just corresponds to four BASE64 units with 6 as the unit. Three traditional bytes can be represented by four BASE64 character values to ensure that the number of valid bits is the same, so the BASE64 encoded string must be divisible by 4. In the data encoding conversion process, BASE64 puts the 3-byte input data into a 24-bit buffer one by one, and the first byte occupies the high bit. If the data is less than 3 bytes, the remaining bits in the buffer are filled with 0. Then take out 6 bits each time, calculate the index value corresponding to the binary, and compare it with the characters in the BASE64 encoding table as the encrypted encoding output. Repeat the above operation until all input data conversion is completed, so the actual encrypted data volume is one-third of the data volume before encryption.
[0029] Figure 2 : is a flow chart of the SMILES-based machine learning method of the present invention. Figure 2 As shown, the machine learning method of the present invention specifically includes:
[0030] Step S1, converting the SMILES string of the target molecule into multiple BASE64 characters;
[0031] Step S11, converting each character in the SMILES string of the target molecule into an 8-bit byte represented by ASCII binary code, for example, converting "C" into "01000011";
[0032] Step S12, converting all obtained ASCII coded 8-bit bytes into 8-bit bytes represented by BASE64 binary code;
[0033] Among them, according to the order of ASCII coded 8-bit bytes from front to back, 3 adjacent ASCII coded 8-bit bytes are selected each time and put into a 24-bit buffer, and the byte order is maintained, and then 6 bits are taken from the buffer from front to back in 4 times, and two 0s are added in front of these 6 bits to form an 8-bit byte. This 8-bit byte is the 8-bit byte represented by BASE64 binary code; all ASCII coded 8-bit bytes are traversed to obtain the BASE64 coded 8-bit bytes corresponding to all ASCII coded 8-bit bytes; if the remaining ASCII coded 8-bit bytes are less than 3, the remaining ASCII coded 8-bit bytes are put into the buffer, and the remaining bits in the 24-bit buffer are supplemented with 0;
[0034] Step S13, converting the BASE64 encoded 8-bit byte into a corresponding decimal BASE64 encoded index, and obtaining the corresponding BASE64 character by comparing the character in the BASE64 encoding table;
[0035] Step S2, obtaining a vector matrix of BASE64 characters through One-Hot encoding; in this step, the process of One-Hot encoding BASE64 characters is consistent with the process of One-hot encoding SMILES, which will not be repeated here;
[0036] Step S3, using the vector matrix obtained by One-Hot encoding BASE64 characters as a training set, and training the machine learning model to perform chemical tasks, for example, a new molecule design task based on the target molecule SMILES data, or a molecular property prediction task based on the target molecule SMILES data, etc.
[0037] The specific implementation method of the present invention is shown below through the process of BASE64 encoding a shorter string. Table 3 is the corresponding conversion process of the BASE64 encoded string "CCc":
[0038]
[0039] Table 3
[0040] As can be seen from Table 3, "CCc" is first converted to ASCII code, then converted to binary representation, and then grouped into 6 characters (with 2 0s added in front) to form BASE64 binary, and then converted to decimal index, and finally the corresponding character is found from the BASE64 encoding table according to the index. It can be clearly seen here that the character "0N" contains the information of the second "C" in the character "CCc" and the implicit information between it and the surrounding characters (the first "C" and the third "c").
[0041] In specific chemical tasks, such as the new molecular design task based on the variational auto-encoder (VAE) model, the BASE64 method is used to pre-process the SMILES before one-hot encoding the SMILES to extract the implicit information between the SMILES characters, and then the BASE64-encoded string is one-hot encoded. After that, the one-hot encoded matrix is input into the VAE model for molecular reconstruction. The results are shown in Table 4:
[0042] method Reconstruction accuracy Reconstruction accuracy of non-padding characters Prior art methods 98.14% 95.08% Method of the present invention 98.53% 96.33%
[0043] Table 4
[0044] As can be seen in Table 4, the BASE64 encoding method improves the performance of VAE, with the reconstruction accuracy of the model validation set increased from 98.14% to 98.53%, and the reconstruction accuracy of non-filling characters increased from 95.08% to 96.33%. This shows that the BASE64 encoding method effectively extracts the implicit semantics between SMILES characters.
[0045] In addition, in order to eliminate the influence of padding characters on reconstruction accuracy, fixed-length SMILES were selected for experiments in specific chemical tasks. The length of SMILES in the data set was counted, and it was found that the number of SMILES with a length between 40 and 50 was the largest. Therefore, SMILES with lengths of 42, 44, 46, 48, and 50 were selected, and then this method was used to extract inter-character information, and then the molecular reconstruction experiment was carried out. The results are shown in Figure 2. Figure 3 shown. Figure 3 It can be seen that the reconstruction rate of the model using the BASE64 method has been significantly improved. This fully demonstrates that the pre-processing of SMILES characters by BASE64 encoding technology in the SMILES-based machine learning method can effectively extract the information between SMILES characters.
[0046] The SMILES-based machine learning method of the present invention can be applied not only to the above-mentioned new molecular design field, but also to the molecular property prediction field. For example, the BASE64 encoding method is first used to extract the information between SMILES characters, and then the character string is converted into vector data using One-hot encoding. Subsequently, a machine learning regression model is constructed, and the vector data is input into the machine learning model to train a molecular property prediction model.
[0047] Figure 4 Schematic diagram of the data processing device of the present invention. Figure 4As shown, an embodiment of the present invention further provides a computer-readable storage medium, and a data processing device. The computer-readable storage medium of the present invention stores computer-executable instructions, and when the computer-executable instructions are executed by the processor of the data processing device, the above-mentioned machine learning method based on SMILES is implemented. A person of ordinary skill in the art can understand that all or part of the steps in the above-mentioned method can be completed by instructing related hardware (such as a processor, FPGA, ASIC, etc.) through a program, and the program can be stored in a readable storage medium, such as a read-only memory, a disk or an optical disk, etc. All or part of the steps in the above-mentioned embodiment can also be implemented using one or more integrated circuits. Accordingly, each module in the above-mentioned embodiment can be implemented in the form of hardware, such as implementing its corresponding functions through an integrated circuit, or can be implemented in the form of a software function module, such as implementing its corresponding functions through a processor executing a program / instruction stored in a memory. The embodiment of the present invention is not limited to any specific form of combination of hardware and software.
[0048] The string obtained after preprocessing by this method contains more information than the original SMILES, which includes not only character information but also implicit information between characters. When this method is applied to chemical tasks such as new molecule design and molecular property prediction based on SMILES, more molecular features can be extracted, which improves the accuracy of model reconstruction of molecules and molecular property prediction.
[0049] The above implementation modes are only used to illustrate the present invention, but not to limit the present invention. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the present invention. The patent protection scope of the present invention should be defined by the claims.
Claims
1. A machine learning method based on SMILES, characterized in that: include: Convert the SMILES string into multiple BASE64 characters; Obtain the vector matrix of the BASE64 character through One-Hot encoding; This vector matrix is used as a training set to train the machine learning model for chemistry tasks.
2. The machine learning method according to claim 1, wherein: The steps to obtain the BASE64 character include: Convert each character of the SMILES string into the first byte represented by ASCII binary encoding; Convert all the first bytes into second bytes represented by BASE64 binary encoding; Generate a corresponding decimal BASE64 encoding index for the second byte and obtain a corresponding BASE64 character.
3. The machine learning method according to claim 2, wherein: The steps of obtaining the second byte include: Select three adjacent first bytes from front to back, connect them end to end in sequence to obtain a 24-bit byte, divide the 24-bit byte into four 6-bit bytes evenly, and add two 0s to the head of each 6-bit byte to obtain the second byte; Traverse all the first bytes; when the remaining first bytes are less than 3, connect the remaining first bytes end to end in sequence and fill 24 bits with 0 to obtain the 24-bit byte.
4. The machine learning method according to claim 1, wherein: The chemistry tasks include: New molecular design tasks based on SMILES, and molecular property prediction tasks based on SMILES.
5. A machine learning system based on SMILES, characterized in that: include: Preprocessing module, used to convert SMILES string into multiple BASE64 characters; A data extraction module is used to obtain the vector matrix of the BASE64 character through One-Hot encoding; The model training module is used to train the machine learning model for chemical tasks using the vector matrix as a training set.
6. The machine learning system of claim 5, wherein: The preprocessing module includes: A first conversion module, used for converting each character of the SMILES string into a first byte represented by ASCII binary code; A second conversion module, used for converting all the first bytes into second bytes represented by BASE64 binary code; The third conversion module is used to generate a corresponding decimal BASE64 encoding index from the second byte and obtain a corresponding BASE64 character.
7. The machine learning system of claim 6, wherein: The second conversion module specifically includes: a dividing module, used for dividing the first byte to obtain the second byte, wherein three adjacent first bytes are selected from front to back, and the first and last bytes are sequentially connected to obtain a 24-bit byte, the 24-bit byte is evenly divided into four 6-bit bytes, and two 0s are added to the head of each 6-bit byte to obtain the second byte; The traversal module is used to call the division module to traverse all the first bytes, and when the remaining first bytes are less than 3, the remaining first bytes are sequentially connected head to tail and filled with 0 to obtain the 24-bit byte.
8. The machine learning system of claim 5, wherein: The chemistry tasks include: New molecular design tasks based on SMILES, and molecular property prediction tasks based on SMILES.
9. A computer-readable storage medium storing computer-executable instructions, characterized in that: When the computer executable instructions are executed, the SMILES-based machine learning method as described in any one of claims 1 to 4 is implemented.
10. A data processing device, comprising the computer-readable storage medium as described in claim 9, when the processor of the data processing device calls and executes the computer-executable instructions in the computer-readable storage medium, performs SMILES-based machine learning to perform chemical tasks.
Citation Information
Patent Citations
Quantitative structure-activity method and device based on SMILES
CN111312340A
Drug small molecule activity prediction method based on bidirectional long-short memory model
CN111640471A
Encoding method, decoding method, encoding device and decoding device
CN105450232A
Intelligent identification method for chemical structural formula
CN108062529A