WO2023272499A1 - Encoding method, decoding method, apparatus, terminal device, and readable storage medium - Google Patents

Encoding method, decoding method, apparatus, terminal device, and readable storage medium Download PDF

Info

Publication number
WO2023272499A1
WO2023272499A1 PCT/CN2021/103179 CN2021103179W WO2023272499A1 WO 2023272499 A1 WO2023272499 A1 WO 2023272499A1 CN 2021103179 W CN2021103179 W CN 2021103179W WO 2023272499 A1 WO2023272499 A1 WO 2023272499A1
Authority
WO
WIPO (PCT)
Prior art keywords
base sequence
base
preset
file
sequence
Prior art date
Application number
PCT/CN2021/103179
Other languages
French (fr)
Chinese (zh)
Inventor
戴俊彪
卢明伟
黄小罗
Original Assignee
中国科学院深圳先进技术研究院
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中国科学院深圳先进技术研究院 filed Critical 中国科学院深圳先进技术研究院
Priority to PCT/CN2021/103179 priority Critical patent/WO2023272499A1/en
Publication of WO2023272499A1 publication Critical patent/WO2023272499A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16BBIOINFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR GENETIC OR PROTEIN-RELATED DATA PROCESSING IN COMPUTATIONAL MOLECULAR BIOLOGY
    • G16B50/00ICT programming tools or database systems specially adapted for bioinformatics
    • G16B50/30Data warehousing; Computing architectures

