DNA data encoding and decoding method, device, computer equipment and storage medium
Through the depth-first search algorithm screening and sequence replacement processing, the problems of homopolymer and GC content imbalance and taboo sequences in DNA data storage are solved, and the stability and reliability of the generated DNA strands are improved.
Patent Information
- Application Number
- CN202310847818.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-11
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2043-07-11
AI Technical Summary
In the existing DNA data storage technology, the problems of homopolymer and GC content imbalance and contraindicated sequences lead to high error rates for amplification and sequencing operations, affecting the stability and reliability of data storage.
The depth-first search algorithm is used to screen the base base sequence, build a mapping table and use replacement sequences to process taboo sequences to ensure that the generated DNA strand does not contain excessively long homopolymers, balanced GC content and no taboo sequences, and improve the stability of data encoding and decoding through suffix automata and error correction code.
The generated DNA strand does not contain excessively long homopolymers, and the GC content is balanced, which avoids taboo sequences, reduces the probability of self-folding to generate secondary structures, and improves the stability and reliability of data storage.
Smart Images

Figure CN116864006B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of bioinformatics, and in particular relates to a DNA data encoding and decoding method, apparatus, computer equipment, and storage medium. Background Art
[0002] With the rapid development of the information industry, the amount of data generated by various industries, especially the internet, is growing. DNA (deoxyribonucleic acid) storage, as a new data storage method, encodes binary files into a sequence consisting of the four DNA bases: A (adenine), T (thymine), G (guanine), and C (cytosine). DNA chains are then synthesized according to this sequence to store data. Due to the structural characteristics of DNA, encoding binary data into base pairs requires consideration of certain limitations. For example, a homopolymer is a long, repeating sequence of single bases in DNA, such as AAAAAA or CCCCCCC. This structure increases the probability of errors in the data generated during DNA amplification and sequencing operations. The GC content of a DNA chain is the ratio of G and C to all bases in the DNA chain. In the DNA double helix, G and C are linked by three hydrogen bonds, while A and T are linked by two. Therefore, the hydrogen bonds formed by GC pairing are more stable. A low GC content can reduce the DNA chain's ability to withstand high temperatures, making the overall structure unstable. However, a high GC content can make it difficult to hydrolyze, resulting in low amplification efficiency and affecting sequencing and decoding. Therefore, during encoding, the GC content of DNA bases must be kept within a balanced range. If some segments in a DNA molecule form anti-palindromic sequences, they may self-fold during amplification to produce secondary structures, which can also affect sequencing and decoding. Therefore, it is necessary to avoid anti-palindromic segments in the generated DNA sequence as much as possible. In addition, it is necessary to avoid the presence of certain specific sequences in DNA during the synthesis process. These sequences can affect DNA storage in organisms and even cause adverse reactions in the organism itself. These are called taboo sequences. Taboo sequences should be completely removed during encoding, and the replaced sequences and replacement relationships should be preserved to ensure that the original data can be restored.
[0003] In a related paper, Goldman et al. [Goldman N, Bertone P, Chen S, et al. Toward spractical, high-capacity, low-maintenance information storage in synthesized DNA [J]. Nature, 2013, 494(7435): 77-80.] proposed a ternary round-robin encoding algorithm to address the homopolymer problem. This paper first converts the text into a ternary sequence using Huffman coding and then into a base sequence. Each time the content changes, the Huffman tree needs to be rebuilt, which is very time-consuming. Moreover, the round-robin encoding only eliminates homopolymers in the sequence and does not restrict other conditions such as GC content. Erlich et al. [Erlich Y, Zielinski D. DNA Fountain enables a robust and efficient storage architecture [J]. science, 2017, 355(6328): 950-954.] used the random generation characteristics of fountain codes to screen the generated droplets to solve the problems of homopolymers and GC content; BGI Yin-Yang Coding [Ping Z, Chen S, Zhou G, et al. Toward spractical and robust DNA-based data archiving using the yin–yang codec system [J]. Nature Computational Science, 2022, 2(4): 234-242.] selected a suitable encoding method from several encoding methods, so that the encoding result does not contain homopolymers, has an appropriate GC content, and the free energy is greater than a certain value, thereby reducing the folding probability; although the above literature can filter out sequence fragments that do not meet the requirements, there is a certain probability that a larger number of generations will be required to meet the requirements, resulting in unstable encoding and decoding time. Li et al. [Li X, Zhou S, Zou L. Design of DNA Storage Coding with Enhanced Constraints [J]. Entropy, 2022, 24 (8): 1151.] first proposed some constraints to control homopolymers, Hamming distance, GC content, and reverse pairing Dynamic-Time-Warping (DTW) distance in base sequences, and then applied them to Aquila Optimizer. After optimization, the ROEAO algorithm was obtained and used to generate qualified base sequences. However, this paper did not consider the problem of taboo sequences. Summary of the Invention
[0004] The present application provides a DNA data encoding and decoding method, apparatus, computer equipment, and storage medium, which aim to solve at least one of the above-mentioned technical problems in the prior art to a certain extent.
[0005] In order to solve the above problems, this application provides the following technical solutions:
[0006] A DNA data encoding and decoding method, comprising:
[0007] Setting an initial sequence, sequentially adding bases to the end of the initial sequence to generate a basic base sequence of the DNA chain, and screening the basic base sequence using a depth-first search algorithm to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content, and taboo sequences;
[0008] selecting a first set number of base base sequences from the screened base base sequences as base base sequences used in encoding binary data, constructing a mapping table based on a mapping relationship between the first set number of base base sequences and the binary data, and selecting a second set number of base base sequences as replacement sequences for replacing taboo sequences;
[0009] The binary data to be encoded is encoded into a base sequence of a DNA chain according to the mapping table, and the taboo sequence in the base sequence is replaced by the replacement sequence.
[0010] The technical solution adopted in the embodiment of the present application further includes: using a depth-first search algorithm to screen the basic base sequence, and obtaining a basic base sequence that meets the preset conditions is specifically:
[0011] Set an initial sequence S of an empty string;
[0012] Add A, T, G, and C to the end of the initial sequence S to generate the basic base sequences S1, S2, S3...S n , n represents the total number of generated basic base sequences, and after each basic base sequence is generated, the basic base sequence is searched using a depth-first search algorithm to determine whether there is a homopolymer with a length greater than a first preset value in the basic base sequence. If so,
[0013] Stop searching on the basic base sequence and determine whether the length of the basic base sequence is equal to a second preset value. If yes,
[0014] Determine whether the number of bases G and C in the basic base sequence reaches a third preset value, and if so,
[0015] Determine whether there is a predefined taboo sequence in the basic base sequence. If there is, delete the taboo sequence; if not, add the basic base sequence to the set of basic base sequences.
[0016] The technical solution adopted in the embodiment of the present application further includes: selecting a first set number of basic base sequences from the screened basic base sequences as the basic base sequences used for binary data encoding, constructing a mapping table according to the mapping relationship between the first set number of basic base sequences and binary data, and selecting a second set number of basic base sequences as the replacement sequences for replacing taboo sequences, specifically:
[0017] Regard all the basic base sequences in the set of basic base sequences as nodes, and use the reverse complementary DTW algorithm to calculate the similarity between each pair of basic base sequences pairwise;
[0018] Judge whether the similarity between each pair of basic base sequences is greater than the fourth preset value. If so, add an edge between the nodes corresponding to each pair of basic base sequences to obtain a graph composed of the nodes represented by the basic base sequences and the edges connecting them;
[0019] Sort all the nodes in the graph in ascending order according to the degree, select the top N basic base sequences for binary data encoding, construct a mapping table according to the mapping relationship between the N basic base sequences and binary data, and select the last M basic base sequences as the replacement sequences for replacing taboo sequences, and add the replacement sequences to the replacement set.
[0020] The technical solution adopted in the embodiment of the present application further includes: assuming that two basic base sequences are L1 and L2, with lengths l1 and l2 respectively, the specific method of using the reverse complementary DTW algorithm to calculate the similarity between basic base sequences pairwise is:
[0021] Reverse L2, and replace the original bases in L2 with their complementary bases;
[0022] Set a two-dimensional array d, with a size of at least l1×l2 and an initial value of 0;
[0023] Judge whether L1[0]==L2[0] holds. If it holds, then d[0][0]=1; otherwise, d[0][0]=0;
[0024] For d[i][j] (0≤i<l1, 0≤j<l2, i + j≠0), calculate d[l1 - 1][l2 - 1] using the following formula, which is the similarity between the basic base sequences L1 and L2:
[0025]
[0026] d[i][j]=max(d1, d2, d3)
[0027] In the above formula, d1, d2, and d3 are initialized to 0, and [j]?1:0 corresponds to the ternary operator a?b:c, indicating that if condition a holds, the result of the formula is b, otherwise it is c.
[0028] The technical solution adopted in the embodiment of the present application also includes: encoding the binary data to be encoded into a base sequence of a DNA chain according to the mapping table is specifically:
[0029] The fixed-length binary data is divided into a certain number of segments according to the set byte length, and each segment is converted into a base sequence composed of bases according to the mapping table. After all segments are converted, a suffix automaton is constructed according to all base sequences.
[0030] The technical solution adopted in the embodiment of the present application also includes: encoding the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replacing the taboo sequence in the base sequence with the replacement sequence, specifically:
[0031] Verify whether there is a taboo sequence in the base sequence of the DNA chain according to the suffix automaton. If so, obtain the starting position and length of the taboo sequence, use the basic base sequence in the replacement set to replace the taboo sequence, generate a new sequence after replacement, and record the replacement information in the taboo sequence replacement file. The replacement information includes the replaced taboo sequence ID, replacement length and starting ID; if not, add the index address, VT code and separation sequence to the base sequence of each DNA chain respectively, and output the encoding result of the DNA chain.
[0032] The technical solution adopted in the embodiment of the present application further includes: encoding the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replacing the taboo sequence in the base sequence with the replacement sequence, further including:
[0033] Error correction is performed on the encoded DNA chain according to the VT code;
[0034] An index address in the DNA chain is obtained, a taboo sequence replacement file is read according to the index address, the replaced taboo sequence in the DNA chain is restored according to replacement information in the taboo sequence replacement file, and the DNA chain is decoded into binary data according to a mapping table.
[0035] Another technical solution adopted in the embodiment of the present application is: a DNA data encoding and decoding method and device, comprising:
[0036] Sequence screening module: used to set the initial sequence, add bases to the end of the initial sequence in sequence to generate the basic base sequence of the DNA chain, and use the depth-first search algorithm to screen the basic base sequence to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content, and taboo sequences;
[0037] A sequence selection module is configured to select a first set number of base base sequences from the screened base base sequences as base base sequences used in encoding binary data, construct a mapping table based on the mapping relationship between the first set number of base base sequences and the binary data, and select a second set number of base base sequences as replacement sequences for replacing taboo sequences;
[0038] Sequence encoding module: used to encode the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replace the taboo sequence in the base sequence with the replacement sequence.
[0039] Another technical solution adopted by the embodiment of the present application is: a computer device, the computer device includes a processor and a memory coupled to the processor, wherein:
[0040] The memory stores program instructions for implementing the DNA data encoding and decoding method;
[0041] The processor is used to execute the program instructions stored in the memory to control the DNA data encoding and decoding method.
[0042] Another technical solution adopted in the embodiment of the present application is: a storage medium storing program instructions executable by a processor, wherein the program instructions are used to execute the DNA data encoding and decoding method.
[0043] Compared with the prior art, the beneficial effects produced by the embodiments of the present application are as follows: the DNA data encoding and decoding method, device, computer equipment and storage medium of the embodiments of the present application use a depth-first search algorithm to screen out basic base sequences that meet preset conditions such as homopolymers, GC content, and taboo sequences, select a certain number of basic base sequences from the basic base sequences as basic base sequences used in binary data encoding, and select a certain number of basic base sequences as replacement sequences for replacing taboo sequences; in the encoding process, fixed-length binary data is encoded into a base sequence according to the mapping relationship between the basic base sequence and the binary data, and the taboo sequence therein is replaced with the replacement sequence, the replacement information is recorded in the taboo sequence replacement file, and data such as the index address, VT code and separation sequence are added to the base sequence; in the decoding process, the base sequence is corrected according to the VT code, and the taboo sequence is restored according to the replacement information, and finally the base sequence is restored to binary data according to the mapping relationship between the base sequence and the binary data. The embodiment of the present application can encode arbitrary binary data into a base sequence composed of four bases: A, T, G, and C. The generated base sequence does not contain excessively long homopolymers, has a balanced GC content, and does not contain pre-defined taboo sequences, thereby reducing the probability of self-folding to produce secondary structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flow chart of the DNA data encoding and decoding method according to the first embodiment of the present application;
[0045] Figure 2 is a flow chart of the DNA data encoding and decoding method according to the second embodiment of the present application;
[0046] Figure 3 This is a schematic diagram of the basic base sequence screening process of an embodiment of the present application;
[0047] Figure 4 This is a schematic diagram of the DNA chain decoding process according to an embodiment of the present application;
[0048] Figure 5 This is a schematic diagram of the structure of the DNA data encoding and decoding method device according to an embodiment of the present application;
[0049] Figure 6 This is a schematic diagram of the computer device structure according to an embodiment of the present application;
[0050] Figure 7 A schematic diagram of the structure of the storage medium of an embodiment of the present application. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0052] The terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of such features. In the description of this application, "multiple" means at least two, for example, two, three, etc., unless otherwise specifically defined. All directional indications in the embodiments of this application (such as up, down, left, right, front, back...) are only used to explain the relative positional relationship, movement, etc. between the components under a specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indications also change accordingly. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or computer device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products, or computer devices.
[0053] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0054] For details, please refer to Figure 1 , is a flow chart of the DNA data encoding and decoding method of the first embodiment of the present application. The DNA data encoding and decoding method of the first embodiment of the present application comprises the following steps:
[0055] S100: Setting an initial sequence, sequentially adding bases to the end of the initial sequence to generate a basic base sequence of the DNA chain, and screening the basic base sequence using a depth-first search algorithm to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content, and taboo sequence;
[0056] S110: Selecting a first set number of base base sequences from the screened base base sequences as base base sequences used for encoding binary data, constructing a mapping table based on a mapping relationship between the first set number of base base sequences and the binary data, and selecting a second set number of base base sequences as replacement sequences for replacing taboo sequences;
[0057] S120: Encode the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replace the taboo sequence in the base sequence with the replacement sequence.
[0058] See also Figure 2 , is a flow chart of the DNA data encoding and decoding method according to the second embodiment of the present application. The DNA data encoding and decoding method according to the second embodiment of the present application comprises the following steps:
[0059] S200: Setting an initial sequence S, sequentially adding the four bases A, T, G, and C to the end of the initial sequence S to generate a basic base sequence of the DNA chain, and after each basic base sequence is generated, searching the basic base sequence using a depth-first search algorithm to screen out a set of basic base sequences that meet preset conditions;
[0060] In this step, please also refer to Figure 3 , is a schematic diagram of the basic base sequence screening process of an embodiment of the present application, and the screening process specifically includes the following steps:
[0061] S201: Set an initial sequence S of an empty string;
[0062] S202: Add the four bases A, T, G, and C at the end of the initial sequence S to generate multiple basic base sequences S1, S2, S3...S n , n represents the total number of generated basic base sequences, and after each basic base sequence is generated, the basic base sequence is searched using a depth-first search algorithm to determine whether there is a homopolymer with a length greater than a first preset value in the basic base sequence. If so, execute S203; otherwise, execute S202 again to continue adding bases to the end of the basic base sequence;
[0063] It should be noted that when a homopolymer is located at the beginning or end of the base sequence, the first preset value is half of the first preset value when the homopolymer is not located at the beginning or end of the base sequence, thereby preventing the formation of excessively long homopolymers when splicing two base sequences. In this embodiment of the present application, the first preset value is set to 4, and the specific value can be set according to the actual application scenario.
[0064] S203: Stop searching on the base base sequence and determine whether the length of the base base sequence is equal to a second preset value. If so, execute S204; otherwise, execute S202 again to continue adding bases to the end of the base base sequence.
[0065] Among them, the second preset value is set to 8, that is, to determine whether the length of the basic base sequence is equal to 8. The specific value can be set according to the actual application scenario.
[0066] S204: Determine whether the number of G and C bases in the basic base sequence reaches a third preset value. If so, execute S205; otherwise, execute S202 again to continue adding bases to the end of the basic base sequence.
[0067] In this step, the third preset value is set between 3 and 5 to ensure that the number of bases G and C in the final synthesized DNA chain is within a balanced range.
[0068] S205: Determine whether there is a predefined taboo sequence in the basic base sequence. If yes, execute S206; if not, execute S207;
[0069] S206: Delete the taboo sequence and re-execute S202 to continue adding bases at the end of the basic base sequence;
[0070] S207: Add the basic base sequence to the basic base sequence set.
[0071] Based on the above, the embodiment of the present application uses a depth-first search algorithm to screen the newly generated basic base sequence to obtain a basic base sequence that meets preset conditions such as homopolymers, GC content, and taboo sequences, and adds all basic base sequences that meet the preset conditions to the basic base sequence set, which can ensure that the encoded base sequence does not contain excessively long homopolymers, and the number of bases G and C in the final synthesized DNA chain is within a balanced range and does not contain pre-defined taboo sequences.
[0072] S210: all base sequences in the base sequence set are regarded as nodes, and the similarity between each base sequence is calculated using a reverse complementary DTW (Dynamic time warping) algorithm;
[0073] In this step, assuming that the two base base sequences are L1 and L2, with lengths of l1 and l2 respectively, the steps for calculating the similarity between the base base sequences using the reverse complementary DTW algorithm are as follows:
[0074] S211: Reverse L2 and replace the original base in L2 with its complementary base;
[0075] S212: Set a two-dimensional array d with a size of at least l1×l2 and an initial value of 0;
[0076] S213: Determine whether L1[0] == L2[0] holds. If it holds, then d[0][0] = 1; otherwise, d[0][0] = 0;
[0077] S214: For d[i][j] (0 ≤ i < l1, 0 ≤ j < l2, i + j ≠ 0), calculate d[l1 - 1][l2 - 1] using the following formula, which is the similarity between the basic base sequences L1 and L2:
[0078]
[0079] d[i][j] = max(d1, d2, d3) (1)
[0080] In formula (1), d1, d2, and d3 are initialized to 0, and [j]? 1:0 corresponds to the ternary operator a? b:c, indicating that if the a condition holds, the result of this formula is b; otherwise, it is c.
[0081] S220: Determine whether the similarity between pairwise basic base sequences is greater than the fourth preset value. If so, execute S230;
[0082] S230: Add an edge between the nodes corresponding to the pairwise basic base sequences to obtain a graph composed of the nodes represented by the basic base sequences and the edges connecting them;
[0083] S240: Sort all the nodes in the graph in ascending order according to their degrees, select the top N basic base sequences for encoding the binary data, construct a mapping table based on the mapping relationship between the N basic base sequences and the binary data, and at the same time select the bottom M basic base sequences as the replacement sequences for replacing the taboo sequences, and add the replacement sequences to the replacement set;
[0084] In this step, by using the top N basic base sequences for encoding fixed-length binary data and the bottom M basic base sequences for replacing the taboo sequences, the probability of the DNA folding itself to generate a secondary structure can be reduced to a certain extent. Among them, the specific values of N and M can be set according to the actual application scenario. For example, in the embodiment of this application, the top 32768 basic base sequences are selected for encoding fixed-length binary data, that is, N = 32768.
[0085] S250: Map the fixed-length binary data to be encoded to the base sequence of the DNA strand according to the mapping table between the N basic base sequences and the binary data, and construct a suffix automaton based on the base sequence;
[0086] In this step, the mapping method of binary data specifically includes: first, dividing the fixed-length binary data into a certain number of fragments according to the set byte length; then converting each fragment into a base sequence composed of bases according to the mapping table, and after all fragments are converted, constructing a suffix automaton based on all base sequences. Specifically, assuming that the fixed-length binary data includes 30 bytes, the 30 bytes are divided into 16 fragments of 15 bits each, each fragment can be converted into a base sequence composed of 8 bases, thereby obtaining a base sequence of 128 in length, and then constructing a suffix automaton based on the base sequence. Among them, the suffix automaton contains the relationship between different states, and each state includes len, parent, next, and pos4 variables. In the initialization state, len is 0, parent is -1, next is empty, and pos is 0, where next is a key-value pair structure. In the suffix automaton of the embodiment of the present application, the state is saved in the form of an array as states. In addition, the suffix automaton also includes variables size and last. In the initialization state, size is 0 and last is 0.
[0087] Furthermore, the suffix automaton construction process includes: when a new character c is input to expand the suffix automaton, the size of the suffix automaton is incremented by 1, a new state cur is initialized, the len of state cur is set to the len of the last state plus 1, pos is set to the len of the last state, and state cur is added to the end of the original state set of the suffix automaton; state up is set to be equal to last, when up is not equal to -1 and states[up] cannot transition to other states with the character c, states[up].next[c] is assigned to cur, so that all states along the way can reach state cur through the character c, and update The new up is states[up].parent; when state up is equal to -1, set the parent of state q to the initial state 0, otherwise set q to states[up].next[c]; if states[up].len+1 is equal to states[q].len, set the parent of state cur to point to q, otherwise the size of the suffix automaton is incremented by 1 again, and copy state q to become the new state clone, set the len of state clone to states[up].len+1, and set the parent of states q and cur to clone. When state up is not equal to -1 and state up can point to state q through character c, update next of state up so that state up can point to state clone through character c, and update up to states[up].parent; repeat the above process. If the end of the string has not been reached, set c to the next character of the string and re-extend the suffix automaton. If the end of the string has been reached, end the construction of the suffix automaton and assign last to cur after the execution.
[0088] Furthermore, after the suffix automaton is constructed, it also includes: using the string f to verify the suffix automaton, and the verification process is specifically as follows: the suffix automaton starts from the initial state and checks whether it can jump according to the first character of the string f. If it can jump to the next state, it checks whether it can jump according to the next character of the string f, and so on. If it can successfully jump until the end of the string f, it means that the initial base sequence used to construct the suffix automaton contains f, and the starting index of the string f in the initial base sequence can be determined according to the pos information of the state finally jumped to; on the contrary, if it is impossible to jump according to a character in the string f in the middle, it means that the initial base sequence used to construct the suffix automaton does not contain the string f, indicating that the verification has failed.
[0089] S260: Verify whether there is a taboo sequence in the base sequence of the DNA chain according to the suffix automaton. If yes, execute S270; if no, execute S280;
[0090] S270: Obtain the starting position and length of the taboo sequence, replace the taboo sequence with the base base sequence in the replacement set, generate a new sequence after replacement, and record the replacement information such as the replaced taboo sequence ID, replacement length and starting ID in the taboo sequence replacement file;
[0091] In this step, the taboo sequence replacement file stores each replacement record by line. Each replacement record corresponds to a sequence address, pointing to the DNA chain corresponding to the replacement record, indicating that the content of this replacement record is a replacement of the taboo sequence in the DNA chain. Specifically, the storage format of the taboo sequence replacement file is shown in Table 1 below:
[0092] Table 1 Storage format of taboo sequence replacement file
[0093]
[0094] Among them, the first line is the byte length corresponding to each stored data in the second line. For example, the sequence address 8B represents that the length of the sequence address is 8 bytes. The taboo sequence id represents the id of the taboo sequence replaced in this replacement record. When the data is recovered, the replaced taboo sequence can be found according to the taboo sequence id; the replacement length is the length of the new sequence after the taboo sequence is replaced with the new sequence, and the starting id is the starting position of the replaced taboo sequence in the base sequence. When the data is recovered, the replaced new sequence can be completely restored to the taboo sequence through the taboo sequence id, replacement length and starting id. In addition, since the sequence addresses recorded in the same DNA chain are the same, when multiple replacements occur in the same DNA chain, new replacement information other than the sequence address can be directly added after the delimiter at the end of the same replacement record, and a delimiter can also be added at the end to save storage space.
[0095] S280: adding the index address, VT (Varshamov-Tenengolts) code, and separator sequence data to the base sequence of each DNA chain, and outputting the encoding result of the DNA chain;
[0096] In this step, the data format for a single DNA chain is shown in Table 2 below:
[0097] Table 2 Data format of DNA chain
[0098]
[0099] The first row indicates the byte length corresponding to each stored data in the second row. For example, a sequence address of 8 bp indicates that the length of the base sequence occupied by the sequence address is 8.
[0100] Since the length of the base sequence in a single DNA chain is limited, an index address needs to be added so that the data can be spliced back during decoding. The end of the base sequence representing the index address may be spliced with the beginning of the base sequence representing the encoded data to form a forbidden sequence. In order to prevent the above situation, the embodiment of the present application inserts a separator sequence between the index address and the encoded data as a separator, and inserts a separator sequence after the encoded data and then adds VT code redundancy to ensure the data correctness and integrity of each DNA chain.
[0101] S290: Recovering the encoded DNA chain according to the replacement information in the taboo sequence replacement file, and decoding the encoded DNA chain into binary data;
[0102] In this step, see Figure 4 , is a schematic diagram of the DNA chain decoding process of an embodiment of the present application, which specifically includes the following steps:
[0103] S291: Determine whether the encoded DNA chain is wrong. If so, execute S292; otherwise, execute S293;
[0104] S292: Error correction of DNA strands based on VT code;
[0105] S293: Obtain the index address in the DNA chain, read the taboo sequence replacement file according to the index address, and check whether the taboo sequence of the DNA chain has been replaced during encoding through the taboo sequence replacement file. If yes, execute S294;
[0106] S294: Restoring the replaced taboo sequence in the DNA chain according to the taboo sequence ID, replacement length, and starting ID in the taboo sequence replacement file;
[0107] S295: After all taboo sequences are restored, the index addresses of all DNA chains are arranged and spliced, and the spliced DNA chains are restored to binary data according to the mapping table.
[0108] Based on the above, the DNA data encoding and decoding method of the second embodiment of the present application uses a depth-first search algorithm to screen out basic base sequences that meet preset conditions such as homopolymers, GC content, and taboo sequences, abstracts the basic base sequences into nodes and constructs a graph consisting of nodes represented by base sequences and their connected edges, selects nodes with higher degrees from the graph as the basic base sequences used for binary data encoding, and selects nodes with lower degrees as replacement sequences for replacing taboo sequences; in the encoding process, binary data of fixed length is encoded into a base sequence according to the mapping relationship between the basic base sequence and the binary data, and the taboo sequence therein is replaced with the replacement sequence, the replacement information is recorded in the taboo sequence replacement file, and data such as the index address, VT code, and separation sequence are added to the base sequence; in the decoding process, the base sequence is corrected according to the VT code, and the taboo sequence is restored according to the replacement information, and finally the base sequence is restored to binary data according to the mapping relationship between the base sequence and the binary data. The embodiment of the present application can encode arbitrary binary data into a base sequence composed of four bases: A, T, G, and C. The generated base sequence does not contain excessively long homopolymers, has a balanced GC content, and does not contain pre-defined taboo sequences, thereby reducing the probability of self-folding to produce secondary structures.
[0109] See also Figure 5 , is a schematic diagram of the structure of the DNA data encoding and decoding method device according to an embodiment of the present application. The DNA data encoding and decoding method device 40 according to an embodiment of the present application comprises:
[0110] Sequence screening module 41: used to set an initial sequence, add bases to the end of the initial sequence in sequence to generate a basic base sequence of the DNA chain, and use a depth-first search algorithm to screen the basic base sequence to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content, and taboo sequences;
[0111] Sequence selection module 42: configured to select a first set number of base base sequences from the screened base base sequences as base base sequences used in encoding binary data, construct a mapping table based on the mapping relationship between the first set number of base base sequences and the binary data, and select a second set number of base base sequences as replacement sequences for replacing taboo sequences;
[0112] The sequence encoding module 43 is configured to encode the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replace the taboo sequence in the base sequence with the replacement sequence.
[0113] See also Figure 6 , is a schematic diagram of the computer device structure of an embodiment of the present application. The computer device 50 includes:
[0114] A memory 51 storing executable program instructions;
[0115] a processor 52 connected to the memory 51;
[0116] The processor 52 is used to call the executable program instructions stored in the memory 51 and perform the following steps: setting an initial sequence, adding bases in sequence at the end of the initial sequence to generate a basic base sequence of the DNA chain, and using a depth-first search algorithm to screen the basic base sequence to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content and taboo sequence; selecting a first set number of basic base sequences from the screened basic base sequences as the basic base sequences used for binary data encoding, constructing a mapping table based on the mapping relationship between the first set number of basic base sequences and the binary data, and selecting a second set number of basic base sequences as replacement sequences for replacing taboo sequences; encoding the binary data to be encoded into the base sequence of the DNA chain according to the mapping table, and using the replacement sequence to replace the taboo sequence in the base sequence.
[0117] The processor 52 may also be referred to as a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip having signal processing capabilities. The processor 52 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The general-purpose processor may be a microprocessor or any conventional processor.
[0118] See also Figure 7 , Figure 7Schematic diagram of the structure of the storage medium of the embodiment of the present application. The storage medium of the embodiment of the present application stores a program instruction 61 that can implement the following steps: setting an initial sequence, adding bases at the end of the initial sequence in sequence to generate a basic base sequence of the DNA chain, and using a depth-first search algorithm to screen the basic base sequence to obtain a basic base sequence that meets the preset conditions; the preset conditions include homopolymer length, GC content and taboo sequence; selecting a first set number of basic base sequences from the screened basic base sequence as the basic base sequence used when encoding binary data, constructing a mapping table based on the mapping relationship between the first set number of basic base sequences and binary data, and selecting a second set number of basic base sequences as a replacement sequence for replacing the taboo sequence; encoding the binary data to be encoded into a base sequence of the DNA chain according to the mapping table, and replacing the taboo sequence in the base sequence with the replacement sequence. Wherein, the program instruction 61 can be stored in the above-mentioned storage medium in the form of a software product, including several instructions for causing a computer device (which can be a personal computer, a server, or a network computer device, etc.) or a processor to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage media include: various media that can store program instructions, such as USB flash drives, mobile hard drives, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks, or terminal computer devices such as computers, servers, mobile phones, and tablets. The server can be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0119] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0120] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. The above is only an implementation method of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the content of the description and drawings of this application, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A DNA data encoding and decoding method, characterized in that: include: Setting an initial sequence, sequentially adding bases to the end of the initial sequence to generate a basic base sequence of the DNA chain, and screening the basic base sequence using a depth-first search algorithm to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content, and taboo sequences; selecting a first set number of base base sequences from the screened base base sequences as base base sequences used in encoding binary data, constructing a mapping table based on a mapping relationship between the first set number of base base sequences and the binary data, and selecting a second set number of base base sequences as replacement sequences for replacing taboo sequences; Encoding the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replacing a taboo sequence in the base sequence with the replacement sequence; The base base sequence is screened using a depth-first search algorithm to obtain a base base sequence that meets the preset conditions: Set an initial sequence S of an empty string; Add four bases, A, T, G, and C, to the end of the initial sequence S to generate the basic base sequences S1, S2, S3…S n , n represents the total number of generated basic base sequences, and after each basic base sequence is generated, the basic base sequence is searched using a depth-first search algorithm to determine whether there is a homopolymer with a length greater than a first preset value in the basic base sequence. If so, Stop searching on the basic base sequence and determine whether the length of the basic base sequence is equal to a second preset value. If yes, Determine whether the number of bases G and C in the basic base sequence reaches a third preset value, and if so, Determine whether there is a predefined taboo sequence in the basic base sequence, and if so, delete the taboo sequence; if not, add the basic base sequence to the basic base sequence set.
2. The DNA data encoding and decoding method according to claim 1, characterized in that: The steps of selecting a first set number of base base sequences from the screened base base sequences as base base sequences used in encoding binary data, constructing a mapping table based on a mapping relationship between the first set number of base base sequences and the binary data, and selecting a second set number of base base sequences as replacement sequences for replacing taboo sequences are as follows: All base sequences in the base sequence set are regarded as nodes, and the similarity between each base sequence is calculated using the reverse complementary DTW algorithm; Determine whether the similarity between the two base base sequences is greater than a fourth preset value; if so, add an edge between the nodes corresponding to the two base base sequences to obtain a graph consisting of the nodes represented by the base base sequences and the edges connecting them; All nodes in the graph are sorted in ascending order according to the degree, the top N basic base sequences are selected for encoding binary data, a mapping table is constructed according to the mapping relationship between the N basic base sequences and the binary data, and the bottom M basic base sequences are selected as replacement sequences for replacing the taboo sequences, and the replacement sequences are added to the replacement set.
3. The DNA data encoding and decoding method according to claim 2, characterized in that: Assume that the two base sequences are and , the lengths are and The reverse complementary DTW algorithm is used to calculate the similarity between the base sequences pairwise as follows: Will Reverse and The original base in is replaced by its complementary base; Set up a two-dimensional array d , of size at least , the initial value is 0; judge Is it established? If so, then ,otherwise 0; for , , , calculated using the following formula , which is the basic base sequence and Similarity between: In the above formula, Initialized to 0, L 2 Corresponding to the ternary operator a ? b : c, it means that if condition a is met, the result of the expression is b, otherwise it is c.
4. The DNA data encoding and decoding method according to claim 3, characterized in that: The base sequence of encoding the binary data to be encoded into a DNA chain according to the mapping table is specifically: The fixed-length binary data is divided into a certain number of segments according to the set byte length, and each segment is converted into a base sequence composed of bases according to the mapping table. After all segments are converted, a suffix automaton is constructed according to all base sequences.
5. The DNA data encoding and decoding method according to claim 4, characterized in that: The encoding of the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and the replacement sequence replacing the taboo sequence in the base sequence is specifically as follows: Verify whether there is a taboo sequence in the base sequence of the DNA chain according to the suffix automaton. If so, obtain the starting position and length of the taboo sequence, use the basic base sequence in the replacement set to replace the taboo sequence, generate a new sequence after replacement, and record the replacement information in the taboo sequence replacement file. The replacement information includes the replaced taboo sequence ID, replacement length and starting ID; if not, add the index address, VT code and separation sequence to the base sequence of each DNA chain respectively, and output the encoding result of the DNA chain.
6. The DNA data encoding and decoding method according to claim 5, characterized in that: After encoding the binary data to be encoded into a base sequence of a DNA chain according to the mapping table and replacing the taboo sequence in the base sequence with the replacement sequence, the method further includes: Error correction is performed on the encoded DNA chain according to the VT code; An index address in the DNA chain is obtained, a taboo sequence replacement file is read according to the index address, the replaced taboo sequence in the DNA chain is restored according to replacement information in the taboo sequence replacement file, and the DNA chain is decoded into binary data according to a mapping table.
7. A DNA data encoding and decoding device using the DNA data encoding and decoding method according to claim 1, characterized in that: include: Sequence screening module: used to set the initial sequence, add bases to the end of the initial sequence in sequence to generate the basic base sequence of the DNA chain, and use the depth-first search algorithm to screen the basic base sequence to obtain a basic base sequence that meets preset conditions; the preset conditions include homopolymer length, GC content, and taboo sequences; A sequence selection module is configured to select a first set number of base base sequences from the screened base base sequences as base base sequences used in encoding binary data, construct a mapping table based on the mapping relationship between the first set number of base base sequences and the binary data, and select a second set number of base base sequences as replacement sequences for replacing taboo sequences; Sequence encoding module: used to encode the binary data to be encoded into a base sequence of a DNA chain according to the mapping table, and replace the taboo sequence in the base sequence with the replacement sequence.
8. A computer device, characterized in that: The computer device includes a processor and a memory coupled to the processor, wherein: The memory stores program instructions for implementing the DNA data encoding and decoding method according to any one of claims 1 to 6; The processor is used to execute the program instructions stored in the memory to control the DNA data encoding and decoding method.
9. A storage medium, characterized in that: Program instructions executable by a processor are stored, and the program instructions are used to execute the DNA data encoding and decoding method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data storage method, decoding method, equipment and storage medium
CN115374937A
Evolution-guided multiplexed DNA assembly of DNA parts, pathways and genomes
US20210130809A1