Definitions

  • the present application belongs to the field of storage technology, and in particular relates to an encoding method, a decoding method, a device, a terminal device, and a computer-readable storage medium.
  • DNA deoxyribonucleic acid
  • DNA storage technology the data to be stored needs to be encoded into the base sequence of DNA, and then DNA can be synthesized according to the base sequence to store the data to be stored into the DNA.
  • DNA encoding technology is the key technology in DNA storage.
  • the existing DNA coding technology will increase the probability of errors in the process of DNA synthesis and sequencing, which is not conducive to the wide application of DNA storage technology.
  • One of the purposes of the embodiments of the present application is to provide an encoding method, decoding method, device, terminal equipment, and computer-readable storage medium, which can solve the problem that the existing DNA encoding technology will increase the probability of errors in the process of DNA synthesis and sequencing problems, expanding the scope of application of DNA storage technology.
  • the embodiment of the present application provides an encoding method, including:
  • the data to be encoded is text
  • the obtaining the initial base sequence of the data to be encoded includes:
  • the initial base sequence corresponding to the text is determined according to the coding table.
  • the at least one set of intermediate base sequences is replaced by a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded ,include:
  • the repeated bases are replaced by a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
  • the grouping of the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences includes:
  • the initial base sequences are grouped according to the first number of bases to obtain at least one group of the intermediate base sequences, and the number of bases included in each of the intermediate base sequences is the first number of bases.
  • the method further includes:
  • adding the third number of bases at the preset position of the individual base sequence includes:
  • the individual base sequence is the base sequence at the head of the initial base sequence or the base sequence at the tail of the initial base sequence.
  • the preset position is the head or the end of the single base sequence.
  • At least one set of the intermediate base sequences is replaced by the first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain
  • the encoding file corresponding to the data to be encoded includes:
  • the repeated bases are replaced by a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
  • the preset number of times is 4, and the correspondence between the repeated bases and the second preset base sequence includes at least one of the following:
  • GCATG corresponds to GGGG
  • GCATC corresponds to CCCC
  • GCATA corresponds to AAAA
  • GCATT corresponds to TTTT.
  • the method also includes:
  • the second sequence set corresponding to the first preset base sequence is constructed according to the fourth base number, and the G and C contained in each of the first preset base sequences in the second sequence set The proportion satisfies the preset conditions;
  • the number of the first bases is 5, and the number of the fourth bases is 6.
  • the embodiment of the present application provides a decoding method, including:
  • the file to be decoded is a file encoded based on the encoding method described in any one of the above first aspects;
  • the bases of the files to be decoded whose GC ratio meets the preset conditions can be accurately restored to obtain the initial base sequence corresponding to the file to be decoded, and by decoding the initial base sequence, you can get The decoding data corresponding to the file to be decoded can effectively improve decoding efficiency and correctness.
  • the base reduction of the file to be decoded is performed to obtain the initial base sequence corresponding to the file to be decoded, including:
  • the embodiment of the present application provides an encoding device, including:
  • the initial sequence acquisition module is used to obtain the initial base sequence of the data to be encoded
  • a sequence grouping module configured to group the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences
  • An encoding module configured to replace at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded,
  • the ratio of G and C contained in the first preset base sequence satisfies a preset condition.
  • the embodiment of the present application provides a decoding device, including:
  • a file acquisition module configured to acquire a file to be decoded, where the file to be decoded is a file encoded based on the encoding method described in any one of the above first aspects;
  • a base restoration module configured to perform base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded
  • a decoding module configured to decode the initial base sequence to obtain decoded data corresponding to the file to be decoded.
  • the embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and operable on the processor, when the processor executes the computer program Realize the above-mentioned first aspect, or the method described in any one of the second aspect.
  • the embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned first aspect or the second aspect are implemented. any one of the methods described.
  • an embodiment of the present application provides a computer program product, which, when the computer program product is run on a terminal device, enables the terminal device to execute the method described in any one of the first aspect or the second aspect.
  • the beneficial effect of the encoding method provided by the embodiment of the present application is that: through the above-mentioned encoding method, the initial base sequence of the data to be encoded can be obtained, and the initial base sequence can be grouped to obtain an intermediate base sequence. Then, the intermediate base sequence can be replaced with the first preset base sequence whose GC ratio meets the preset conditions, so that the GC ratio contained in the obtained encoding file meets the requirements, reducing the cost of DNA sequence synthesis and sequencing And the probability of error, reduce the cost of DNA storage, and expand the application scale of DNA storage.
  • FIG. 1 is a schematic flow chart of an encoding method provided in Embodiment 1 of the present application;
  • FIG. 2 is a schematic diagram of a scene for constructing a four-fork Huffman tree provided by Embodiment 1 of the present application;
  • Fig. 3 is a schematic diagram of the application scenario of adding bases provided in Embodiment 1 of the present application;
  • FIG. 4 is a schematic diagram of a scene of an encoding method provided in Embodiment 1 of the present application.
  • FIG. 5 to FIG. 7 are schematic diagrams showing the effect of the encoding method provided in Embodiment 1 of the present application.
  • FIG. 8 is a schematic flowchart of a decoding method provided in Embodiment 2 of the present application.
  • FIG. 9 is a schematic diagram of a scene of a decoding method provided in Embodiment 2 of the present application.
  • FIG. 10 is a schematic structural diagram of an encoding device provided in Embodiment 3 of the present application.
  • FIG. 11 is a schematic structural diagram of a decoding device provided in Embodiment 4 of the present application.
  • FIG. 12 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
  • the term “if” may be construed, depending on the context, as “when” or “once” or “in response to determining” or “in response to detecting “.
  • the phrase “if determined” or “if [the described condition or event] is detected” may be construed, depending on the context, to mean “once determined” or “in response to the determination” or “once detected [the described condition or event] ]” or “in response to detection of [described condition or event]”.
  • references to "one embodiment” or “some embodiments” or the like in the specification of the present application means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application.
  • appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in other embodiments,” etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless specifically stated otherwise.
  • the terms “including”, “comprising”, “having” and variations thereof mean “including but not limited to”, unless specifically stated otherwise.
  • DNA has the characteristics of high storage density, long storage time, and low loss rate. It can be used for mass storage of information and has gradually attracted widespread attention from researchers. Among them, DNA has four bases, namely Guanine (Guanine, G), Cytosine (Cytosine, C), Adenine (Adenine, A) and Thymine (Thymine, T).
  • Guanine Guanine
  • Cytosine Cytosine
  • Adenine Adenine
  • Thymine Thymine
  • DNA encoding technology is the key technology in DNA storage.
  • the existing DNA coding technology has the problems of low coding efficiency or uneven GC ratio in the encoded base sequence and multi-base repetition, which increases the cost of DNA sequence synthesis and sequencing and the probability of errors, which is not conducive to DNA Large-scale application of storage technology.
  • sequencing is a necessary operation before decoding the encoded encoded file, and is used to measure the DNA base sequence corresponding to the encoded file. After the base sequence is obtained, the base sequence is decoded according to the decoding rules.
  • the embodiment of the present application provides an encoding method for encoding data into base sequences in DNA, so as to use DNA for data storage.
  • the initial base sequence can be grouped to obtain at least one group of intermediate base sequences corresponding to the initial base sequence, and the proportions of G and C are used to satisfy the preset
  • the first preset base sequence of the condition replaces each intermediate base sequence to obtain an encoding file corresponding to the data to be encoded.
  • the encoding method provided by the embodiment of the present application can make the proportion of GC in the encoding file meet the requirements, reduce the cost of DNA sequence synthesis and sequencing and the probability of errors, reduce the cost of DNA storage, and expand the application scale of DNA storage. ease of use and practicality.
  • the encoding method and decoding method provided in the embodiments of the present application can be applied to mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) devices, notebook computers, super mobile On terminal devices such as personal computers (ultra-mobile personal computer, UMPC), netbooks, and personal digital assistants (personal digital assistants, PDAs), the embodiments of the present application do not impose any restrictions on the specific types of terminal devices.
  • FIG. 1 shows a schematic flowchart of an encoding method provided in Embodiment 1 of the present application. As shown in Figure 1, the method may include:
  • the terminal device acquires the initial base sequence of the data to be encoded.
  • the data to be encoded may be data in any format, such as text, numbers, and so on.
  • the terminal device can encode the data to be encoded in any format according to any existing encoding method to obtain the initial base sequence of the data to be encoded, which is not specifically limited in the embodiment of the present application.
  • the terminal device can treat the encoded data through the four-fork Huffman encoding (that is, the four-ary Huffman encoding) method Encoding is performed to obtain the initial base sequence.
  • the four-fork Huffman encoding that is, the four-ary Huffman encoding
  • Encoding is performed to obtain the initial base sequence.
  • the following will take the quadrangle Huffman coding as an example for illustration.
  • the terminal device may first perform word segmentation processing on the text to obtain each character corresponding to the text. Then, the terminal device counts the number of occurrences of each character in the text, so that the frequency of occurrence of each character can be determined according to the number of occurrences of each character and the total number of characters in the text, and each character is used as a leaf node. For the weight of the leaf node, construct a quadruple Huffman tree corresponding to the text. Subsequently, the terminal device can represent each edge of the quadruplet Huffman tree with bases to obtain a coding table corresponding to the text, so that the initial base sequence of the text can be determined according to the coding table.
  • the terminal device can select the four leaf nodes with the smallest weights to construct the first-level quadrangle Huffman subtree, and the weight of the root node of the quadrature Huffman subtree is the weight of the four leaf nodes The sum of the weights of .
  • the terminal device determines the root node of the quadruplet Huffman subtree as a new leaf node, and continues from all unselected leaf nodes (including the root node of the quadruplet Huffman subtree of the first layer) Select the four leaf nodes with the smallest weight to build the second layer of quadruplet Huffman subtree, the weight of the root node of the quadrangle Huffman subtree is the sum of the weights of these four leaf nodes, as By analogy, until it is no longer possible to construct a four-fork Huffman subtree, to obtain a four-fork Huffman tree corresponding to the text.
  • the number n of root nodes in the four-fork Huffman tree corresponding to the text can be determined according to the quotient of the total number of characters w1 and 3 corresponding to the text.
  • n is the quotient obtained by dividing the total number of characters w1 by 3, for example, when the total number of characters w1 is 12, n is 4; when the total number of characters w1 is not an integer of 3
  • n is the quotient obtained by dividing the total number of characters w1 by 3 plus 1, for example, when the total number of characters w1 is 8, n is 3.
  • the terminal device can add one or two leaf nodes with a weight of 0 to construct a quadrangle Huffman tree.
  • the terminal device can set bases for each side of the constructed quadrature Huffman tree respectively. Specifically, for each quadruple Huffman subtree, the terminal device can set the four sides of the quadruple Huffman subtree as "G", "C", "A” in order from left to right ", "T”. Then, the terminal device can determine the combination of all bases on the path from the root node of the quadruplet Huffman tree to the leaf node corresponding to each character as the base corresponding to the character in order from left to right, and obtain the text The corresponding coding table, so that the initial base sequence of the text can be determined according to the coding table.
  • FIG. 2 shows a schematic diagram of an application scenario for constructing a quad-fork Huffman tree provided by Embodiment 1 of the present application.
  • the text "Biology and Synthetic Biology” is taken as an example to illustrate the construction of a quadruple Huffman tree.
  • the terminal device can first perform word segmentation processing on the text to obtain the characters " ⁇ ", “ ⁇ ”, “ ⁇ ”, “ ⁇ ”, “ ⁇ ” and “ ⁇ ”, and can be based on the occurrence of each character in the text
  • the number of times and the total number of characters determine the frequency of occurrence of each character, and the frequency of occurrence of " ⁇ ” is 0.25, the frequency of "thing” is 0.25, the frequency of "and” is 0.125, and the frequency of "combination” is 0.125.
  • the frequency of occurrence of "cheng” is 0.125, and the frequency of "learning” is 0.125.
  • the terminal device uses each character as a leaf node, and uses the frequency of occurrence of each character as the weight of the leaf node to construct a quadruplet Huffman tree.
  • the terminal device can determine the leaf nodes to be added according to w2 and w1 The number is 1.
  • the terminal device can add a leaf node with a weight of 0 to construct a quadruple Huffman tree as shown in FIG. 2 .
  • the numbers 1, 0.25, 0, etc. in Figure 2 represent the weight of the node.
  • the terminal device can set the four sides of all four-fork Huffman subtrees as "G", “C”, “A”, and “T” in order from left to right, and according to the four-fork Huffman
  • the combination of all bases on the path from the root node of the Mann tree (the node where "1" is located in Figure 2) to the leaf node corresponding to each character is determined as the base corresponding to the character, and the following table 1 is obtained code table.
  • the terminal device can determine that the initial base sequence of "Biology and Synthetic Biology" is CATCTATTCAG.
  • the terminal device groups the initial base sequences to obtain at least one group of intermediate base sequences corresponding to the initial base sequences.
  • the terminal device may group the initial base sequences according to the first number of bases to obtain at least one group of intermediate base sequences, that is, each intermediate base sequence may include bases of the first number of bases.
  • the first number of bases can be any value greater than or equal to 5.
  • the first number of bases in order to make the final encoding file have a shorter base sequence and improve encoding efficiency, can be determined as 5.
  • the terminal device replaces at least one set of intermediate base sequences with the first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded, the first preset base sequence
  • the ratio of G and C contained in satisfies the preset condition.
  • the terminal device may first determine the first preset base sequence corresponding to each intermediate base sequence according to the first preset correspondence relationship, and replace the corresponding intermediate base sequence with each first preset base sequence, The target base sequence is obtained, and the target base sequence includes each intermediate base sequence after replacement. Then, the terminal device can obtain the repeated bases whose consecutive occurrences are equal to the preset number of times in the target base sequence, and can obtain the second preset base sequence corresponding to the repeated bases according to the second preset correspondence relationship, so as to utilize the second The preset base sequence will repeat the base replacement to obtain the encoding file corresponding to the data to be encoded.
  • the second preset correspondence between repeated bases and the second preset base sequence includes at least one of the following: GCATG corresponds to GGGG; GCATC corresponds to CCCC; GCATA corresponds to AAAA; GCATT corresponds to TTTT. It should be understood that the second preset correspondence relationship may be stored in the terminal device, or may be stored in other devices such as a cloud server communicatively connected with the terminal device.
  • the first preset correspondence can be stored in the terminal device, or can be stored in other devices such as a cloud server communicatively connected with the terminal device, and the first preset correspondence can be pre-established by the terminal device, or can be created by the cloud
  • the server and other devices are pre-established, which is not specifically limited in this embodiment of the present application. The following will take an example in which the first preset correspondence is pre-established by the terminal device as an example for illustration.
  • the terminal device may construct the first sequence set corresponding to the intermediate base sequence according to the first base number corresponding to the intermediate base sequence.
  • the terminal device may determine a fourth base number corresponding to the first preset base sequence according to the first base number.
  • the fourth base number can be any value.
  • the number of fourth bases can be determined as 6.
  • the fourth base number is 6 as an example for illustration.
  • the terminal device can construct a third sequence set containing the first preset base sequence according to the fourth base number, wherein the ratio of G and C contained in each base sequence in the third sequence set satisfies the preset set conditions.
  • the preset condition may be that the proportion of GC is 50%, that is, the total number of G and C contained in each base sequence in the third sequence set is half of the number of the fourth base (ie 3).
  • the third sequence set may include ⁇ GGGAAA, GGGAAT, GGGATA, GGGATT, GGGTAA, GGGTAT, GGGTTA, GGGTTT, GGCAAA, GGCAAT, ... ⁇ have a total of 1280 base sequences.
  • the terminal device can delete GCATxx, xGCATx, xxGCAT, xxxGCA, xxxxGC and CATxxx in the third sequence set to ensure that the second The second preset base sequences GCATG, GCATC, GCATA and GCATT for replacing repeated bases will not appear in the sequence set.
  • x is an arbitrary base, and x described below is an arbitrary base.
  • the terminal device can also delete GGGxxx, CCCxxx, AAAxxx in the third sequence set , TTTxxx, xxxGGG, xxxCCC, xxxAAA, xxxTTT, xGGGAA, and xGGGTT to reduce the probability of four base repeats in the target base sequence, thereby reducing the length of the base sequence corresponding to the encoding file.
  • the terminal device can select 1024 base sequences from the 1091 base sequences as the first preset base sequence to obtain Second set of sequences ⁇ GGCAAT, GGCTAA, GGCTAT, GGCTTA, GGAGAA, GGAGAT, GGAGTA, GGAGTT, GGACAA, GGACAT, ... ⁇ . Then, the terminal device can regard the first sequence set and the second sequence set as a 1x1024-dimensional matrix respectively, and combine the two matrices into a 2x1024-dimensional matrix M:
  • the terminal device can correspond (1, a) in the matrix M to (2, a) in the matrix M, so as to establish the relationship between each intermediate base sequence in the first sequence set and the second sequence set Correspondence between each first preset base sequence.
  • a is any column in the matrix M. That is to say, when the intermediate base sequence is GGGGG in (1,1), the first predetermined base sequence corresponding to the intermediate base sequence is GGCAAT in (2,1). When the intermediate base sequence is GGGCG in (1,5), the first predetermined base sequence corresponding to the intermediate base sequence is GGAGAA in (2,5).
  • the terminal device after using the first preset base sequence to replace the corresponding intermediate base sequence to obtain the target base sequence, when the target base sequence does not contain the above-mentioned repeated bases, the terminal device does not need to use the second The preset relationship is used to replace repeated bases, and the target base sequence is directly determined as the encoding file corresponding to the data to be encoded.
  • the terminal device when the number of bases corresponding to the initial base sequence is not an integer multiple of the first base number, when the terminal device groups the initial base sequences to obtain at least one set of intermediate base sequences, it also A single base sequence can be obtained, and the number of second bases corresponding to the single base sequence is less than the number of first bases, that is, the single base sequence can contain 1 base, 2 bases, 3 bases or 4 bases base. Therefore, after the intermediate base sequence is replaced according to the first preset correspondence, the terminal device can combine the replaced intermediate base sequence with the individual base sequence to obtain the target base sequence. It should be understood that the terminal device can combine the intermediate base sequence and the individual base sequence according to the positional relationship between the two in the initial base sequence.
  • the terminal device can obtain the repeated bases whose consecutive occurrences are equal to the preset number of times in the target base sequence, and can obtain the second preset base sequence corresponding to the repeated bases according to the second preset correspondence relationship, so as to utilize the second The preset base sequence replaces the repeated bases to obtain the encoding file corresponding to the data to be encoded.
  • the terminal device can determine the number of third bases to be added according to the number of first bases and the number of second bases corresponding to the individual base sequence, and can Assume that the position is added according to the order of GCAT to add the base of the third base number, and the individual base sequence after the base addition and the intermediate base sequence after the replacement are merged to obtain the target base sequence, and the added
  • the base is used as the recognition sequence, so that during the decoding process, the terminal device can accurately identify the individual base sequence according to the recognition sequence, thereby accurately obtaining the decoded file and improving the correctness of decoding.
  • the terminal device can add “G”, “C”, “A”, and “T” in sequence from left to right in the preset position of the individual base sequence.
  • the terminal device can add “G”, “C”, and “A” in sequence from left to right in the preset position of the individual base sequence.
  • the terminal device can add "G” and "C” in sequence from left to right in the preset position of the individual base sequence.
  • the terminal device can add "G” at the preset position of the individual base sequence, and so on.
  • the individual base sequence can be the base sequence at any position in the initial base sequence, for example, it can be the base sequence at the head of the initial base sequence, or it can be the base sequence at the tail of the initial base sequence sequence, or it can be the base sequence at any position in the middle of the initial base sequence.
  • the preset position for adding bases may be the head or the end of a single base sequence.
  • FIG. 3 shows a schematic diagram of an application scenario for adding bases provided in Embodiment 1 of the present application.
  • the individual base sequence can be the base sequence at the head of the initial base sequence, and the terminal device can add bases with the third number of bases at the head of the individual base sequence; or, As shown in (b) in FIG. 3 , the individual base sequence may be the base sequence at the end of the initial base sequence, and the terminal device may add a third number of bases at the end of the individual base sequence.
  • the terminal device can mark the position of the individual base sequence in the initial base sequence and the preset position of the added base in the individual base sequence. , the terminal device can identify the individual base sequence according to the mark.
  • the terminal device may not set a flag, but directly set the individual base sequence as the end of the initial base sequence by default base sequence, and directly set the preset position of the added base in the separate base sequence as the end of the separate base sequence by default.
  • the number of the first base is 5
  • the number of the fourth base is 6
  • the single base sequence defaults to the base sequence at the end of the initial base sequence
  • the preset position defaults to the end of the single base sequence sexual description.
  • FIG. 4 shows a schematic diagram of an application scenario of the encoding method provided in Embodiment 1 of the present application.
  • the terminal device when determining that the initial base sequence of the data to be encoded is CCTCTATCCAG, the terminal device can base on the second number of bases corresponding to the initial base sequence (i.e. 11) and the preset first number of bases (i.e. 5) Grouping the initial base sequences to obtain two intermediate base sequences (ie CCTCT and ATCCA) and an individual base sequence, wherein the individual base sequence includes a base G. Then, the terminal device can add four bases "G", "C", "A”, and "T” to the end of the individual base sequence to obtain GGCAT.
  • the terminal device can base on the second number of bases corresponding to the initial base sequence (i.e. 11) and the preset first number of bases (i.e. 5) Grouping the initial base sequences to obtain two intermediate base sequences (ie CCTCT and ATCCA) and an individual base sequence, wherein the
  • the terminal device can use the first preset base sequence corresponding to each intermediate base sequence to replace each intermediate base sequence, for example, use the first preset base sequence CCTGAA corresponding to the intermediate base sequence CCTCT to replace the intermediate base sequence base sequence CCTCT, using the first preset base sequence AACGTC corresponding to the intermediate base sequence ATCCA to replace the intermediate base sequence ATCCA, and merging the replaced base sequence CCTGAAAACGTC and GGCAT to obtain the target base sequence CCTGAAAACGTCGGCAT.
  • the terminal device can obtain the repeated base AAAA in the target base sequence CCTGAAAACGTCGGCAT, and use the second preset base sequence GCATA corresponding to the repeated base AAAA to replace the repeated base AAAA to obtain the encoding file corresponding to the data to be encoded CCTGGCATACGTCGGCAT.
  • FIG. 5 to FIG. 7 show schematic diagrams of effects of the encoding method provided by Embodiment 1 of the present application.
  • the encoded file obtained by encoding the full-text text of "San Zi Jing" using the three-pronged Huffman encoding (i.e., ternary Huffman encoding) method there are more
  • the GC ratio of the sequence is lower than 0.45 or higher than 0.55.
  • the encoding method provided in Embodiment 1 of the present application can make the GC ratios in the encoded files more uniform.
  • the maximum number of repeated bases in the base sequence is 3.
  • the encoding method provided in Example 1 of the present application is more conducive to reducing the difficulty of synthesizing long DNA fragment sequences, thereby effectively reducing the probability of errors during DNA synthesis and sequencing, and expanding the application range of DNA storage technology.
  • the base sequence in the encoding file obtained by encoding using the encoding method proposed in Example 1 of the present application is 9793bp, while the length of the base sequence in the encoding file obtained by using the three-pronged Huffman encoding is 10128bp, That is, the length of the base sequence obtained by the encoding method provided in Example 1 of the present application is shorter, which is more conducive to reducing the cost of DNA storage information.
  • the initial base sequence after obtaining the initial base sequence of the data to be encoded, the initial base sequence can be grouped to obtain at least one group of intermediate base sequences corresponding to the initial base sequence, and the proportions of G and C can be used to The first preset base sequence that meets the preset conditions replaces the intermediate base sequence to obtain an encoding file corresponding to the data to be encoded. That is, the encoding method provided in this embodiment can make the GC ratio in the encoding file meet the requirements, reduce the cost of DNA sequence synthesis and sequencing and the probability of errors, expand the application scale of DNA storage, and have strong usability and practicality sex.
  • FIG. 8 shows a schematic flowchart of a decoding method provided in Embodiment 2 of the present application. As shown in FIG. 8, the method may include:
  • the terminal device acquires a file to be decoded, where the file to be decoded is a file encoded based on the encoding method described in Embodiment 1 above.
  • the terminal device performs base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded.
  • the terminal device decodes the initial base sequence to obtain decoded data corresponding to the file to be decoded.
  • the terminal device can first obtain the second preset base sequence in the file to be decoded, and use the repeated bases corresponding to the second preset base sequence to replace the second preset base sequence to obtain the file to be decoded Corresponding target base sequence. Then, the terminal device can obtain the first preset base sequence in the target base sequence, and use the intermediate base sequence corresponding to the first preset base sequence to replace the first preset base sequence to obtain the file to be decoded Corresponding initial base sequence. Subsequently, the terminal device can decode the initial base sequence to obtain the decoded data corresponding to the file to be decoded.
  • the decoding method for the terminal device to decode the initial base sequence corresponds to the encoding method for encoding the data to be encoded to obtain the initial base sequence in Embodiment 1.
  • the terminal device may encode the text by using quad-fork Huffman encoding to obtain an encoding table corresponding to the text. Then, the terminal device can determine the initial base sequence of the text according to the coding table. Therefore, when decoding, the terminal device can decode the initial base sequence according to the encoding table to obtain the corresponding decoded data (that is, the text).
  • the following will take four-fork Huffman coding as an example for illustration.
  • the correspondence between repeated bases and the second preset base sequence may include GCATG corresponding to GGGG; GCATC corresponding to CCCC; GCATA corresponding to AAAA; GCATT corresponding to TTTT. That is, the terminal device can look for "GCATT" in the file to be decoded and replace it with "TTTT”, look for "GCATA” and replace it with “AAAA”, look for "GCATC” and replace it with "CCCC”, and look for " GCATG” and replace it with "GGGG” to get the target base sequence corresponding to the file to be decoded.
  • the specific content of the corresponding relationship between the first preset base sequence and the intermediate base sequence can refer to the description in the first embodiment above, and will not be repeated here.
  • the terminal device when grouping the initial base sequence, if there is a separate base sequence, the terminal device can add the first identification and the second identification corresponding to the encoding file, the first identification is used to identify the individual base The position of the base sequence in the initial base sequence, and the second mark is used to identify the preset position of the added base in the separate base sequence.
  • the terminal device can split the individual base sequence (including the added base) from the target base sequence according to the first identification and the second identification corresponding to the file to be decoded, and delete the individual base sequence.
  • a base added to a base sequence For the remaining base sequences in the target base sequence (that is, base sequences other than the individual base sequences), the terminal device can obtain the first preset base sequence, and use the intermediate base corresponding to the first preset base sequence The base sequence replaces the first preset base sequence, and merges the base sequence obtained by base replacement with the single base sequence after base deletion to obtain the initial base sequence corresponding to the file to be encoded.
  • the terminal device can decode the initial base sequence according to the encoding table corresponding to the four-fork Huffman encoding, and obtain the decoded data corresponding to the file to be decoded.
  • the terminal device may first split the individual base sequence (including the added bases) from the file to be decoded according to the first identifier and the second identifier, and delete the added bases in the individual base sequence. Then, for the remaining base sequences in the file to be decoded (i.e. base sequences other than the individual base sequences), the terminal device can obtain the second preset base sequence in the remaining base sequences, and use the The repeated bases corresponding to the preset base sequence are replaced by the second preset base sequence to obtain the target base sequence corresponding to the file to be decoded.
  • the terminal device obtains the first preset base sequence in the target base sequence, replaces the first preset base sequence with the intermediate base sequence corresponding to the first preset base sequence, and performs base replacement to obtain The base sequence is merged with the single base sequence after base deletion to obtain the initial base sequence corresponding to the file to be encoded. Subsequently, the terminal device can decode the initial base sequence according to the encoding table corresponding to the four-fork Huffman encoding, and obtain the decoded data corresponding to the file to be decoded.
  • the terminal device can default the individual base sequence as the base sequence at the end of the initial base sequence, and place the added base at the preset position of the individual base sequence The default is the end of the individual base sequence, so as to facilitate the accurate identification of the individual base sequence during decoding without introducing an identifier, so as to ensure correct decoding data. Therefore, after obtaining the target base sequence, the terminal device can obtain the number of bases corresponding to the target base sequence.
  • the terminal device can directly use the intermediate base sequence corresponding to each first preset base sequence to perform base reduction on the first preset base sequence , that is, restore every 6 bases to the original 5 bases, and obtain the initial base sequence corresponding to the file to be decoded.
  • the sequence in which the terminal device performs base reduction is the same as the sequence in which the terminal device performs base replacement in Embodiment 1.
  • the terminal device when in Embodiment 1, the terminal device performs base replacement in order from left to right, in this embodiment, the terminal device will perform base restoration in order from left to right. The following will take restoration from left to right as an example for illustration.
  • the terminal device can split the last 5 base sequences in the target base sequence, and can base the split base sequence Deleted to obtain a single base sequence.
  • the terminal device can use the intermediate base sequence corresponding to each first preset base sequence to perform base reduction on the first preset base sequence, that is, restore every 6 bases to the original 5 bases .
  • the terminal device can combine the individual base sequence with the base sequence obtained by base reduction, that is, add the individual base sequence to the end of the base sequence obtained by base reduction to obtain the initial base corresponding to the file to be decoded sequence.
  • the terminal device can perform base addition at the end of the individual base sequence in the order of "GCAT".
  • the terminal device can determine that G is the added base, that is, it can determine that the individual base sequence is xxxx.
  • the terminal device can determine that G and C are the added bases, that is, the individual base sequence can be determined as xxx.
  • the terminal device can determine that G, C and A are the added bases, that is, it can determine that the individual base sequence is xx.
  • the terminal device can determine that G, C, A and T are the added bases, that is, the individual base sequence can be determined as x.
  • FIG. 9 shows a schematic diagram of an application scenario of the decoding method provided in this embodiment.
  • the terminal device can determine that there is no four-base repeat problem in the file to be decoded , at this point the terminal device can directly determine the file to be decoded as the target base sequence. Since the number of bases corresponding to the target base sequence is not a multiple of 6, the terminal device can determine that there is a separate base sequence in the target base sequence.
  • the terminal device can split the target base sequence to obtain separate The base sequence GGCAT and the first preset base sequences CACTTG and AACCAC. Subsequently, the terminal device can use the intermediate base sequence CATCT corresponding to the first preset base sequence CACTTG to replace the first preset base sequence CACTTG, and the intermediate base sequence AATTCA corresponding to the first preset base sequence AACCAC to replace The first preset base sequence AACCAC, at the same time, the terminal device can delete the added base GCAT in the single base sequence GGCAT.
  • the terminal device can combine the first preset base sequence after base substitution and the individual base sequence after base deletion to obtain the initial base sequence CATCTATTCAG, and according to Table 1 in the foregoing embodiment one Decode the initial base sequence using the coding table shown, and obtain the decoded data "Biology and Synthetic Biology" corresponding to the file to be decoded.
  • the terminal device may not add bases to the individual base sequence, but directly default the individual base sequence as the base sequence at the end of the initial base sequence.
  • the terminal device can obtain the remainder of the number of bases corresponding to the target base sequence and 6, and split it from the end of the target base sequence The base sequence of the remainder is used as a single base sequence.
  • the terminal device can use the intermediate base sequence corresponding to each first preset base sequence to restore the first preset base sequence, that is, the base after splitting the individual base sequence from the target base sequence Every 6 bases in the base sequence are restored to the original 5 bases. Then, the terminal device can combine the individual base sequence with the base sequence obtained through base reduction to obtain the initial base sequence corresponding to the file to be decoded.
  • the terminal device can perform base restoration on the file to be decoded according to the preset corresponding relationship, and obtain the initial base sequence corresponding to the file to be decoded. Then, the initial base sequence can be decoded according to the coding table constructed in advance to obtain the decoding data corresponding to the file to be decoded, so as to improve decoding efficiency and correctness.
  • Fig. 10 shows a structural block diagram of the encoding device provided by the third embodiment of the present application. part.
  • the encoding device may include:
  • a sequence grouping module 1002 configured to group the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences;
  • An encoding module 1003 configured to replace at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded , the ratio of G and C contained in the first preset base sequence satisfies a preset condition.
  • the data to be encoded is text
  • the initial sequence acquisition module 1001 may include:
  • a frequency statistics unit configured to count the frequency of occurrence of each character in the text
  • a Huffman tree construction unit configured to use each of the characters as a leaf node, and use the frequency of occurrence of each of the characters as the weight of the leaf node to construct a quadruplet Huffman tree corresponding to the text;
  • An encoding table acquisition unit configured to represent each edge of the quadrupled Huffman tree with a base to obtain an encoding table corresponding to the text;
  • the initial sequence determination unit is configured to determine the initial base sequence corresponding to the text according to the coding table.
  • the encoding module 1003 may include:
  • the first replacement unit is used to replace at least one set of the intermediate base sequences with a first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain the target base sequence;
  • the first repeated base obtaining unit is used to obtain repeated bases whose consecutive occurrences are equal to the preset number of times in the target base sequence;
  • the second replacement unit is configured to replace the repeated bases with a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
  • sequence grouping module 1002 is specifically configured to group the initial base sequences according to the first number of bases to obtain at least one set of intermediate base sequences, and the bases included in each intermediate base sequence
  • the number of bases is the first number of bases.
  • the device may further include:
  • An individual sequence acquisition module configured to acquire an individual base sequence in the initial base sequence, wherein, after grouping the initial base sequence, the number of bases obtained is less than that of the first base sequence A base sequence of one base number;
  • a base adding module configured to determine the number of third bases to be added according to the number of first bases and the number of second bases corresponding to the separate base sequence, and Positions add the third number of bases.
  • the base addition module is further configured to add bases of the third base number at preset positions of the individual base sequence according to the order of GCAT.
  • the individual base sequence is the base sequence at the head of the initial base sequence or the base sequence at the tail of the initial base sequence.
  • the preset position is the head or the end of the single base sequence.
  • the encoding module 1003 may further include:
  • the third replacement unit is used to replace at least one set of the intermediate base sequences with the first preset base sequence corresponding to at least one set of the intermediate base sequences, and replace the replaced intermediate base sequences Merge with a separate base sequence to obtain the target base sequence;
  • the second repetitive base obtaining unit is used to obtain repeated bases whose consecutive occurrence times are equal to a preset number of times in the target base sequence;
  • the fourth replacement unit is configured to replace the repeated bases with a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
  • the preset number of times is 4 times
  • the correspondence between the repeated base and the second preset base sequence includes at least one of the following:
  • GCATG corresponds to GGGG
  • GCATC corresponds to CCCC
  • GCATA corresponds to AAAA
  • GCATT corresponds to TTTT.
  • the device may also include:
  • a first set construction module configured to construct a first sequence set corresponding to the intermediate base sequence according to the number of first bases corresponding to the intermediate base sequence
  • a base number determination module configured to determine a fourth base number corresponding to the first preset base sequence according to the first base number
  • a second set construction module configured to construct a second sequence set corresponding to the first preset base sequence according to the fourth base number, each of the first preset bases in the second sequence set The ratio of G and C included in the sequence meets the preset condition;
  • a correspondence relationship establishment module configured to establish a correspondence relationship between each of the intermediate base sequences in the first sequence set and each of the first preset base sequences in the second sequence set.
  • the number of the first bases is 5, and the number of the fourth bases is 6.
  • FIG. 11 shows a structural block diagram of the decoding device provided in Embodiment 4 of the present application.
  • FIG. 11 shows a structural block diagram of the decoding device provided in Embodiment 4 of the present application.
  • the components related to Embodiment 4 of the present application are shown in FIG. 11 . part.
  • the decoding device may include:
  • a base restoration module 1102 configured to perform base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded;
  • the decoding module 1103 is configured to decode the initial base sequence to obtain decoded data corresponding to the file to be decoded.
  • the base reduction module 1102 may include:
  • a first base determination unit configured to obtain a second preset base sequence in the file to be decoded
  • a first reduction unit configured to replace the second preset base sequence with repeated bases corresponding to the second preset base sequence, to obtain a target base sequence corresponding to the file to be decoded
  • a sequence obtaining unit configured to obtain a first preset base sequence in the target base sequence
  • the second restoring unit is configured to use an intermediate base sequence corresponding to the first preset base sequence to replace the first preset base sequence to obtain an initial base sequence corresponding to the file to be decoded.
  • FIG. 12 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
  • the terminal device 12 of this embodiment includes: at least one processor 1200 (only one is shown in FIG. 12 ), a memory 1201 and stored in the memory 1201 and can be used in the at least one processor 1200
  • the terminal device 12 may be a computing device such as a desktop computer, a notebook, or a palmtop computer.
  • the terminal device may include, but not limited to, a processor 1200 and a memory 1201.
  • FIG. 12 is only an example of the terminal device 12, and does not constitute a limitation on the terminal device 12. It may include more or less components than those shown in the figure, or combine certain components, or different components. , for example, may also include input and output devices, network access devices, and so on.
  • the processor 1200 can be a central processing unit (central processing unit, CPU), and the processor 1200 can also be other general processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuits) , ASIC), field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the storage 1201 may be an internal storage unit of the terminal device 12 in some embodiments, such as a hard disk or a memory of the terminal device 12 .
  • the memory 1201 may also be an external storage device of the terminal device 12 in other embodiments, such as a plug-in hard disk equipped on the terminal device 12, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, flash memory card (flash card), etc. Further, the memory 1201 may also include both an internal storage unit of the terminal device 12 and an external storage device.
  • the memory 1201 is used to store operating systems, application programs, bootloader programs (BootLoader), data and other programs, such as program codes of the computer programs.
  • the memory 1201 can also be used to temporarily store data that has been output or will be output.
  • the embodiment of the present application also provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the foregoing method embodiments can be implemented.
  • An embodiment of the present application provides a computer program product.
  • the computer program product runs on a terminal device, the terminal device can implement the steps in the foregoing method embodiments when executed.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the procedures in the methods of the above embodiments in the present application can be completed by instructing related hardware through computer programs, and the computer programs can be stored in a computer-readable storage medium.
  • the computer program When executed by a processor, the steps in the above-mentioned various method embodiments can be realized.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form.
  • the computer-readable storage medium may at least include: any entity or device capable of carrying computer program codes to the device/terminal device, recording medium, computer memory, read-only memory (read-only memory, ROM, ), random access Memory (random access memory, RAM), electrical carrier signals, telecommunication signals, and software distribution media.
  • computer readable storage media may not be electrical carrier signals and telecommunication signals based on legislation and patent practice.
  • the disclosed apparatus/terminal device and method may be implemented in other ways.
  • the device/terminal device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

Abstract

An encoding method, a decoding method, an apparatus, a terminal device (12), and a readable storage medium, which are applicable to the technical field of storage. In the encoding method, initial base sequences of data to be encoded can be acquired; the initial base sequences can then be grouped to obtain at least one set of intermediate base sequences corresponding to the initial base sequences, and first preset base sequences the proportions of G and C of which satisfy a preset condition are used to substitute the intermediate base sequences, and an encoded file corresponding to the data is obtained. The encoding method can enable the proportions of G and C in the encoded file to meet requirements, the cost and the probability of error of DNA sequence synthesis and sequencing to be reduced, the cost of DNA storage to be reduced, and the application scale of DNA storage to be expanded.

Description

编码方法、解码方法、装置、终端设备及可读存储介质Encoding method, decoding method, device, terminal equipment and readable storage medium 技术领域technical field
本申请属于存储技术领域,尤其涉及编码方法、解码方法、装置、终端设备及计算机可读存储介质。The present application belongs to the field of storage technology, and in particular relates to an encoding method, a decoding method, a device, a terminal device, and a computer-readable storage medium.
背景技术Background technique
脱氧核糖核酸(deoxyribonucleic acid,DNA)作为信息存储介质具有存储密度高、存储时间长以及损耗率低等特点,可以用于信息的大量存储。在DNA存储技术中,需要将待存储数据编码成DNA的碱基序列,然后可以根据碱基序列合成DNA,以将待存储数据存储至DNA中。其中,DNA编码技术是DNA存储中的关键技术。而现有的DNA编码技术会增加DNA合成及测序过程中出错的概率,不利于DNA存储技术的广泛应用。As an information storage medium, deoxyribonucleic acid (DNA) has the characteristics of high storage density, long storage time and low loss rate, and can be used for mass storage of information. In DNA storage technology, the data to be stored needs to be encoded into the base sequence of DNA, and then DNA can be synthesized according to the base sequence to store the data to be stored into the DNA. Among them, DNA encoding technology is the key technology in DNA storage. However, the existing DNA coding technology will increase the probability of errors in the process of DNA synthesis and sequencing, which is not conducive to the wide application of DNA storage technology.
技术问题technical problem
本申请实施例的目的之一在于:提供一种编码方法、解码方法、装置、终端设备及计算机可读存储介质,可以解决现有的DNA编码技术会增加DNA合成及测序过程中出错的概率的问题,扩大DNA存储技术的应用范围。One of the purposes of the embodiments of the present application is to provide an encoding method, decoding method, device, terminal equipment, and computer-readable storage medium, which can solve the problem that the existing DNA encoding technology will increase the probability of errors in the process of DNA synthesis and sequencing problems, expanding the scope of application of DNA storage technology.
技术解决方案technical solution
第一方面,本申请实施例提供了一种编码方法,包括:In the first aspect, the embodiment of the present application provides an encoding method, including:
获取待编码数据的初始碱基序列;Obtain the initial base sequence of the data to be encoded;
对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至少一组中间碱基序列;grouping the initial base sequences to obtain at least one group of intermediate base sequences corresponding to the initial base sequences;
利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,所述第一预设碱基序列中包含的G与C的占比满足预设条件。Replace at least one set of the intermediate base sequences with a first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain an encoding file corresponding to the data to be encoded, the first preset It is assumed that the ratio of G and C included in the base sequence satisfies a preset condition.
示例性的,所述待编码数据为文本,所述获取所述待编码数据的初始碱基序列,包括:Exemplarily, the data to be encoded is text, and the obtaining the initial base sequence of the data to be encoded includes:
统计所述文本中各字符的出现频率;Count the occurrence frequency of each character in the text;
以各所述字符为叶子节点、以各所述字符的出现频率为该叶子节点的权值构建所述文本对应的四叉哈夫曼树;Constructing a quadrangle Huffman tree corresponding to the text with each of the characters as a leaf node and the frequency of occurrence of each of the characters as the weight of the leaf node;
将所述四叉哈夫曼树的每一条边用碱基表示,得到所述文本对应的编码表;Representing each edge of the four-fork Huffman tree with a base to obtain a code table corresponding to the text;
根据所述编码表确定所述文本对应的初始碱基序列。The initial base sequence corresponding to the text is determined according to the coding table.
示例性的,所述利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,包括:Exemplarily, the at least one set of intermediate base sequences is replaced by a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded ,include:
利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到目标碱基序列;replacing at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain a target base sequence;
获取所述目标碱基序列中连续出现次数等于预设次数的重复碱基;Obtaining repeated bases whose number of consecutive occurrences is equal to a preset number of times in the target base sequence;
利用与所述重复碱基对应的第二预设碱基序列将所述重复碱基替换,得到所述待编码数据对应的编码文件。The repeated bases are replaced by a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
具体地,所述对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至少一组中间碱基序列,包括:Specifically, the grouping of the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences includes:
按照第一碱基数量对所述初始碱基序列进行分组,得到至少一组所述中间碱基序列,各所述中间碱基序列包括的碱基数量为所述第一碱基数量。The initial base sequences are grouped according to the first number of bases to obtain at least one group of the intermediate base sequences, and the number of bases included in each of the intermediate base sequences is the first number of bases.
在第一方面的一种可能的实现方式中,所述方法还包括:In a possible implementation manner of the first aspect, the method further includes:
获取所述初始碱基序列中的单独碱基序列,其中,所述单独碱基序列为对所述初始碱 基序列进行分组后,得到的碱基数量小于所述第一碱基数量的碱基序列;Obtaining an individual base sequence in the initial base sequence, wherein the individual base sequence is a base whose number of bases is less than the first number of bases after grouping the initial base sequence sequence;
根据所述第一碱基数量和所述单独碱基序列对应的第二碱基数量确定需添加的第三碱基数量,并在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基。Determine the number of third bases to be added according to the number of first bases and the number of second bases corresponding to the separate base sequence, and add the third base at a preset position of the separate base sequence base number of bases.
可选的,所述在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基,包括:Optionally, adding the third number of bases at the preset position of the individual base sequence includes:
根据GCAT的顺序在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基。adding the third number of bases at preset positions of the individual base sequence according to the order of GCAT.
示例性的,所述单独碱基序列为所述初始碱基序列头部的碱基序列或者为所述初始碱基序列尾部的碱基序列。Exemplarily, the individual base sequence is the base sequence at the head of the initial base sequence or the base sequence at the tail of the initial base sequence.
示例性的,所述预设位置为所述单独碱基序列的头部或者末尾。Exemplarily, the preset position is the head or the end of the single base sequence.
在第一方面的一种可能的实现方式中,所述利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,包括:In a possible implementation manner of the first aspect, at least one set of the intermediate base sequences is replaced by the first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain The encoding file corresponding to the data to be encoded includes:
利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,并将替换后的中间碱基序列与单独碱基序列进行合并,得到目标碱基序列;Replace at least one set of the intermediate base sequences with the first preset base sequence corresponding to at least one set of the intermediate base sequences one-to-one, and merge the replaced intermediate base sequence with the separate base sequence , to obtain the target base sequence;
获取所述目标碱基序列中连续出现次数等于预设次数的重复碱基;Obtaining repeated bases whose number of consecutive occurrences is equal to a preset number of times in the target base sequence;
利用与所述重复碱基对应的第二预设碱基序列将所述重复碱基替换,得到所述待编码数据对应的编码文件。The repeated bases are replaced by a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
可选的,所述预设次数为4次,所述重复碱基与第二预设碱基序列之间的对应关系包括以下至少一种:Optionally, the preset number of times is 4, and the correspondence between the repeated bases and the second preset base sequence includes at least one of the following:
GCATG对应GGGG;GCATG corresponds to GGGG;
GCATC对应CCCC;GCATC corresponds to CCCC;
GCATA对应AAAA;GCATA corresponds to AAAA;
GCATT对应TTTT。GCATT corresponds to TTTT.
示例性的,所述方法还包括:Exemplary, the method also includes:
根据所述中间碱基序列对应的第一碱基数量构建所述中间碱基序列对应的第一序列集合;constructing a first sequence set corresponding to the intermediate base sequence according to the number of first bases corresponding to the intermediate base sequence;
根据所述第一碱基数量确定所述第一预设碱基序列对应的第四碱基数量;determining a fourth base number corresponding to the first preset base sequence according to the first base number;
根据所述第四碱基数量构建所述第一预设碱基序列对应的第二序列集合,所述第二序列集合中的各所述第一预设碱基序列中包含的G与C的占比满足所述预设条件;The second sequence set corresponding to the first preset base sequence is constructed according to the fourth base number, and the G and C contained in each of the first preset base sequences in the second sequence set The proportion satisfies the preset conditions;
建立所述第一序列集合中的各所述中间碱基序列与所述第二序列集合中的各所述第一预设碱基序列之间的对应关系。Establishing a correspondence between each of the intermediate base sequences in the first sequence set and each of the first preset base sequences in the second sequence set.
可选的,所述第一碱基数量为5个,所述第四碱基数量为6个。Optionally, the number of the first bases is 5, and the number of the fourth bases is 6.
第二方面,本申请实施例提供了一种解码方法,包括:In the second aspect, the embodiment of the present application provides a decoding method, including:
获取待解码文件,所述待解码文件为基于上述第一方面中任一项所述的编码方法编码得到的文件;Obtaining a file to be decoded, the file to be decoded is a file encoded based on the encoding method described in any one of the above first aspects;
对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱基序列;performing base reduction on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded;
对所述初始碱基序列进行解码,得到所述待解码文件对应的解码数据。Decoding the initial base sequence to obtain decoded data corresponding to the file to be decoded.
通过上述的解码方法,可以对GC占比符合预设条件的待解码文件进行碱基的准确还原,得到待解码文件对应的初始碱基序列,并通过对初始碱基序列进行解码,即可以得到待解码文件对应的解码数据,可以有效提高解码效率和正确性。Through the above decoding method, the bases of the files to be decoded whose GC ratio meets the preset conditions can be accurately restored to obtain the initial base sequence corresponding to the file to be decoded, and by decoding the initial base sequence, you can get The decoding data corresponding to the file to be decoded can effectively improve decoding efficiency and correctness.
示例性的,所述对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱 基序列,包括:Exemplarily, the base reduction of the file to be decoded is performed to obtain the initial base sequence corresponding to the file to be decoded, including:
获取所述待解码文件中的第二预设碱基序列;Obtain the second preset base sequence in the file to be decoded;
利用与所述第二预设碱基序列对应的重复碱基将所述第二预设碱基序列替换,得到所述待解码文件对应的目标碱基序列;replacing the second preset base sequence with repeated bases corresponding to the second preset base sequence to obtain a target base sequence corresponding to the file to be decoded;
获取所述目标碱基序列中的第一预设碱基序列;Obtaining the first preset base sequence in the target base sequence;
利用与所述第一预设碱基序列对应的中间碱基序列将所述第一预设碱基序列替换,得到所述待解码文件对应的初始碱基序列。replacing the first preset base sequence with an intermediate base sequence corresponding to the first preset base sequence to obtain an initial base sequence corresponding to the file to be decoded.
第三方面,本申请实施例提供一种编码装置,包括:In a third aspect, the embodiment of the present application provides an encoding device, including:
初始序列获取模块,用于获取待编码数据的初始碱基序列;The initial sequence acquisition module is used to obtain the initial base sequence of the data to be encoded;
序列分组模块,用于对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至少一组中间碱基序列;A sequence grouping module, configured to group the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences;
编码模块,用于利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,所述第一预设碱基序列中包含的G与C的占比满足预设条件。An encoding module, configured to replace at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded, The ratio of G and C contained in the first preset base sequence satisfies a preset condition.
第四方面,本申请实施例提供了一种解码装置,包括:In a fourth aspect, the embodiment of the present application provides a decoding device, including:
文件获取模块,用于获取待解码文件,所述待解码文件为基于上述第一方面中任一项所述的编码方法编码得到的文件;A file acquisition module, configured to acquire a file to be decoded, where the file to be decoded is a file encoded based on the encoding method described in any one of the above first aspects;
碱基还原模块,用于对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱基序列;A base restoration module, configured to perform base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded;
解码模块,用于对所述初始碱基序列进行解码,得到所述待解码文件对应的解码数据。A decoding module, configured to decode the initial base sequence to obtain decoded data corresponding to the file to be decoded.
第五方面,本申请实施例提供了一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述第一方面,或者第二方面中任一项所述的方法。In the fifth aspect, the embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and operable on the processor, when the processor executes the computer program Realize the above-mentioned first aspect, or the method described in any one of the second aspect.
第六方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述第一方面,或者第二方面中任一项所述的方法。In the sixth aspect, the embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned first aspect or the second aspect are implemented. any one of the methods described.
第七方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行上述第一方面,或者第二方面中任一项所述的方法。In a seventh aspect, an embodiment of the present application provides a computer program product, which, when the computer program product is run on a terminal device, enables the terminal device to execute the method described in any one of the first aspect or the second aspect.
有益效果Beneficial effect
本申请实施例提供的编码方法的有益效果在于:通过上述的编码方法,可以获取待编码数据的初始碱基序列,并对初始碱基序列进行分组,得到中间碱基序列。然后可以利用GC占比符合预设条件的第一预设碱基序列对中间碱基序列进行替换,以使得所得到的编码文件中包含的GC占比符合要求,降低DNA序列合成和测序的成本以及出错的概率,降低DNA存储的成本,扩大DNA存储的应用规模。The beneficial effect of the encoding method provided by the embodiment of the present application is that: through the above-mentioned encoding method, the initial base sequence of the data to be encoded can be obtained, and the initial base sequence can be grouped to obtain an intermediate base sequence. Then, the intermediate base sequence can be replaced with the first preset base sequence whose GC ratio meets the preset conditions, so that the GC ratio contained in the obtained encoding file meets the requirements, reducing the cost of DNA sequence synthesis and sequencing And the probability of error, reduce the cost of DNA storage, and expand the application scale of DNA storage.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the accompanying drawings that need to be used in the descriptions of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings in the following description are only for the present application For some embodiments, those of ordinary skill in the art can also obtain other drawings based on these drawings without any creative effort.
图1是本申请实施例一提供的编码方法的流程示意图;FIG. 1 is a schematic flow chart of an encoding method provided in Embodiment 1 of the present application;
图2是本申请实施例一提供的构建四叉哈夫曼树的场景示意图;FIG. 2 is a schematic diagram of a scene for constructing a four-fork Huffman tree provided by Embodiment 1 of the present application;
图3是本申请实施例一提供的添加碱基的应用场景示意图;Fig. 3 is a schematic diagram of the application scenario of adding bases provided in Embodiment 1 of the present application;
图4是本申请实施例一提供的编码方法的场景示意图;FIG. 4 is a schematic diagram of a scene of an encoding method provided in Embodiment 1 of the present application;
图5至图7是本申请实施例一提供的编码方法的效果示意图;FIG. 5 to FIG. 7 are schematic diagrams showing the effect of the encoding method provided in Embodiment 1 of the present application;
图8是本申请实施例二提供的解码方法的流程示意图;FIG. 8 is a schematic flowchart of a decoding method provided in Embodiment 2 of the present application;
图9是本申请实施例二提供的解码方法的场景示意图;FIG. 9 is a schematic diagram of a scene of a decoding method provided in Embodiment 2 of the present application;
图10是本申请实施例三提供的编码装置的结构示意图;FIG. 10 is a schematic structural diagram of an encoding device provided in Embodiment 3 of the present application;
图11是本申请实施例四提供的解码装置的结构示意图;FIG. 11 is a schematic structural diagram of a decoding device provided in Embodiment 4 of the present application;
图12是本申请实施例提供的终端设备的结构示意图。FIG. 12 is a schematic structural diagram of a terminal device provided by an embodiment of the present application.
本发明的实施方式Embodiments of the present invention
以下描述中,为了说明而不是为了限定,提出了诸如特定系统结构、技术之类的具体细节,以便透彻理解本申请实施例。然而,本领域的技术人员应当清楚,在没有这些具体细节的其它实施例中也可以实现本申请。在其它情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本申请的描述。In the following description, specific details such as specific system structures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
应当理解,当在本申请说明书和所附权利要求书中使用时,术语“包括”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and/or components, but does not exclude one or more other Presence or addition of features, wholes, steps, operations, elements, components and/or collections thereof.
还应当理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It should also be understood that the term "and/or" used in the description of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
如在本申请说明书和所附权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。As used in this specification and the appended claims, the term "if" may be construed, depending on the context, as "when" or "once" or "in response to determining" or "in response to detecting ". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" may be construed, depending on the context, to mean "once determined" or "in response to the determination" or "once detected [the described condition or event] ]” or “in response to detection of [described condition or event]”.
另外,在本申请说明书和所附权利要求书的描述中,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。In addition, in the description of the specification and appended claims of the present application, the terms "first", "second", "third" and so on are only used to distinguish descriptions, and should not be understood as indicating or implying relative importance.
在本申请说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。Reference to "one embodiment" or "some embodiments" or the like in the specification of the present application means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in other embodiments," etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean "one or more but not all embodiments" unless specifically stated otherwise. The terms "including", "comprising", "having" and variations thereof mean "including but not limited to", unless specifically stated otherwise.
相关数据表明,2025年全球数据信息的总量将增长至163泽字节(Zettabyte,ZB),这超过了现有硬盘等存储介质的承受能力,因此,寻找一种新的数据存储至关重要。DNA作为信息存储介质具有存储密度高、存储时间长、损耗率低等特点,可用于信息的大量存储,逐渐受到研究者的广泛关注。其中,DNA具有四种碱基,分别是鸟嘌呤(Guanine,G)、胞嘧啶(Cytosine,C)、腺嘌呤(Adenine,A)和胸腺嘧啶(Thymine,T)。在DNA存储技术中,需要先将待存储数据编码成由GCAT四种碱基组成的碱基序列,然后根据碱基序列合成DNA,以将待存储数据存储至DNA中。Relevant data show that the total amount of global data information will increase to 163 Zettabytes (ZB) in 2025, which exceeds the capacity of storage media such as existing hard disks. Therefore, it is very important to find a new data storage . As an information storage medium, DNA has the characteristics of high storage density, long storage time, and low loss rate. It can be used for mass storage of information and has gradually attracted widespread attention from researchers. Among them, DNA has four bases, namely Guanine (Guanine, G), Cytosine (Cytosine, C), Adenine (Adenine, A) and Thymine (Thymine, T). In DNA storage technology, the data to be stored needs to be encoded into a base sequence consisting of four bases of GCAT, and then DNA is synthesized according to the base sequence to store the data to be stored in DNA.
其中,DNA编码技术是DNA存储中的关键技术。而现有的DNA编码技术存在编码效率不高或者编码得到的碱基序列中GC占比不均一、多碱基重复的问题,增加了DNA序 列合成和测序的成本以及出错的概率,不利于DNA存储技术的大规模应用。应理解,测序是对编码后的编码文件进行解码前的必要操作,用于测得编码文件对应的DNA碱基序列,在得到碱基序列后,再依据解码规则来进行碱基序列的解码。Among them, DNA encoding technology is the key technology in DNA storage. However, the existing DNA coding technology has the problems of low coding efficiency or uneven GC ratio in the encoded base sequence and multi-base repetition, which increases the cost of DNA sequence synthesis and sequencing and the probability of errors, which is not conducive to DNA Large-scale application of storage technology. It should be understood that sequencing is a necessary operation before decoding the encoded encoded file, and is used to measure the DNA base sequence corresponding to the encoded file. After the base sequence is obtained, the base sequence is decoded according to the decoding rules.
为解决上述问题,本申请实施例提供了一种编码方法,用于将数据编码为DNA中的碱基序列,以利用DNA来进行数据存储。该方法在获取待编码数据的初始碱基序列后,可以对初始碱基序列进行分组,得到初始碱基序列对应的至少一组中间碱基序列,并分别利用G与C的占比满足预设条件的第一预设碱基序列对各中间碱基序列进行替换,得到待编码数据对应的编码文件。即本申请实施例提供的编码方法可以使得编码文件中的GC占比符合要求,降低DNA序列合成和测序的成本以及出错的概率,降低DNA存储的成本,扩大DNA存储的应用规模,具有较强的易用性和实用性。In order to solve the above problems, the embodiment of the present application provides an encoding method for encoding data into base sequences in DNA, so as to use DNA for data storage. In this method, after obtaining the initial base sequence of the data to be encoded, the initial base sequence can be grouped to obtain at least one group of intermediate base sequences corresponding to the initial base sequence, and the proportions of G and C are used to satisfy the preset The first preset base sequence of the condition replaces each intermediate base sequence to obtain an encoding file corresponding to the data to be encoded. That is, the encoding method provided by the embodiment of the present application can make the proportion of GC in the encoding file meet the requirements, reduce the cost of DNA sequence synthesis and sequencing and the probability of errors, reduce the cost of DNA storage, and expand the application scale of DNA storage. ease of use and practicality.
本申请实施例提供的编码方法、解码方法可以应用于手机、平板电脑、可穿戴设备、车载设备、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)设备、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等终端设备上,本申请实施例对终端设备的具体类型不作任何限制。The encoding method and decoding method provided in the embodiments of the present application can be applied to mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (augmented reality, AR)/virtual reality (virtual reality, VR) devices, notebook computers, super mobile On terminal devices such as personal computers (ultra-mobile personal computer, UMPC), netbooks, and personal digital assistants (personal digital assistants, PDAs), the embodiments of the present application do not impose any restrictions on the specific types of terminal devices.
【实施例一】[Example 1]
请参阅图1,图1示出了本申请实施例一提供的编码方法的示意性流程图。如图1所示,该方法可以包括:Please refer to FIG. 1 . FIG. 1 shows a schematic flowchart of an encoding method provided in Embodiment 1 of the present application. As shown in Figure 1, the method may include:
S101、终端设备获取待编码数据的初始碱基序列。S101. The terminal device acquires the initial base sequence of the data to be encoded.
其中,待编码数据可以为任一格式的数据,例如可以为文本、数字,等等。本申请实施例中,终端设备可以按照任意一种已有的编码方式对任何格式的待编码数据进行编码,来得到待编码数据的初始碱基序列,本申请实施例对此不作具体限定。Wherein, the data to be encoded may be data in any format, such as text, numbers, and so on. In the embodiment of the present application, the terminal device can encode the data to be encoded in any format according to any existing encoding method to obtain the initial base sequence of the data to be encoded, which is not specifically limited in the embodiment of the present application.
为使最终得到的编码文件具有较短的碱基序列,以提高编码效率,降低DNA存储的成本,终端设备可以通过四叉哈夫曼编码(即四进制哈夫曼编码)方法对待编码数据进行编码,得到初始碱基序列。以下将以四叉哈弗曼编码为例进行示例性说明。In order to make the final encoded file have a shorter base sequence, to improve the encoding efficiency and reduce the cost of DNA storage, the terminal device can treat the encoded data through the four-fork Huffman encoding (that is, the four-ary Huffman encoding) method Encoding is performed to obtain the initial base sequence. The following will take the quadrangle Huffman coding as an example for illustration.
示例性的,在待编码数据为文本时,终端设备可以先对文本进行分词处理,得到文本对应的各字符。然后,终端设备统计各字符在文本中出现的次数,从而可以根据各字符出现的次数和文本具有的总字符数确定各字符的出现频率,并以各字符为叶子节点、以各字符的出现频率为该叶子节点的权值来构建文本对应的四叉哈夫曼树。随后,终端设备可以将四叉哈夫曼树的每一条边用碱基来表示,以得到文本对应的编码表,从而可以根据编码表确定文本的初始碱基序列。Exemplarily, when the data to be encoded is text, the terminal device may first perform word segmentation processing on the text to obtain each character corresponding to the text. Then, the terminal device counts the number of occurrences of each character in the text, so that the frequency of occurrence of each character can be determined according to the number of occurrences of each character and the total number of characters in the text, and each character is used as a leaf node. For the weight of the leaf node, construct a quadruple Huffman tree corresponding to the text. Subsequently, the terminal device can represent each edge of the quadruplet Huffman tree with bases to obtain a coding table corresponding to the text, so that the initial base sequence of the text can be determined according to the coding table.
可以理解的是,终端设备可以选取权值最小的四个叶子节点构建第一层的四叉哈夫曼子树,该四叉哈夫曼子树的根节点的权值为这四个叶子节点的权值之和。然后,终端设备将该四叉哈夫曼子树的根节点确定为新的叶子节点,并继续从所有未被选取的叶子节点(包括第一层的四叉哈夫曼子树的根节点)中选取权值最小的四个叶子节点构建第二层的四叉哈夫曼子树,该四叉哈夫曼子树的根节点的权值为这四个叶子节点的权值之和,以此类推,直至无法再构建四叉哈夫曼子树为止,以得到文本对应的四叉哈夫曼树。It can be understood that the terminal device can select the four leaf nodes with the smallest weights to construct the first-level quadrangle Huffman subtree, and the weight of the root node of the quadrature Huffman subtree is the weight of the four leaf nodes The sum of the weights of . Then, the terminal device determines the root node of the quadruplet Huffman subtree as a new leaf node, and continues from all unselected leaf nodes (including the root node of the quadruplet Huffman subtree of the first layer) Select the four leaf nodes with the smallest weight to build the second layer of quadruplet Huffman subtree, the weight of the root node of the quadrangle Huffman subtree is the sum of the weights of these four leaf nodes, as By analogy, until it is no longer possible to construct a four-fork Huffman subtree, to obtain a four-fork Huffman tree corresponding to the text.
其中,文本对应的四叉哈夫曼树中根节点的数量n可以根据文本对应的总字符数w1与3的商来确定。当总字符数w1是3的整数倍时,则n为总字符数w1除以3所得的商,例如,当总字符数w1为12时,n为4;当总字符数w1不是3的整数倍时,则n为总字符 数w1除以3所得的商再加1,例如,当总字符数w1为8时,n为3。可以理解的是,构建四叉哈夫曼树所需的叶子节点数w2与n之间的关系需满足3n+1=w2。因此,当文本的总字符数w1不等于w2时,终端设备可以添加1个或者2个权值为0的叶子节点,来进行四叉哈夫曼树的构建。Wherein, the number n of root nodes in the four-fork Huffman tree corresponding to the text can be determined according to the quotient of the total number of characters w1 and 3 corresponding to the text. When the total number of characters w1 is an integer multiple of 3, then n is the quotient obtained by dividing the total number of characters w1 by 3, for example, when the total number of characters w1 is 12, n is 4; when the total number of characters w1 is not an integer of 3 When times, then n is the quotient obtained by dividing the total number of characters w1 by 3 plus 1, for example, when the total number of characters w1 is 8, n is 3. It can be understood that the relationship between the number of leaf nodes w2 and n required to construct a quadrangle Huffman tree must satisfy 3n+1=w2. Therefore, when the total number of characters w1 of the text is not equal to w2, the terminal device can add one or two leaf nodes with a weight of 0 to construct a quadrangle Huffman tree.
构建文本对应的四叉哈夫曼树之后,终端设备可以对所构建的四叉哈夫曼树的各条边分别设定碱基。具体地,对于每一四叉哈夫曼子树,终端设备可以按照从左至右的顺序将该四叉哈夫曼子树的四条边分别设定为“G”、“C”、“A”、“T”。然后,终端设备可以按照从左至右的顺序将四叉哈夫曼树的根节点至各字符所对应的叶子节点的路径上的所有碱基的组合确定为该字符对应的碱基,得到文本对应的编码表,从而可以根据编码表来确定文本的初始碱基序列。After constructing the quadrature Huffman tree corresponding to the text, the terminal device can set bases for each side of the constructed quadrature Huffman tree respectively. Specifically, for each quadruple Huffman subtree, the terminal device can set the four sides of the quadruple Huffman subtree as "G", "C", "A" in order from left to right ", "T". Then, the terminal device can determine the combination of all bases on the path from the root node of the quadruplet Huffman tree to the leaf node corresponding to each character as the base corresponding to the character in order from left to right, and obtain the text The corresponding coding table, so that the initial base sequence of the text can be determined according to the coding table.
请参阅图2,图2示出了本申请实施例一提供的构建四叉哈夫曼树的应用场景示意图。该应用场景以文本为“生物与合成生物学”为例对四叉哈夫曼树的构建进行示例说明。Please refer to FIG. 2 . FIG. 2 shows a schematic diagram of an application scenario for constructing a quad-fork Huffman tree provided by Embodiment 1 of the present application. In this application scenario, the text "Biology and Synthetic Biology" is taken as an example to illustrate the construction of a quadruple Huffman tree.
如图2所示,终端设备可以先对文本进行分词处理,得到字符“生”、“物”、“与”、“合”、“成”以及“学”,并可以根据文本中各字符出现的次数和总字符数确定各字符的出现频率,得到“生”的出现频率为0.25、“物”的出现频率为0.25、“与”的出现频率为0.125、“合”的出现频率为0.125、“成”的出现频率为0.125、“学”的出现频率为0.125。随后,终端设备以各字符为叶子节点,以各字符的出现频率为该叶子节点的权值来进行四叉哈夫曼树的构建。其中,由于文本对应的总字符数(w1=8)小于构建四叉哈夫曼树所需的叶子节点数(w2=9),因此,终端设备可以根据w2和w1确定所需添加的叶子节点数为1,此时终端设备可以添加1个权值为0的叶子节点来构建得到如图2所示的四叉哈夫曼树。图2中的数字1、0.25、0等代表该节点的权值。As shown in Figure 2, the terminal device can first perform word segmentation processing on the text to obtain the characters "生", "物", "和", "合", "成" and "学", and can be based on the occurrence of each character in the text The number of times and the total number of characters determine the frequency of occurrence of each character, and the frequency of occurrence of "生" is 0.25, the frequency of "thing" is 0.25, the frequency of "and" is 0.125, and the frequency of "combination" is 0.125. The frequency of occurrence of "cheng" is 0.125, and the frequency of "learning" is 0.125. Subsequently, the terminal device uses each character as a leaf node, and uses the frequency of occurrence of each character as the weight of the leaf node to construct a quadruplet Huffman tree. Among them, since the total number of characters corresponding to the text (w1=8) is less than the number of leaf nodes (w2=9) required to construct a quadrangle Huffman tree, the terminal device can determine the leaf nodes to be added according to w2 and w1 The number is 1. At this time, the terminal device can add a leaf node with a weight of 0 to construct a quadruple Huffman tree as shown in FIG. 2 . The numbers 1, 0.25, 0, etc. in Figure 2 represent the weight of the node.
然后,终端设备可以按照从左至右的顺序将所有四叉哈夫曼子树的四条边分别设定为“G”、“C”、“A”、“T”,并根据四叉哈夫曼树的根节点(图2中“1”所在的节点)到各字符所对应的叶子节点的路径上的所有碱基的组合确定为该字符对应的碱基,得到如下述表1所示的编码表。终端设备根据该编码表即可以确定“生物与合成生物学”的初始碱基序列为CATCTATTCAG。Then, the terminal device can set the four sides of all four-fork Huffman subtrees as "G", "C", "A", and "T" in order from left to right, and according to the four-fork Huffman The combination of all bases on the path from the root node of the Mann tree (the node where "1" is located in Figure 2) to the leaf node corresponding to each character is determined as the base corresponding to the character, and the following table 1 is obtained code table. According to the coding table, the terminal device can determine that the initial base sequence of "Biology and Synthetic Biology" is CATCTATTCAG.
表1Table 1
字符character pregnancy thing and combine become study
碱基base CC AA TCTC TATA TTTT GG
S102、终端设备对初始碱基序列进行分组,得到初始碱基序列对应的至少一组中间碱基序列。S102. The terminal device groups the initial base sequences to obtain at least one group of intermediate base sequences corresponding to the initial base sequences.
示例性的,终端设备可以按照第一碱基数量对初始碱基序列进行分组,得到至少一组中间碱基序列,即各中间碱基序列均可以包括第一碱基数量的碱基。其中,第一碱基数量可以为大于或者等于5的任一数值。本申请实施例中,为使得最终得到的编码文件具有较短的碱基序列,以提高编码效率,可以将第一碱基数量确定为5。Exemplarily, the terminal device may group the initial base sequences according to the first number of bases to obtain at least one group of intermediate base sequences, that is, each intermediate base sequence may include bases of the first number of bases. Wherein, the first number of bases can be any value greater than or equal to 5. In the embodiment of the present application, in order to make the final encoding file have a shorter base sequence and improve encoding efficiency, the first number of bases can be determined as 5.
S103、终端设备利用与至少一组中间碱基序列一一对应的第一预设碱基序列将至少一组中间碱基序列替换,得到待编码数据对应的编码文件,第一预设碱基序列中包含的G与C的占比满足预设条件。S103. The terminal device replaces at least one set of intermediate base sequences with the first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded, the first preset base sequence The ratio of G and C contained in satisfies the preset condition.
示例性的,终端设备可以先根据第一预设对应关系确定各中间碱基序列对应的第一预设碱基序列,并分别利用各第一预设碱基序列替换对应的中间碱基序列,得到目标碱基序 列,目标碱基序列包含替换后的各中间碱基序列。然后,终端设备可以获取目标碱基序列中连续出现次数等于预设次数的重复碱基,并可以根据第二预设对应关系获取重复碱基对应的第二预设碱基序列,以利用第二预设碱基序列将重复碱基替换,得到待编码数据对应的编码文件。Exemplarily, the terminal device may first determine the first preset base sequence corresponding to each intermediate base sequence according to the first preset correspondence relationship, and replace the corresponding intermediate base sequence with each first preset base sequence, The target base sequence is obtained, and the target base sequence includes each intermediate base sequence after replacement. Then, the terminal device can obtain the repeated bases whose consecutive occurrences are equal to the preset number of times in the target base sequence, and can obtain the second preset base sequence corresponding to the repeated bases according to the second preset correspondence relationship, so as to utilize the second The preset base sequence will repeat the base replacement to obtain the encoding file corresponding to the data to be encoded.
其中,重复碱基与第二预设碱基序列对应的第二预设对应关系包括以下至少一种:GCATG对应GGGG;GCATC对应CCCC;GCATA对应AAAA;GCATT对应TTTT。应理解,第二预设对应关系可以存储于终端设备,也可以存储于与终端设备通信连接的云端服务器等其他设备。Wherein, the second preset correspondence between repeated bases and the second preset base sequence includes at least one of the following: GCATG corresponds to GGGG; GCATC corresponds to CCCC; GCATA corresponds to AAAA; GCATT corresponds to TTTT. It should be understood that the second preset correspondence relationship may be stored in the terminal device, or may be stored in other devices such as a cloud server communicatively connected with the terminal device.
同样的,第一预设对应关系可以存储于终端设备,也可以存储于与终端设备通信连接的云端服务器等其他设备,且第一预设对应关系可以由终端设备预先建立,也可以为由云端服务器等其他设备预先建立,本申请实施例对此不作具体限定。以下将以第一预设对应关系由终端设备预先建立为例进行示例性说明。Similarly, the first preset correspondence can be stored in the terminal device, or can be stored in other devices such as a cloud server communicatively connected with the terminal device, and the first preset correspondence can be pre-established by the terminal device, or can be created by the cloud The server and other devices are pre-established, which is not specifically limited in this embodiment of the present application. The following will take an example in which the first preset correspondence is pre-established by the terminal device as an example for illustration.
具体地,终端设备可以根据中间碱基序列对应的第一碱基数量构建中间碱基序列对应的第一序列集合。其中,第一序列集合中可以包括碱基数量为5的碱基序列的所有可能的排列方式,因此,第一序列集合中可以包括45=1024个中间碱基序列,即第一序列集合中可以包括{GGGGG,GGAGG,GCGGG,GCAGG,GAGGG,GAAGG,GTGGG,GTAGG,CGGGG,CGAGG,……}共1024个中间碱基序列。Specifically, the terminal device may construct the first sequence set corresponding to the intermediate base sequence according to the first base number corresponding to the intermediate base sequence. Wherein, the first sequence set may include all possible arrangements of base sequences with a base number of 5, therefore, the first sequence set may include 45=1024 intermediate base sequences, that is, the first sequence set may Including {GGGGG, GGAGG, GCGGG, GCAGG, GAGGG, GAAGG, GTGGG, GTAGG, CGGGG, CGAGG, ...} a total of 1024 intermediate base sequences.
随后,终端设备可以根据第一碱基数量确定第一预设碱基序列对应的第四碱基数量。其中,第四碱基数量可以为任一数值。本申请实施例中,为了确保最终得到的编码文件中的GC占比符合要求,以降低DNA序列合成和测序的成本以及出错的概率,同时为了使得编码文件具有较短的碱基序列,以提高编码效率,可以将第四碱基数量确定为6。以下将以第四碱基数量为6为例进行示例性说明。Subsequently, the terminal device may determine a fourth base number corresponding to the first preset base sequence according to the first base number. Wherein, the fourth base number can be any value. In the embodiment of this application, in order to ensure that the GC ratio in the final encoding file meets the requirements, the cost of DNA sequence synthesis and sequencing and the probability of errors are reduced, and at the same time, in order to make the encoding file have a shorter base sequence, to improve For coding efficiency, the number of fourth bases can be determined as 6. Hereinafter, the fourth base number is 6 as an example for illustration.
同样地,终端设备可以根据第四碱基数量构建包含第一预设碱基序列的第三序列集合,其中,第三序列集合中的各碱基序列中包含的G与C的占比满足预设条件。在此,预设条件可以为GC的占比为50%,即第三序列集合中的每一个碱基序列中包含的G与C的总数量为第四碱基数量的一半(即3)。应理解,碱基数量为6、且GC占比为50%的碱基序列所有可能的排列方式共有1280个,即第三序列集合中可以包括{GGGAAA,GGGAAT,GGGATA,GGGATT,GGGTAA,GGGTAT,GGGTTA,GGGTTT,GGCAAA,GGCAAT,……}共1280个碱基序列。Similarly, the terminal device can construct a third sequence set containing the first preset base sequence according to the fourth base number, wherein the ratio of G and C contained in each base sequence in the third sequence set satisfies the preset set conditions. Here, the preset condition may be that the proportion of GC is 50%, that is, the total number of G and C contained in each base sequence in the third sequence set is half of the number of the fourth base (ie 3). It should be understood that there are a total of 1280 possible arrangements of base sequences with a base number of 6 and a GC ratio of 50%, that is, the third sequence set may include {GGGAAA, GGGAAT, GGGATA, GGGATT, GGGTAA, GGGTAT, GGGTTA, GGGTTT, GGCAAA, GGCAAT, ...} have a total of 1280 base sequences.
由于后续重复碱基替换中需要使用包含GCAT的碱基序列,因此,为减少解码中的出错概率,即避免解码过程中,将第一预设碱基序列错判为是用于替换重复碱基的第二预设碱基序列,从而错误解码成GGGG、CCCC、AAAA或者TTTT,终端设备可以删除第三序列集合中的GCATxx、xGCATx、xxGCAT、xxxGCA、xxxxGC以及CATxxx,以确保最终构建的第二序列集合中不会出现用于替换重复碱基的第二预设碱基序列GCATG、GCATC、GCATA以及GCATT。x为任意碱基,以下所述的x均为任意碱基。Since the base sequence containing GCAT needs to be used in the subsequent repeated base replacement, in order to reduce the error probability in decoding, that is, to avoid the decoding process, the first preset base sequence is misjudged as being used to replace repeated bases The second preset base sequence, which is incorrectly decoded into GGGG, CCCC, AAAA or TTTT, the terminal device can delete GCATxx, xGCATx, xxGCAT, xxxGCA, xxxxGC and CATxxx in the third sequence set to ensure that the second The second preset base sequences GCATG, GCATC, GCATA and GCATT for replacing repeated bases will not appear in the sequence set. x is an arbitrary base, and x described below is an arbitrary base.
另外,由于重复碱基替换中会增加碱基的数量,因此为使得编码文件具有较短的碱基序列,降低DNA存储的成本,终端设备还可以删除第三序列集合中的GGGxxx、CCCxxx、AAAxxx、TTTxxx,xxxGGG、xxxCCC、xxxAAA、xxxTTT、xGGGAA以及xGGGTT,以降低目标碱基序列中出现四个碱基重复的概率,从而减少编码文件对应的碱基序列的长度。In addition, since the number of bases will be increased in repeated base replacement, in order to make the encoding file have a shorter base sequence and reduce the cost of DNA storage, the terminal device can also delete GGGxxx, CCCxxx, AAAxxx in the third sequence set , TTTxxx, xxxGGG, xxxCCC, xxxAAA, xxxTTT, xGGGAA, and xGGGTT to reduce the probability of four base repeats in the target base sequence, thereby reducing the length of the base sequence corresponding to the encoding file.
经过上述的删除处理后,第三序列集合中剩余1091个碱基序列,此时,终端设备可以 从这1091个碱基序列中选取1024个碱基序列作为第一预设碱基序列,以得到第二序列集合{GGCAAT,GGCTAA,GGCTAT,GGCTTA,GGAGAA,GGAGAT,GGAGTA,GGAGTT,GGACAA,GGACAT,……}。然后,终端设备可以将第一序列集合和第二序列集合分别视为一个1x1024维度的矩阵,并将两矩阵组合成一个2x1024维度的矩阵M:After the above-mentioned deletion process, there are 1091 base sequences remaining in the third sequence set. At this time, the terminal device can select 1024 base sequences from the 1091 base sequences as the first preset base sequence to obtain Second set of sequences {GGCAAT, GGCTAA, GGCTAT, GGCTTA, GGAGAA, GGAGAT, GGAGTA, GGAGTT, GGACAA, GGACAT, ...}. Then, the terminal device can regard the first sequence set and the second sequence set as a 1x1024-dimensional matrix respectively, and combine the two matrices into a 2x1024-dimensional matrix M:
Figure PCTCN2021103179-appb-000001
Figure PCTCN2021103179-appb-000001
其中,矩阵M中的第一行为第一序列集合中的各中间碱基序列,第二行为第二序列集合中的各第一预设碱基序列。此时,终端设备可以将矩阵M中的(1,a)与矩阵M中的(2,a)相对应,以此建立第一序列集合中的各中间碱基序列与第二序列集合中的各第一预设碱基序列之间的对应关系。a为矩阵M中的任一列。也就是说,当中间碱基序列为(1,1)中的GGGGG时,则与该中间碱基序列对应的第一预设碱基序列为(2,1)中的GGCAAT。当中间碱基序列为(1,5)中的GGGCG时,则与该中间碱基序列对应的第一预设碱基序列为(2,5)中的GGAGAA。Wherein, the first row in the matrix M is each intermediate base sequence in the first sequence set, and the second row is each first preset base sequence in the second sequence set. At this time, the terminal device can correspond (1, a) in the matrix M to (2, a) in the matrix M, so as to establish the relationship between each intermediate base sequence in the first sequence set and the second sequence set Correspondence between each first preset base sequence. a is any column in the matrix M. That is to say, when the intermediate base sequence is GGGGG in (1,1), the first predetermined base sequence corresponding to the intermediate base sequence is GGCAAT in (2,1). When the intermediate base sequence is GGGCG in (1,5), the first predetermined base sequence corresponding to the intermediate base sequence is GGAGAA in (2,5).
本实施例中,在利用第一预设碱基序列替换对应的中间碱基序列,得到目标碱基序列后,当目标碱基序列中不包含上述的重复碱基时,终端设备不用根据第二预设关系来进行重复碱基的替换,而直接将目标碱基序列确定为待编码数据对应的编码文件。In this embodiment, after using the first preset base sequence to replace the corresponding intermediate base sequence to obtain the target base sequence, when the target base sequence does not contain the above-mentioned repeated bases, the terminal device does not need to use the second The preset relationship is used to replace repeated bases, and the target base sequence is directly determined as the encoding file corresponding to the data to be encoded.
在一种可能的实现方式中,当初始碱基序列对应的碱基数量不是第一碱基数量的整数倍时,终端设备对初始碱基序列进行分组得到至少一组中间碱基序列时,还可以得到一个单独碱基序列,单独碱基序列对应的第二碱基数量小于第一碱基数量,即单独碱基序列可以包含1个碱基、2个碱基、3个碱基或者4个碱基。因此,在根据第一预设对应关系进行中间碱基序列的替换后,终端设备可以将替换后的中间碱基序列与单独碱基序列进行合并,以得到目标碱基序列。应理解,终端设备可以根据中间碱基序列和单独碱基序列在初始碱基序列中的位置关系来进行两者的合并。然后,终端设备可以获取目标碱基序列中连续出现次数等于预设次数的重复碱基,并可以根据第二预设对应关系获取重复碱基对应的第二预设碱基序列,以利用第二预设碱基序列替换重复碱基,得到待编码数据对应的编码文件。In a possible implementation, when the number of bases corresponding to the initial base sequence is not an integer multiple of the first base number, when the terminal device groups the initial base sequences to obtain at least one set of intermediate base sequences, it also A single base sequence can be obtained, and the number of second bases corresponding to the single base sequence is less than the number of first bases, that is, the single base sequence can contain 1 base, 2 bases, 3 bases or 4 bases base. Therefore, after the intermediate base sequence is replaced according to the first preset correspondence, the terminal device can combine the replaced intermediate base sequence with the individual base sequence to obtain the target base sequence. It should be understood that the terminal device can combine the intermediate base sequence and the individual base sequence according to the positional relationship between the two in the initial base sequence. Then, the terminal device can obtain the repeated bases whose consecutive occurrences are equal to the preset number of times in the target base sequence, and can obtain the second preset base sequence corresponding to the repeated bases according to the second preset correspondence relationship, so as to utilize the second The preset base sequence replaces the repeated bases to obtain the encoding file corresponding to the data to be encoded.
在另一种可能的实现方式中,终端设备可以根据第一碱基数量和单独碱基序列对应的第二碱基数量确定需添加的第三碱基数量,并可以在单独碱基序列的预设位置按照GCAT的顺序添加第三碱基数量的碱基,并将碱基添加后的单独碱基序列与替换后的中间碱基序列进行合并,得到目标碱基序列,以通过将所添加的碱基作为识别序列,使得在解码过程中,终端设备可以根据识别序列准确识别单独碱基序列,从而准确得到解码文件,提高解码正确性。例如,当需要添加四个碱基时,终端设备可以在单独碱基序列的预设位置中按照从左至右的顺序依次添加“G”、“C”、“A”、“T”。例如,当需要添加三个碱基时,终端设备可以在单独碱基序列的预设位置中按照从左至右的顺序依次添加“G”、“C”、“A”。例如,当需要添加两个碱基时,终端设备可以在单独碱基序列的预设位置中按照从左至右的顺序依次添加“G”、“C”。例如,当需要添加一个碱基时,终端设备可以在单独碱基序列的预设位置添加“G”,等等。In another possible implementation, the terminal device can determine the number of third bases to be added according to the number of first bases and the number of second bases corresponding to the individual base sequence, and can Assume that the position is added according to the order of GCAT to add the base of the third base number, and the individual base sequence after the base addition and the intermediate base sequence after the replacement are merged to obtain the target base sequence, and the added The base is used as the recognition sequence, so that during the decoding process, the terminal device can accurately identify the individual base sequence according to the recognition sequence, thereby accurately obtaining the decoded file and improving the correctness of decoding. For example, when four bases need to be added, the terminal device can add "G", "C", "A", and "T" in sequence from left to right in the preset position of the individual base sequence. For example, when three bases need to be added, the terminal device can add "G", "C", and "A" in sequence from left to right in the preset position of the individual base sequence. For example, when two bases need to be added, the terminal device can add "G" and "C" in sequence from left to right in the preset position of the individual base sequence. For example, when a base needs to be added, the terminal device can add "G" at the preset position of the individual base sequence, and so on.
需要说明的是,单独碱基序列可以为初始碱基序列中任一位置处的碱基序列,例如可以为初始碱基序列头部的碱基序列,或者可以为初始碱基序列尾部的碱基序列,或者可以 为初始碱基序列的中间任一位置的碱基序列。另外,添加碱基的预设位置可以为单独碱基序列的头部或者末尾。It should be noted that the individual base sequence can be the base sequence at any position in the initial base sequence, for example, it can be the base sequence at the head of the initial base sequence, or it can be the base sequence at the tail of the initial base sequence sequence, or it can be the base sequence at any position in the middle of the initial base sequence. In addition, the preset position for adding bases may be the head or the end of a single base sequence.
请参阅图3,图3示出了本申请实施例一提供的添加碱基的应用场景示意图。如3中的(a)所示,单独碱基序列可以为初始碱基序列头部的碱基序列,终端设备可以在单独碱基序列的头部添加第三碱基数量的碱基;或者,如图3中的(b)所示,单独碱基序列可以为初始碱基序列末尾的碱基序列,终端设备可以在单独碱基序列的末尾添加第三碱基数量的碱基。Please refer to FIG. 3 . FIG. 3 shows a schematic diagram of an application scenario for adding bases provided in Embodiment 1 of the present application. As shown in (a) in 3, the individual base sequence can be the base sequence at the head of the initial base sequence, and the terminal device can add bases with the third number of bases at the head of the individual base sequence; or, As shown in (b) in FIG. 3 , the individual base sequence may be the base sequence at the end of the initial base sequence, and the terminal device may add a third number of bases at the end of the individual base sequence.
为方便解码过程中,正确识别单独碱基序列,终端设备可以对单独碱基序列在初始碱基序列中的位置以及所添加的碱基在单独碱基序列中的预设位置进行标记,解码时,终端设备可以根据该标记来进行单独碱基序列的识别。本实施例中,为减少最终得到的编码文件的长度,以提高编码效率,降低解码难度与出错概率,终端设备也可以不设置标记,而直接将单独碱基序列默认设置为初始碱基序列末尾的碱基序列,并直接将所添加的碱基在单独碱基序列中的预设位置默认设置为单独碱基序列的末尾。In order to facilitate the correct identification of the individual base sequence during the decoding process, the terminal device can mark the position of the individual base sequence in the initial base sequence and the preset position of the added base in the individual base sequence. , the terminal device can identify the individual base sequence according to the mark. In this embodiment, in order to reduce the length of the final encoded file, improve encoding efficiency, reduce decoding difficulty and error probability, the terminal device may not set a flag, but directly set the individual base sequence as the end of the initial base sequence by default base sequence, and directly set the preset position of the added base in the separate base sequence as the end of the separate base sequence by default.
以下将以第一碱基数量为5、第四碱基数量为6、单独碱基序列默认为初始碱基序列末尾的碱基序列、预设位置默认为单独碱基序列的末尾为例进行示例性说明。The following will take the example that the number of the first base is 5, the number of the fourth base is 6, the single base sequence defaults to the base sequence at the end of the initial base sequence, and the preset position defaults to the end of the single base sequence sexual description.
请参阅图4,图4示出了本申请实施例一提供的编码方法的应用场景示意图。如图4所示,在确定待编码数据的初始碱基序列为CCTCTATCCAG时,终端设备可以根据初始碱基序列对应的第二碱基数量(即11)和预设的第一碱基数量(即5)对初始碱基序列进行分组,以得到2个中间碱基序列(即CCTCT和ATCCA)和单独碱基序列,其中,单独碱基序列包括一个碱基G。然后,终端设备可以在单独碱基序列的末尾添加“G”、“C”、“A”、“T”四个碱基,得到GGCAT。同时,终端设备可以利用与各中间碱基序列对应的第一预设碱基序列将各中间碱基序列替换,例如利用与中间碱基序列CCTCT对应的第一预设碱基序列CCTGAA将中间碱基序列CCTCT、利用与中间碱基序列ATCCA对应的第一预设碱基序列AACGTC将中间碱基序列ATCCA替换,并将替换得到的碱基序列CCTGAAAACGTC与GGCAT进行合并,得到目标碱基序列CCTGAAAACGTCGGCAT。然后,终端设备可以获取目标碱基序列CCTGAAAACGTCGGCAT中的重复碱基AAAA,并利用与重复碱基AAAA对应的第二预设碱基序列GCATA将重复碱基AAAA替换,得到待编码数据对应的编码文件CCTGGCATACGTCGGCAT。Please refer to FIG. 4 , which shows a schematic diagram of an application scenario of the encoding method provided in Embodiment 1 of the present application. As shown in Figure 4, when determining that the initial base sequence of the data to be encoded is CCTCTATCCAG, the terminal device can base on the second number of bases corresponding to the initial base sequence (i.e. 11) and the preset first number of bases (i.e. 5) Grouping the initial base sequences to obtain two intermediate base sequences (ie CCTCT and ATCCA) and an individual base sequence, wherein the individual base sequence includes a base G. Then, the terminal device can add four bases "G", "C", "A", and "T" to the end of the individual base sequence to obtain GGCAT. At the same time, the terminal device can use the first preset base sequence corresponding to each intermediate base sequence to replace each intermediate base sequence, for example, use the first preset base sequence CCTGAA corresponding to the intermediate base sequence CCTCT to replace the intermediate base sequence base sequence CCTCT, using the first preset base sequence AACGTC corresponding to the intermediate base sequence ATCCA to replace the intermediate base sequence ATCCA, and merging the replaced base sequence CCTGAAAACGTC and GGCAT to obtain the target base sequence CCTGAAAACGTCGGCAT. Then, the terminal device can obtain the repeated base AAAA in the target base sequence CCTGAAAACGTCGGCAT, and use the second preset base sequence GCATA corresponding to the repeated base AAAA to replace the repeated base AAAA to obtain the encoding file corresponding to the data to be encoded CCTGGCATACGTCGGCAT.
以下将以《三字经》的全文文本为例对本实施例提供的编码方法的效果进行示例性说明。The effect of the encoding method provided in this embodiment will be illustrated below by taking the full text of "San Zi Jing" as an example.
请参阅图5至图7,图5至图7示出了本申请实施例一提供的编码方法的效果示意图。如图5所示,在使用三叉哈夫曼编码(即三进制哈夫曼编码)方法对《三字经》的全文文本进行编码得到的编码文件中,任意连续的50bp碱基序列中有较多序列的GC占比低于0.45或高于0.55。如图6所示,与三叉哈夫曼编码相比,在使用本申请实施例一提出的编码方法对《三字经》的全文文本进行编码得到的编码文件中,任意连续的50bp碱基序列中的GC占比均处于0.45~0.55之间,显然本申请实施例一提供的编码方法可以使得编码文件中的GC占比更为均一。另外,在利用本申请实施例一提供的编码方法得到的编码文件中,碱基序列的最大碱基重复个数为3个。综上,本申请实施例一提供的编码方法更有利于降低DNA长片段序列的合成难度,从而可以有效降低DNA合成及测序过程中出错的概率,以扩展DNA存储技术的应用范围。Referring to FIG. 5 to FIG. 7 , FIG. 5 to FIG. 7 show schematic diagrams of effects of the encoding method provided by Embodiment 1 of the present application. As shown in Figure 5, in the encoded file obtained by encoding the full-text text of "San Zi Jing" using the three-pronged Huffman encoding (i.e., ternary Huffman encoding) method, there are more The GC ratio of the sequence is lower than 0.45 or higher than 0.55. As shown in Figure 6, compared with the three-pronged Huffman encoding, in the encoding file obtained by encoding the full-text text of "San Zi Jing" using the encoding method proposed in Example 1 of the present application, in any continuous 50bp base sequence The GC ratios are all between 0.45 and 0.55. Obviously, the encoding method provided in Embodiment 1 of the present application can make the GC ratios in the encoded files more uniform. In addition, in the encoding file obtained by using the encoding method provided in Example 1 of the present application, the maximum number of repeated bases in the base sequence is 3. In summary, the encoding method provided in Example 1 of the present application is more conducive to reducing the difficulty of synthesizing long DNA fragment sequences, thereby effectively reducing the probability of errors during DNA synthesis and sequencing, and expanding the application range of DNA storage technology.
如图7所示,使用本申请实施例一提出的编码方法进行编码得到的编码文件中的碱基序列为9793bp,而使用三叉哈夫曼编码得到的编码文件中的碱基序列长度为10128bp,即本申请实施例一提供的编码方法得到的碱基序列的长度更短,更有利于降低DNA存储信息的成本。As shown in Figure 7, the base sequence in the encoding file obtained by encoding using the encoding method proposed in Example 1 of the present application is 9793bp, while the length of the base sequence in the encoding file obtained by using the three-pronged Huffman encoding is 10128bp, That is, the length of the base sequence obtained by the encoding method provided in Example 1 of the present application is shorter, which is more conducive to reducing the cost of DNA storage information.
本实施例中,在获取待编码数据的初始碱基序列后,可以对初始碱基序列进行分组,得到初始碱基序列对应的至少一组中间碱基序列,并分别利用G与C的占比满足预设条件的第一预设碱基序列对中间碱基序列进行替换,得到待编码数据对应的编码文件。即本实施例提供的编码方法可以使得编码文件中的GC占比符合要求,以降低DNA序列合成和测序的成本以及出错的概率,扩大DNA存储的应用规模,具有较强的易用性和实用性。In this embodiment, after obtaining the initial base sequence of the data to be encoded, the initial base sequence can be grouped to obtain at least one group of intermediate base sequences corresponding to the initial base sequence, and the proportions of G and C can be used to The first preset base sequence that meets the preset conditions replaces the intermediate base sequence to obtain an encoding file corresponding to the data to be encoded. That is, the encoding method provided in this embodiment can make the GC ratio in the encoding file meet the requirements, reduce the cost of DNA sequence synthesis and sequencing and the probability of errors, expand the application scale of DNA storage, and have strong usability and practicality sex.
【实施例二】[Example 2]
请参阅图8,图8示出了本申请实施例二提供的解码方法的示意性流程图,如图8所示,该方法可以包括:Please refer to FIG. 8. FIG. 8 shows a schematic flowchart of a decoding method provided in Embodiment 2 of the present application. As shown in FIG. 8, the method may include:
S801、终端设备获取待解码文件,待解码文件为基于前述实施例一所述的编码方法编码得到的文件。S801. The terminal device acquires a file to be decoded, where the file to be decoded is a file encoded based on the encoding method described in Embodiment 1 above.
S802、终端设备对待解码文件进行碱基还原,得到待解码文件对应的初始碱基序列。S802. The terminal device performs base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded.
S803、终端设备对初始碱基序列进行解码,得到待解码文件对应的解码数据。S803. The terminal device decodes the initial base sequence to obtain decoded data corresponding to the file to be decoded.
具体地,终端设备可以先获取待解码文件中的第二预设碱基序列,并利用与第二预设碱基序列对应的重复碱基将第二预设碱基序列替换,得到待解码文件对应的目标碱基序列。然后,终端设备可以获取目标碱基序列中的第一预设碱基序列,并利用与第一预设碱基序列对应的中间碱基序列将第一预设碱基序列替换,得到待解码文件对应的初始碱基序列。随后,终端设备可以对初始碱基序列进行解码,得到待解码文件对应的解码数据。其中,本实施例中,终端设备对初始碱基序列进行解码的解码方式与实施例一中对待编码数据进行编码得到初始碱基序列的编码方式相对应。Specifically, the terminal device can first obtain the second preset base sequence in the file to be decoded, and use the repeated bases corresponding to the second preset base sequence to replace the second preset base sequence to obtain the file to be decoded Corresponding target base sequence. Then, the terminal device can obtain the first preset base sequence in the target base sequence, and use the intermediate base sequence corresponding to the first preset base sequence to replace the first preset base sequence to obtain the file to be decoded Corresponding initial base sequence. Subsequently, the terminal device can decode the initial base sequence to obtain the decoded data corresponding to the file to be decoded. Wherein, in this embodiment, the decoding method for the terminal device to decode the initial base sequence corresponds to the encoding method for encoding the data to be encoded to obtain the initial base sequence in Embodiment 1.
示例性的,在待编码数据为文本时,终端设备可以通过四叉哈夫曼编码对该文本进行编码,得到该文本对应的编码表。然后,终端设备可以根据该编码表确定该文本的初始碱基序列。因此,解码时,终端设备则可以根据该编码表对初始碱基序列进行解码,得到对应的解码数据(即该文本)。以下将以四叉哈夫曼编码为例进行示例性说明。Exemplarily, when the data to be encoded is text, the terminal device may encode the text by using quad-fork Huffman encoding to obtain an encoding table corresponding to the text. Then, the terminal device can determine the initial base sequence of the text according to the coding table. Therefore, when decoding, the terminal device can decode the initial base sequence according to the encoding table to obtain the corresponding decoded data (that is, the text). The following will take four-fork Huffman coding as an example for illustration.
其中,重复碱基与第二预设碱基序列之间的对应关系可以包括GCATG对应GGGG;GCATC对应CCCC;GCATA对应AAAA;GCATT对应TTTT。即终端设备可以在待解码文件中寻找“GCATT”,将其替换为“TTTT”,寻找“GCATA”,将其替换为“AAAA”,寻找“GCATC”,将其替换为“CCCC”,寻找“GCATG”,将其替换为“GGGG”,得到待解码文件对应的目标碱基序列。应理解,第一预设碱基序列与中间碱基序列之间的对应关系的具体内容可以参见前述实施例一中的描述,在此不再赘述。Wherein, the correspondence between repeated bases and the second preset base sequence may include GCATG corresponding to GGGG; GCATC corresponding to CCCC; GCATA corresponding to AAAA; GCATT corresponding to TTTT. That is, the terminal device can look for "GCATT" in the file to be decoded and replace it with "TTTT", look for "GCATA" and replace it with "AAAA", look for "GCATC" and replace it with "CCCC", and look for " GCATG" and replace it with "GGGG" to get the target base sequence corresponding to the file to be decoded. It should be understood that the specific content of the corresponding relationship between the first preset base sequence and the intermediate base sequence can refer to the description in the first embodiment above, and will not be repeated here.
示例性的,在编码过程中,在对初始碱基序列进行分组时,若存在单独碱基序列,终端设备可以添加编码文件对应的第一标识和第二标识,第一标识用于标识单独碱基序列在初始碱基序列中的位置,第二标识用于标识所添加的碱基在单独碱基序列中的预设位置。Exemplarily, during the encoding process, when grouping the initial base sequence, if there is a separate base sequence, the terminal device can add the first identification and the second identification corresponding to the encoding file, the first identification is used to identify the individual base The position of the base sequence in the initial base sequence, and the second mark is used to identify the preset position of the added base in the separate base sequence.
在得到目标碱基序列后,终端设备可以根据待解码文件对应的第一标识和第二标识,从目标碱基序列中拆分出单独碱基序列(包括所添加的碱基),并删除单独碱基序列中所添加的碱基。对于目标碱基序列中的剩余碱基序列(即除单独碱基序列以外的碱基序列),终端设备可以获取第一预设碱基序列,利用与第一预设碱基序列对应的中间碱基序列将第一 预设碱基序列替换,并将进行碱基替换得到的碱基序列与删除碱基后的单独碱基序列进行合并,得到待编码文件对应的初始碱基序列。随后,终端设备可以根据四叉哈夫曼编码对应的编码表对初始碱基序列进行解码,得到待解码文件对应的解码数据。After obtaining the target base sequence, the terminal device can split the individual base sequence (including the added base) from the target base sequence according to the first identification and the second identification corresponding to the file to be decoded, and delete the individual base sequence. A base added to a base sequence. For the remaining base sequences in the target base sequence (that is, base sequences other than the individual base sequences), the terminal device can obtain the first preset base sequence, and use the intermediate base corresponding to the first preset base sequence The base sequence replaces the first preset base sequence, and merges the base sequence obtained by base replacement with the single base sequence after base deletion to obtain the initial base sequence corresponding to the file to be encoded. Subsequently, the terminal device can decode the initial base sequence according to the encoding table corresponding to the four-fork Huffman encoding, and obtain the decoded data corresponding to the file to be decoded.
或者,终端设备可以先根据第一标识和第二标识从待解码文件中拆分出单独碱基序列(包括所添加的碱基),并删除单独碱基序列中所添加的碱基。然后,对于待解码文件中的剩余碱基序列(即除单独碱基序列以外的碱基序列),终端设备可以获取该剩余碱基序列中的第二预设碱基序列,并利用与第二预设碱基序列对应的重复碱基将第二预设碱基序列替换,得到待解码文件对应的目标碱基序列。终端设备获取目标碱基序列中的第一预设碱基序列,利用与第一预设碱基序列对应的中间碱基序列将第一预设碱基序列替换,并将进行碱基替换得到的碱基序列与删除碱基后的单独碱基序列进行合并,得到待编码文件对应的初始碱基序列。随后,终端设备可以根据四叉哈夫曼编码对应的编码表对初始碱基序列进行解码,得到待解码文件对应的解码数据。Alternatively, the terminal device may first split the individual base sequence (including the added bases) from the file to be decoded according to the first identifier and the second identifier, and delete the added bases in the individual base sequence. Then, for the remaining base sequences in the file to be decoded (i.e. base sequences other than the individual base sequences), the terminal device can obtain the second preset base sequence in the remaining base sequences, and use the The repeated bases corresponding to the preset base sequence are replaced by the second preset base sequence to obtain the target base sequence corresponding to the file to be decoded. The terminal device obtains the first preset base sequence in the target base sequence, replaces the first preset base sequence with the intermediate base sequence corresponding to the first preset base sequence, and performs base replacement to obtain The base sequence is merged with the single base sequence after base deletion to obtain the initial base sequence corresponding to the file to be encoded. Subsequently, the terminal device can decode the initial base sequence according to the encoding table corresponding to the four-fork Huffman encoding, and obtain the decoded data corresponding to the file to be decoded.
在一种可能的实现方式中,在编码过程中,终端设备可以将单独碱基序列默认为初始碱基序列末尾的碱基序列,并将所添加的碱基在单独碱基序列的预设位置默认为单独碱基序列的末尾,以在不引入标识的基础上方便解码时准确识别单独碱基序列,确保得到正确的解码数据。因此,在得到目标碱基序列之后,终端设备可以获取目标碱基序列对应的碱基数量。当目标碱基序列对应的碱基数量为6的倍数时,终端设备可以直接利用与各第一预设碱基序列一一对应的中间碱基序列对第一预设碱基序列进行碱基还原,即将每6个碱基还原为原来的5个碱基,得到待解码文件对应的初始碱基序列。其中,终端设备进行碱基还原的顺序与实施例一中终端设备进行碱基替换的顺序相同。例如,当实施例一中,终端设备按照从左到右的顺序进行碱基替换时,本实施例中,终端设备将按照从左至右的顺序进行碱基还原。以下将以按照从左至右的顺序进行还原为例进行示例性说明。In a possible implementation, during the encoding process, the terminal device can default the individual base sequence as the base sequence at the end of the initial base sequence, and place the added base at the preset position of the individual base sequence The default is the end of the individual base sequence, so as to facilitate the accurate identification of the individual base sequence during decoding without introducing an identifier, so as to ensure correct decoding data. Therefore, after obtaining the target base sequence, the terminal device can obtain the number of bases corresponding to the target base sequence. When the number of bases corresponding to the target base sequence is a multiple of 6, the terminal device can directly use the intermediate base sequence corresponding to each first preset base sequence to perform base reduction on the first preset base sequence , that is, restore every 6 bases to the original 5 bases, and obtain the initial base sequence corresponding to the file to be decoded. Wherein, the sequence in which the terminal device performs base reduction is the same as the sequence in which the terminal device performs base replacement in Embodiment 1. For example, when in Embodiment 1, the terminal device performs base replacement in order from left to right, in this embodiment, the terminal device will perform base restoration in order from left to right. The following will take restoration from left to right as an example for illustration.
当目标碱基序列对应的碱基数量不是6的倍数时,终端设备则可以将目标碱基序列中的最后5个碱基序列拆分出来,并可以对拆分出来的碱基序列进行碱基删除,得到单独碱基序列。同时,终端设备可以利用与各第一预设碱基序列一一对应的中间碱基序列对第一预设碱基序列进行碱基还原,即将每6个碱基还原为原来的5个碱基。然后,终端设备可以将单独碱基序列与进行碱基还原得到的碱基序列进行合并,即将单独碱基序列添加至碱基还原得到的碱基序列的末尾,得到待解码文件对应的初始碱基序列。When the number of bases corresponding to the target base sequence is not a multiple of 6, the terminal device can split the last 5 base sequences in the target base sequence, and can base the split base sequence Deleted to obtain a single base sequence. At the same time, the terminal device can use the intermediate base sequence corresponding to each first preset base sequence to perform base reduction on the first preset base sequence, that is, restore every 6 bases to the original 5 bases . Then, the terminal device can combine the individual base sequence with the base sequence obtained by base reduction, that is, add the individual base sequence to the end of the base sequence obtained by base reduction to obtain the initial base corresponding to the file to be decoded sequence.
其中,在编码过程中,终端设备可以按照“GCAT”的顺序在单独碱基序列的末端进行碱基添加。解码时,当最后一组碱基序列为xxxxG时,终端设备可以确定G为所添加的碱基,即可以确定单独碱基序列为xxxx。当最后一组碱基序列为xxxGC时,终端设备可以确定G和C为所添加的碱基,即可以确定单独碱基序列为xxx。当最后一组碱基序列为xxGCA时,终端设备可以确定G、C以及A为所添加的碱基,即可以确定单独碱基序列为xx。当最后一组碱基序列为xGCAT时,终端设备可以确定G、C、A以及T为所添加的碱基,即可以确定单独碱基序列为x。Among them, during the encoding process, the terminal device can perform base addition at the end of the individual base sequence in the order of "GCAT". When decoding, when the last group of base sequences is xxxxG, the terminal device can determine that G is the added base, that is, it can determine that the individual base sequence is xxxx. When the last group of base sequences is xxxGC, the terminal device can determine that G and C are the added bases, that is, the individual base sequence can be determined as xxx. When the last group of base sequences is xxGCA, the terminal device can determine that G, C and A are the added bases, that is, it can determine that the individual base sequence is xx. When the last group of base sequences is xGCAT, the terminal device can determine that G, C, A and T are the added bases, that is, the individual base sequence can be determined as x.
请参阅图9,图9示出了本实施例提供的解码方法的应用场景示意图。如图9所示,在终端设备获取到的待解码文件为CACTTGAACCACGGCAT时,由于待解码文件中不存在GCATG、GCATC、GCATA以及GCATT,即终端设备可以确定待解码文件不存在四碱基重复的问题,此时终端设备可以直接将待解码文件确定为目标碱基序列。由于,目标碱基序列对应的碱基数量不是6的倍数,因此,终端设备可以确定目标碱基序列中存在单独 碱基序列,此时,终端设备可以对目标碱基序列进行拆分,得到单独碱基序列GGCAT以及第一预设碱基序列CACTTG和AACCAC。随后,终端设备可以利用与第一预设碱基序列CACTTG对应的中间碱基序列CATCT替换第一预设碱基序列CACTTG、利用与第一预设碱基序列AACCAC对应的中间碱基序列ATTCA替换第一预设碱基序列AACCAC,同时,终端设备可以删除单独碱基序列GGCAT中所添加的碱基GCAT。最后,终端设备可以将进行碱基替换后的第一预设碱基序列和进行碱基删除后的单独碱基序列进行合并,得到初始碱基序列CATCTATTCAG,并根据前述实施例一中表1所示的编码表对初始碱基序列进行解码,得到待解码文件对应的解码数据“生物与合成生物学”。Please refer to FIG. 9, which shows a schematic diagram of an application scenario of the decoding method provided in this embodiment. As shown in Figure 9, when the file to be decoded obtained by the terminal device is CACTTGAACCACGGCAT, since GCATG, GCATC, GCATA, and GCATT do not exist in the file to be decoded, the terminal device can determine that there is no four-base repeat problem in the file to be decoded , at this point the terminal device can directly determine the file to be decoded as the target base sequence. Since the number of bases corresponding to the target base sequence is not a multiple of 6, the terminal device can determine that there is a separate base sequence in the target base sequence. At this time, the terminal device can split the target base sequence to obtain separate The base sequence GGCAT and the first preset base sequences CACTTG and AACCAC. Subsequently, the terminal device can use the intermediate base sequence CATCT corresponding to the first preset base sequence CACTTG to replace the first preset base sequence CACTTG, and the intermediate base sequence AATTCA corresponding to the first preset base sequence AACCAC to replace The first preset base sequence AACCAC, at the same time, the terminal device can delete the added base GCAT in the single base sequence GGCAT. Finally, the terminal device can combine the first preset base sequence after base substitution and the individual base sequence after base deletion to obtain the initial base sequence CATCTATTCAG, and according to Table 1 in the foregoing embodiment one Decode the initial base sequence using the coding table shown, and obtain the decoded data "Biology and Synthetic Biology" corresponding to the file to be decoded.
在另一种可能的实现方式中,在编码过程中,终端设备也可以不对单独碱基序列进行碱基添加,而直接将单独碱基序列默认为初始碱基序列末尾的碱基序列。在解码过程中,当目标碱基序列对应的碱基数量不是6的倍数时,终端设备可以获取目标碱基序列对应的碱基数量与6的余数,并从目标碱基序列的末尾拆分出该余数的碱基序列来作为单独碱基序列。同时,终端设备可以利用与各第一预设碱基序列一一对应的中间碱基序列对第一预设碱基序列进行还原,即将目标碱基序列中拆分出单独碱基序列后的碱基序列中的每6个碱基还原为原来的5个碱基。然后,终端设备可以将单独碱基序列与进行碱基还原得到的碱基序列进行合并,以得到待解码文件对应的初始碱基序列。In another possible implementation, during the encoding process, the terminal device may not add bases to the individual base sequence, but directly default the individual base sequence as the base sequence at the end of the initial base sequence. During the decoding process, when the number of bases corresponding to the target base sequence is not a multiple of 6, the terminal device can obtain the remainder of the number of bases corresponding to the target base sequence and 6, and split it from the end of the target base sequence The base sequence of the remainder is used as a single base sequence. At the same time, the terminal device can use the intermediate base sequence corresponding to each first preset base sequence to restore the first preset base sequence, that is, the base after splitting the individual base sequence from the target base sequence Every 6 bases in the base sequence are restored to the original 5 bases. Then, the terminal device can combine the individual base sequence with the base sequence obtained through base reduction to obtain the initial base sequence corresponding to the file to be decoded.
通过上述的解码方法,终端设备可以根据预设对应关系对待解码文件进行碱基还原,得到待解码文件对应的初始碱基序列。然后,可以根据事先构建的编码表对初始碱基序列进行解码,得到待解码文件对应的解码数据,以提高解码效率和正确性。Through the above decoding method, the terminal device can perform base restoration on the file to be decoded according to the preset corresponding relationship, and obtain the initial base sequence corresponding to the file to be decoded. Then, the initial base sequence can be decoded according to the coding table constructed in advance to obtain the decoding data corresponding to the file to be decoded, so as to improve decoding efficiency and correctness.
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that the sequence numbers of the steps in the above embodiments do not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiment of the present application.
【实施例三】[Embodiment 3]
对应于上文实施例一所述的编码方法,图10示出了本申请实施例三提供的编码装置的结构框图,为了便于说明,图10中仅示出了与本申请实施例三相关的部分。Corresponding to the encoding method described in the first embodiment above, Fig. 10 shows a structural block diagram of the encoding device provided by the third embodiment of the present application. part.
参照图10,该编码装置可以包括:Referring to Figure 10, the encoding device may include:
初始序列获取模块1001,用于获取待编码数据的初始碱基序列;An initial sequence acquisition module 1001, configured to acquire an initial base sequence of the data to be encoded;
序列分组模块1002,用于对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至少一组中间碱基序列;A sequence grouping module 1002, configured to group the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences;
编码模块1003,用于利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,所述第一预设碱基序列中包含的G与C的占比满足预设条件。An encoding module 1003, configured to replace at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded , the ratio of G and C contained in the first preset base sequence satisfies a preset condition.
示例性的,所述待编码数据为文本,所述初始序列获取模块1001,可以包括:Exemplarily, the data to be encoded is text, and the initial sequence acquisition module 1001 may include:
频率统计单元,用于统计所述文本中各字符的出现频率;A frequency statistics unit, configured to count the frequency of occurrence of each character in the text;
哈夫曼树构建单元,用于以各所述字符为叶子节点、以各所述字符的出现频率为该叶子节点的权值构建所述文本对应的四叉哈夫曼树;A Huffman tree construction unit, configured to use each of the characters as a leaf node, and use the frequency of occurrence of each of the characters as the weight of the leaf node to construct a quadruplet Huffman tree corresponding to the text;
编码表获取单元,用于将所述四叉哈夫曼树的每一条边用碱基表示,得到所述文本对应的编码表;An encoding table acquisition unit, configured to represent each edge of the quadrupled Huffman tree with a base to obtain an encoding table corresponding to the text;
初始序列确定单元,用于根据所述编码表确定所述文本对应的初始碱基序列。The initial sequence determination unit is configured to determine the initial base sequence corresponding to the text according to the coding table.
在一种可能的实现方式中,所述编码模块1003,可以包括:In a possible implementation manner, the encoding module 1003 may include:
第一替换单元,用于利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列 将至少一组所述中间碱基序列替换,得到目标碱基序列;The first replacement unit is used to replace at least one set of the intermediate base sequences with a first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain the target base sequence;
第一重复碱基获取单元,用于获取所述目标碱基序列中连续出现次数等于预设次数的重复碱基;The first repeated base obtaining unit is used to obtain repeated bases whose consecutive occurrences are equal to the preset number of times in the target base sequence;
第二替换单元,用于利用与所述重复碱基对应的第二预设碱基序列将所述重复碱基替换,得到所述待编码数据对应的编码文件。The second replacement unit is configured to replace the repeated bases with a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
具体地,所述序列分组模块1002,具体用于按照第一碱基数量对所述初始碱基序列进行分组,得到至少一组所述中间碱基序列,各所述中间碱基序列包括的碱基数量为所述第一碱基数量。Specifically, the sequence grouping module 1002 is specifically configured to group the initial base sequences according to the first number of bases to obtain at least one set of intermediate base sequences, and the bases included in each intermediate base sequence The number of bases is the first number of bases.
在一种可能的实现方式中,所述装置还可以包括:In a possible implementation manner, the device may further include:
单独序列获取模块,用于获取所述初始碱基序列中的单独碱基序列,其中,所述单独碱基序列为对所述初始碱基序列进行分组后,得到的碱基数量小于所述第一碱基数量的碱基序列;An individual sequence acquisition module, configured to acquire an individual base sequence in the initial base sequence, wherein, after grouping the initial base sequence, the number of bases obtained is less than that of the first base sequence A base sequence of one base number;
碱基添加模块,用于根据所述第一碱基数量和所述单独碱基序列对应的第二碱基数量确定需添加的第三碱基数量,并在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基。A base adding module, configured to determine the number of third bases to be added according to the number of first bases and the number of second bases corresponding to the separate base sequence, and Positions add the third number of bases.
可选的,所述碱基添加模块,还用于根据GCAT的顺序在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基。Optionally, the base addition module is further configured to add bases of the third base number at preset positions of the individual base sequence according to the order of GCAT.
示例性的,所述单独碱基序列为所述初始碱基序列头部的碱基序列或者为所述初始碱基序列尾部的碱基序列。Exemplarily, the individual base sequence is the base sequence at the head of the initial base sequence or the base sequence at the tail of the initial base sequence.
示例性的,所述预设位置为所述单独碱基序列的头部或者末尾。Exemplarily, the preset position is the head or the end of the single base sequence.
在一种可能的实现方式中,所述编码模块1003,还可以包括:In a possible implementation manner, the encoding module 1003 may further include:
第三替换单元,用于利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,并将替换后的中间碱基序列与单独碱基序列进行合并,得到目标碱基序列;The third replacement unit is used to replace at least one set of the intermediate base sequences with the first preset base sequence corresponding to at least one set of the intermediate base sequences, and replace the replaced intermediate base sequences Merge with a separate base sequence to obtain the target base sequence;
第二重复碱基获取单元,用于获取所述目标碱基序列中连续出现次数等于预设次数的重复碱基;The second repetitive base obtaining unit is used to obtain repeated bases whose consecutive occurrence times are equal to a preset number of times in the target base sequence;
第四替换单元,用于利用与所述重复碱基对应的第二预设碱基序列将所述重复碱基替换,得到所述待编码数据对应的编码文件。The fourth replacement unit is configured to replace the repeated bases with a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
其中,所述预设次数为4次,所述重复碱基与第二预设碱基序列之间的对应关系包括以下至少一种:Wherein, the preset number of times is 4 times, and the correspondence between the repeated base and the second preset base sequence includes at least one of the following:
GCATG对应GGGG;GCATG corresponds to GGGG;
GCATC对应CCCC;GCATC corresponds to CCCC;
GCATA对应AAAA;GCATA corresponds to AAAA;
GCATT对应TTTT。GCATT corresponds to TTTT.
示例性的,所述装置还可以包括:Exemplarily, the device may also include:
第一集合构建模块,用于根据所述中间碱基序列对应的第一碱基数量构建所述中间碱基序列对应的第一序列集合;A first set construction module, configured to construct a first sequence set corresponding to the intermediate base sequence according to the number of first bases corresponding to the intermediate base sequence;
碱基数量确定模块,用于根据所述第一碱基数量确定所述第一预设碱基序列对应的第四碱基数量;A base number determination module, configured to determine a fourth base number corresponding to the first preset base sequence according to the first base number;
第二集合构建模块,用于根据所述第四碱基数量构建所述第一预设碱基序列对应的第 二序列集合,所述第二序列集合中的各所述第一预设碱基序列中包含的G与C的占比满足所述预设条件;A second set construction module, configured to construct a second sequence set corresponding to the first preset base sequence according to the fourth base number, each of the first preset bases in the second sequence set The ratio of G and C included in the sequence meets the preset condition;
对应关系建立模块,用于建立所述第一序列集合中的各所述中间碱基序列与所述第二序列集合中的各所述第一预设碱基序列之间的对应关系。A correspondence relationship establishment module, configured to establish a correspondence relationship between each of the intermediate base sequences in the first sequence set and each of the first preset base sequences in the second sequence set.
可选的,所述第一碱基数量为5个,所述第四碱基数量为6个。Optionally, the number of the first bases is 5, and the number of the fourth bases is 6.
【实施例四】[Example 4]
对应于上文实施例二所述的解码方法,图11示出了本申请实施例四提供的解码装置的结构框图,为了便于说明,图11中仅示出了与本申请实施例四相关的部分。Corresponding to the decoding method described in Embodiment 2 above, FIG. 11 shows a structural block diagram of the decoding device provided in Embodiment 4 of the present application. For the convenience of description, only the components related to Embodiment 4 of the present application are shown in FIG. 11 . part.
参照图11,所述解码装置可以包括:Referring to Figure 11, the decoding device may include:
文件获取模块1101,用于获取待解码文件,所述待解码文件为基于上述实施例一中任一项所述的编码方法编码得到的文件;A file obtaining module 1101, configured to obtain a file to be decoded, the file to be decoded is a file obtained by encoding based on the encoding method described in any one of the first embodiment above;
碱基还原模块1102,用于对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱基序列;A base restoration module 1102, configured to perform base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded;
解码模块1103,用于对所述初始碱基序列进行解码,得到所述待解码文件对应的解码数据。The decoding module 1103 is configured to decode the initial base sequence to obtain decoded data corresponding to the file to be decoded.
示例性的,所述碱基还原模块1102,可以包括:Exemplarily, the base reduction module 1102 may include:
第一碱基确定单元,用于获取所述待解码文件中的第二预设碱基序列;a first base determination unit, configured to obtain a second preset base sequence in the file to be decoded;
第一还原单元,用于利用与所述第二预设碱基序列对应的重复碱基将所述第二预设碱基序列替换,得到所述待解码文件对应的目标碱基序列;a first reduction unit, configured to replace the second preset base sequence with repeated bases corresponding to the second preset base sequence, to obtain a target base sequence corresponding to the file to be decoded;
序列获取单元,用于获取所述目标碱基序列中的第一预设碱基序列;a sequence obtaining unit, configured to obtain a first preset base sequence in the target base sequence;
第二还原单元,用于利用与所述第一预设碱基序列对应的中间碱基序列将所述第一预设碱基序列替换,得到所述待解码文件对应的初始碱基序列。The second restoring unit is configured to use an intermediate base sequence corresponding to the first preset base sequence to replace the first preset base sequence to obtain an initial base sequence corresponding to the file to be decoded.
需要说明的是,上述装置/单元之间的信息交互、执行过程等内容,由于与本申请方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。It should be noted that the information interaction and execution process between the above-mentioned devices/units are based on the same concept as the method embodiment of the present application, and its specific functions and technical effects can be found in the method embodiment section. I won't repeat them here.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本申请的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used for illustration. In practical applications, the above-mentioned functions can be assigned to different functional units, Completion of modules means that the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment may be integrated into one processing unit, or each unit may exist separately physically, or two or more units may be integrated into one unit, and the above-mentioned integrated units may adopt hardware It can also be implemented in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the present application. For the specific working process of the units and modules in the above system, reference may be made to the corresponding process in the foregoing method embodiments, and details will not be repeated here.
图12为本申请一实施例提供的终端设备的结构示意图。如图12所示,该实施例的终端设备12包括:至少一个处理器1200(图12中仅示出一个)、存储器1201以及存储在所述存储器1201中并可在所述至少一个处理器1200上运行的计算机程序1202,所述处理器1200执行所述计算机程序1202时实现上述任意各个文本编码方法实施例或者文本解码方法实施例中的步骤。FIG. 12 is a schematic structural diagram of a terminal device provided by an embodiment of the present application. As shown in FIG. 12 , the terminal device 12 of this embodiment includes: at least one processor 1200 (only one is shown in FIG. 12 ), a memory 1201 and stored in the memory 1201 and can be used in the at least one processor 1200 A computer program 1202 running on the computer, when the processor 1200 executes the computer program 1202, the steps in any of the foregoing text encoding method embodiments or text decoding method embodiments are implemented.
所述终端设备12可以是桌上型计算机、笔记本、掌上电脑等计算设备。该终端设备可 包括,但不仅限于,处理器1200、存储器1201。本领域技术人员可以理解,图12仅仅是终端设备12的举例,并不构成对终端设备12的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如还可以包括输入输出设备、网络接入设备等。The terminal device 12 may be a computing device such as a desktop computer, a notebook, or a palmtop computer. The terminal device may include, but not limited to, a processor 1200 and a memory 1201. Those skilled in the art can understand that FIG. 12 is only an example of the terminal device 12, and does not constitute a limitation on the terminal device 12. It may include more or less components than those shown in the figure, or combine certain components, or different components. , for example, may also include input and output devices, network access devices, and so on.
所述处理器1200可以是中央处理单元(central processing unit,CPU),该处理器1200还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field-programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 1200 can be a central processing unit (central processing unit, CPU), and the processor 1200 can also be other general processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuits) , ASIC), field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
所述存储器1201在一些实施例中可以是所述终端设备12的内部存储单元,例如终端设备12的硬盘或内存。所述存储器1201在另一些实施例中也可以是所述终端设备12的外部存储设备,例如所述终端设备12上配备的插接式硬盘,智能存储卡(smart media card,SMC),安全数字(secure digital,SD)卡,闪存卡(flash card)等。进一步地,所述存储器1201还可以既包括所述终端设备12的内部存储单元也包括外部存储设备。所述存储器1201用于存储操作系统、应用程序、引导装载程序(BootLoader)、数据以及其他程序等,例如所述计算机程序的程序代码等。所述存储器1201还可以用于暂时地存储已经输出或者将要输出的数据。The storage 1201 may be an internal storage unit of the terminal device 12 in some embodiments, such as a hard disk or a memory of the terminal device 12 . The memory 1201 may also be an external storage device of the terminal device 12 in other embodiments, such as a plug-in hard disk equipped on the terminal device 12, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, flash memory card (flash card), etc. Further, the memory 1201 may also include both an internal storage unit of the terminal device 12 and an external storage device. The memory 1201 is used to store operating systems, application programs, bootloader programs (BootLoader), data and other programs, such as program codes of the computer programs. The memory 1201 can also be used to temporarily store data that has been output or will be output.
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时可实现上述各个方法实施例中的步骤。The embodiment of the present application also provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the foregoing method embodiments can be implemented.
本申请实施例提供了一种计算机程序产品,当计算机程序产品在终端设备上运行时,使得终端设备执行时可实现上述各个方法实施例中的步骤。An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can implement the steps in the foregoing method embodiments when executed.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读存储介质至少可以包括:能够将计算机程序代码携带到装置/终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(read-only memory,ROM,)、随机存取存储器(random access memory,RAM,)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。在某些司法管辖区,根据立法和专利实践,计算机可读存储介质不可以是电载波信号和电信信号。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the procedures in the methods of the above embodiments in the present application can be completed by instructing related hardware through computer programs, and the computer programs can be stored in a computer-readable storage medium. The computer program When executed by a processor, the steps in the above-mentioned various method embodiments can be realized. Wherein, the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form. The computer-readable storage medium may at least include: any entity or device capable of carrying computer program codes to the device/terminal device, recording medium, computer memory, read-only memory (read-only memory, ROM, ), random access Memory (random access memory, RAM), electrical carrier signals, telecommunication signals, and software distribution media. Such as U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, computer readable storage media may not be electrical carrier signals and telecommunication signals based on legislation and patent practice.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the descriptions of each embodiment have their own emphases, and for parts that are not detailed or recorded in a certain embodiment, refer to the relevant descriptions of other embodiments.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can appreciate that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present application.
在本申请所提供的实施例中,应该理解到,所揭露的装置/终端设备和方法,可以通过其它的方式实现。例如,以上所描述的装置/终端设备实施例仅仅是示意性的,例如,所述 模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通讯连接可以是通过一些接口,装置或单元的间接耦合或通讯连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the device/terminal device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units Or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: it can still implement the foregoing embodiments Modifications to the technical solutions described in the examples, or equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the various embodiments of the application, and should be included in the Within the protection scope of this application.

Claims (18)

  1. 一种编码方法,其特征在于,包括:An encoding method, characterized in that it comprises:
    获取待编码数据的初始碱基序列;Obtain the initial base sequence of the data to be encoded;
    对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至少一组中间碱基序列;grouping the initial base sequences to obtain at least one group of intermediate base sequences corresponding to the initial base sequences;
    利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,所述第一预设碱基序列中包含的G与C的占比满足预设条件。Replace at least one set of the intermediate base sequences with a first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain an encoding file corresponding to the data to be encoded, the first preset It is assumed that the ratio of G and C included in the base sequence satisfies a preset condition.
  2. 如权利要求1所述的方法,其特征在于,所述待编码数据为文本,所述获取所述待编码数据的初始碱基序列,包括:The method according to claim 1, wherein the data to be encoded is text, and the obtaining the initial base sequence of the data to be encoded comprises:
    统计所述文本中各字符的出现频率;Count the occurrence frequency of each character in the text;
    以各所述字符为叶子节点、以各所述字符的出现频率为该叶子节点的权值构建所述文本对应的四叉哈夫曼树;Constructing a quadrangle Huffman tree corresponding to the text with each of the characters as a leaf node and the frequency of occurrence of each of the characters as the weight of the leaf node;
    将所述四叉哈夫曼树的每一条边用碱基表示,得到所述文本对应的编码表;Representing each edge of the four-fork Huffman tree with a base to obtain a code table corresponding to the text;
    根据所述编码表确定所述文本的初始碱基序列。The initial base sequence of the text is determined according to the coding table.
  3. 如权利要求1所述的方法,其特征在于,所述利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,包括:The method according to claim 1, characterized in that, replacing at least one set of the intermediate base sequences with a first preset base sequence corresponding to at least one set of the intermediate base sequences to obtain The encoding file corresponding to the data to be encoded includes:
    利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到目标碱基序列;replacing at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain a target base sequence;
    获取所述目标碱基序列中连续出现次数等于预设次数的重复碱基;Obtaining repeated bases whose number of consecutive occurrences is equal to a preset number of times in the target base sequence;
    利用与所述重复碱基对应的第二预设碱基序列将所述重复碱基替换,得到所述待编码数据对应的编码文件。The repeated bases are replaced by a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
  4. 如权利要求1所述的方法,其特征在于,所述对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至少一组中间碱基序列,包括:The method according to claim 1, wherein the grouping of the initial base sequences to obtain at least one group of intermediate base sequences corresponding to the initial base sequences comprises:
    按照第一碱基数量对所述初始碱基序列进行分组,得到至少一组所述中间碱基序列,各所述中间碱基序列包括的碱基数量为所述第一碱基数量。The initial base sequences are grouped according to the first number of bases to obtain at least one group of the intermediate base sequences, and the number of bases included in each of the intermediate base sequences is the first number of bases.
  5. 如权利要求4所述的方法,其特征在于,所述方法还包括:The method of claim 4, further comprising:
    获取所述初始碱基序列中的单独碱基序列,其中,所述单独碱基序列为对所述初始碱基序列进行分组后,得到的碱基数量小于所述第一碱基数量的碱基序列;Obtaining an individual base sequence in the initial base sequence, wherein the individual base sequence is a base whose number of bases is less than the first number of bases after grouping the initial base sequence sequence;
    根据所述第一碱基数量和所述单独碱基序列对应的第二碱基数量确定需添加的第三碱基数量,并在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基。Determine the number of third bases to be added according to the number of first bases and the number of second bases corresponding to the separate base sequence, and add the third base at a preset position of the separate base sequence base number of bases.
  6. 如权利要求5所述的方法,其特征在于,所述在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基,包括:The method according to claim 5, wherein said adding the third number of bases at the preset position of said individual base sequence comprises:
    根据GCAT的顺序在所述单独碱基序列的预设位置添加所述第三碱基数量的碱基。adding the third number of bases at preset positions of the individual base sequence according to the order of GCAT.
  7. 如权利要求5所述的方法,其特征在于,所述单独碱基序列为所述初始碱基序列头部的碱基序列或者为所述初始碱基序列尾部的碱基序列。The method according to claim 5, wherein the single base sequence is a base sequence at the head of the initial base sequence or a base sequence at the tail of the initial base sequence.
  8. 如权利要求5所述的方法,其特征在于,所述预设位置为所述单独碱基序列的头部或者末尾。The method according to claim 5, wherein the preset position is the head or the end of the single base sequence.
  9. 如权利要求5至8中任一项所述的方法,其特征在于,所述利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,包括:The method according to any one of claims 5 to 8, wherein said at least one group of said intermediate base sequences is converted into a The base sequence is replaced to obtain the encoding file corresponding to the data to be encoded, including:
    利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,并将替换后的中间碱基序列与单独碱基序列进行合并,得到目标碱基序列;Replace at least one set of the intermediate base sequences with the first preset base sequence corresponding to at least one set of the intermediate base sequences one-to-one, and merge the replaced intermediate base sequence with the separate base sequence , to obtain the target base sequence;
    获取所述目标碱基序列中连续出现次数等于预设次数的重复碱基;Obtaining repeated bases whose number of consecutive occurrences is equal to a preset number of times in the target base sequence;
    利用与所述重复碱基对应的第二预设碱基序列将所述重复碱基替换,得到所述待编码数据对应的编码文件。The repeated bases are replaced by a second preset base sequence corresponding to the repeated bases to obtain an encoding file corresponding to the data to be encoded.
  10. 如权利要求9所述的方法,其特征在于,所述预设次数为4次,所述重复碱基与第二预设碱基序列之间的对应关系包括以下至少一种:The method according to claim 9, wherein the preset number of times is 4, and the correspondence between the repeated base and the second preset base sequence includes at least one of the following:
    GCATG对应GGGG;GCATG corresponds to GGGG;
    GCATC对应CCCC;GCATC corresponds to CCCC;
    GCATA对应AAAA;GCATA corresponds to AAAA;
    GCATT对应TTTT。GCATT corresponds to TTTT.
  11. 如权利要求1至8中任一项所述的方法,其特征在于,所述方法,还包括:The method according to any one of claims 1 to 8, wherein said method further comprises:
    根据所述中间碱基序列对应的第一碱基数量构建所述中间碱基序列对应的第一序列集合;constructing a first sequence set corresponding to the intermediate base sequence according to the number of first bases corresponding to the intermediate base sequence;
    根据所述第一碱基数量确定所述第一预设碱基序列对应的第四碱基数量;determining a fourth base number corresponding to the first preset base sequence according to the first base number;
    根据所述第四碱基数量构建所述第一预设碱基序列对应的第二序列集合,所述第二序列集合中的各所述第一预设碱基序列中包含的G与C的占比满足所述预设条件;The second sequence set corresponding to the first preset base sequence is constructed according to the fourth base number, and the G and C contained in each of the first preset base sequences in the second sequence set The proportion satisfies the preset conditions;
    建立所述第一序列集合中的各所述中间碱基序列与所述第二序列集合中的各所述第一预设碱基序列之间的对应关系。Establishing a correspondence between each of the intermediate base sequences in the first sequence set and each of the first preset base sequences in the second sequence set.
  12. 如权利要求11所述的方法,其特征在于,所述第一碱基数量为5个,所述第四碱基数量为6个。The method according to claim 11, wherein the number of the first bases is 5, and the number of the fourth bases is 6.
  13. 一种解码方法,其特征在于,包括:A decoding method, characterized in that, comprising:
    获取待解码文件,所述待解码文件为基于权利要求1至12中任一项所述的编码方法编码得到的文件;Obtaining a file to be decoded, the file to be decoded is a file encoded based on the encoding method described in any one of claims 1 to 12;
    对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱基序列;performing base reduction on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded;
    对所述初始碱基序列进行解码,得到所述待解码文件对应的解码数据。Decoding the initial base sequence to obtain decoded data corresponding to the file to be decoded.
  14. 如权利要求13所述的方法,其特征在于,所述对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱基序列,包括:The method according to claim 13, wherein said performing base reduction on said file to be decoded to obtain an initial base sequence corresponding to said file to be decoded comprises:
    获取所述待解码文件中的第二预设碱基序列;Obtain the second preset base sequence in the file to be decoded;
    利用与所述第二预设碱基序列对应的重复碱基将所述第二预设碱基序列替换,得到所述待解码文件对应的目标碱基序列;replacing the second preset base sequence with repeated bases corresponding to the second preset base sequence to obtain a target base sequence corresponding to the file to be decoded;
    获取所述目标碱基序列中的第一预设碱基序列;Obtaining the first preset base sequence in the target base sequence;
    利用与所述第一预设碱基序列对应的中间碱基序列将所述第一预设碱基序列替换,得到所述待解码文件对应的初始碱基序列。replacing the first preset base sequence with an intermediate base sequence corresponding to the first preset base sequence to obtain an initial base sequence corresponding to the file to be decoded.
  15. 一种编码装置,其特征在于,包括:An encoding device, characterized in that it comprises:
    初始序列获取模块,用于获取待编码数据的初始碱基序列;The initial sequence acquisition module is used to obtain the initial base sequence of the data to be encoded;
    序列分组模块,用于对所述初始碱基序列进行分组,得到所述初始碱基序列对应的至 少一组中间碱基序列;A sequence grouping module, configured to group the initial base sequences to obtain at least one set of intermediate base sequences corresponding to the initial base sequences;
    编码模块,用于利用与至少一组所述中间碱基序列一一对应的第一预设碱基序列将至少一组所述中间碱基序列替换,得到所述待编码数据对应的编码文件,所述第一预设碱基序列中包含的G与C的占比满足预设条件。An encoding module, configured to replace at least one set of intermediate base sequences with a first preset base sequence corresponding to at least one set of intermediate base sequences to obtain an encoding file corresponding to the data to be encoded, The ratio of G and C contained in the first preset base sequence satisfies a preset condition.
  16. 一种解码装置,其特征在于,包括:A decoding device, characterized in that it comprises:
    文件获取模块,用于获取待解码文件,所述待解码文件为基于权利要求1至12中任一项所述的编码方法编码得到的文件;A file acquisition module, configured to acquire a file to be decoded, the file to be decoded is a file encoded based on the encoding method described in any one of claims 1 to 12;
    碱基还原模块,用于对所述待解码文件进行碱基还原,得到所述待解码文件对应的初始碱基序列;A base restoration module, configured to perform base restoration on the file to be decoded to obtain an initial base sequence corresponding to the file to be decoded;
    解码模块,用于对所述初始碱基序列进行解码,得到所述待解码文件对应的解码数据。A decoding module, configured to decode the initial base sequence to obtain decoded data corresponding to the file to be decoded.
  17. 一种终端设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至12,或者13至14中任一项所述的方法。A terminal device, comprising a memory, a processor, and a computer program stored in the memory and operable on the processor, characterized in that, when the processor executes the computer program, the following claims 1 to 1 are implemented. 12, or the method described in any one of 13 to 14.
  18. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至12,或者13至14中任一项所述的方法。A computer-readable storage medium, the computer-readable storage medium stores a computer program, characterized in that, when the computer program is executed by a processor, the computer program according to any one of claims 1 to 12 or 13 to 14 is implemented. described method.
PCT/CN2021/103179 2021-06-29 2021-06-29 Encoding method, decoding method, apparatus, terminal device, and readable storage medium WO2023272499A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/103179 WO2023272499A1 (en) 2021-06-29 2021-06-29 Encoding method, decoding method, apparatus, terminal device, and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/103179 WO2023272499A1 (en) 2021-06-29 2021-06-29 Encoding method, decoding method, apparatus, terminal device, and readable storage medium

Publications (1)

Publication Number Publication Date
WO2023272499A1 true WO2023272499A1 (en) 2023-01-05

Family

ID=84689820

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/103179 WO2023272499A1 (en) 2021-06-29 2021-06-29 Encoding method, decoding method, apparatus, terminal device, and readable storage medium

Country Status (1)

Country Link
WO (1) WO2023272499A1 (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101200763A (en) * 2007-11-13 2008-06-18 东南大学 Coding and decoding method for determined nucleic acid sequence
US20170116372A1 (en) * 2015-10-27 2017-04-27 International Business Machines Corporation Using machine-learning to perform linear regression on a dna-computing platform
CN106845158A (en) * 2017-02-17 2017-06-13 苏州泓迅生物科技股份有限公司 A kind of method that information Store is carried out using DNA
CN108629157A (en) * 2017-03-22 2018-10-09 深圳华大基因科技服务有限公司 One kind being used for nucleic acid sequencing data compression and encrypted method
CN111443869A (en) * 2020-03-24 2020-07-24 中国科学院长春应用化学研究所 File storage method, device, equipment and computer readable storage medium
US10917109B1 (en) * 2020-03-06 2021-02-09 Centre National De La Recherche Scientifique Methods for storing digital data as, and for transforming digital data into, synthetic DNA
CN112582030A (en) * 2020-12-18 2021-03-30 广州大学 Text storage method based on DNA storage medium
CN112749247A (en) * 2019-10-31 2021-05-04 中国科学院深圳先进技术研究院 Text information storage and reading method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101200763A (en) * 2007-11-13 2008-06-18 东南大学 Coding and decoding method for determined nucleic acid sequence
US20170116372A1 (en) * 2015-10-27 2017-04-27 International Business Machines Corporation Using machine-learning to perform linear regression on a dna-computing platform
CN106845158A (en) * 2017-02-17 2017-06-13 苏州泓迅生物科技股份有限公司 A kind of method that information Store is carried out using DNA
CN108629157A (en) * 2017-03-22 2018-10-09 深圳华大基因科技服务有限公司 One kind being used for nucleic acid sequencing data compression and encrypted method
CN112749247A (en) * 2019-10-31 2021-05-04 中国科学院深圳先进技术研究院 Text information storage and reading method and device
US10917109B1 (en) * 2020-03-06 2021-02-09 Centre National De La Recherche Scientifique Methods for storing digital data as, and for transforming digital data into, synthetic DNA
CN111443869A (en) * 2020-03-24 2020-07-24 中国科学院长春应用化学研究所 File storage method, device, equipment and computer readable storage medium
CN112582030A (en) * 2020-12-18 2021-03-30 广州大学 Text storage method based on DNA storage medium

Similar Documents

Publication Publication Date Title
WO2022120912A1 (en) Coding method and device, decoding method and device, and computer-readable storage medium
CN113539370B (en) Encoding method, decoding method, device, terminal device and readable storage medium
Deorowicz et al. Data compression for sequencing data
Phoophakdee et al. Genome-scale disk-based suffix tree indexing
JP2019537172A (en) Method and system for indexing bioinformatics data
US10453559B2 (en) Method and system for rapid searching of genomic data and uses thereof
US20130166518A1 (en) Compression Of Genomic Data File
CN111046034A (en) Method and system for managing memory data and maintaining data in memory
CN109299086B (en) Optimal sort key compression and index reconstruction
US8972200B2 (en) Compression of genomic data
WO2023109711A1 (en) Data storage method and apparatus, and terminal device and computer-readable storage medium
CN112885412B (en) Genome annotation method, apparatus, visualization platform and storage medium
Wang et al. CHTKC: a robust and efficient k-mer counting algorithm based on a lock-free chaining hash table
CN113744804A (en) Method and device for storing data by using DNA and storage equipment
Karasikov et al. Sparse binary relation representations for genome graph annotation
CN113826168A (en) Flexible seed extension for hashtable genome mapping
Cracco et al. Extremely fast construction and querying of compacted and colored de Bruijn graphs with GGCAT
WO2023272499A1 (en) Encoding method, decoding method, apparatus, terminal device, and readable storage medium
WO2022120626A1 (en) Dna-based data storage method and apparatus, dna-based data recovery method and apparatus, and terminal device
White et al. Compressing DNA sequence databases with coil
US20230230659A1 (en) Biological sequence compression using sequence alignment
Huo et al. CS2A: A compressed suffix array-based method for short read alignment
US11101018B2 (en) Encoding and decoding of RNA data
CN111158994B (en) Method and device for testing pressing performance
CN110309367B (en) Information classification method, information processing method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21947457

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE