Data compression method and apparatus

The data compression method employing code trees and context modeling in VLE addresses the need for high-speed and low-memory data compression for genome data, achieving superior performance in compression ratio and speed compared to existing techniques.

WO2024186229A1PCT designated stage expired Publication Date: 2024-09-12HUAWEI TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
PCT/RU2023/000065
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-03-09
Publication Date
2024-09-12

Smart Images

  • Figure RU2023000065_12092024_PF_FP_ABST
    Figure RU2023000065_12092024_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data compression method and an apparatus. The data compression method includes: obtaining data to be compressed, the data to be compressed being a sequence consisting of P symbols, the P symbols including N different symbols; and constructing a context table based on the data to be compressed, the context table including multiple contexts, and each of the contexts including M symbols, the M symbols including at least one of the N different symbols; and determining code trees corresponding to each of the contexts in the context table, with the code trees including encodings for the N different symbols; and compressing the data to be compressed according to the context table and the code trees. The data compression method provided in the present application improves the compression speed and reduces memory consumption.
Need to check novelty before this filing date? Find Prior Art

Description

DATA COMPRESSION METHOD AND APPARATUSTECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of data processing, and more specifically, to a data compression method and apparatus.BACKGROUND

[0002] Nowadays, in the age of massive information, people are constantly generating information, exchanging information, and using information every day. In this era of increasing data volume, there is also a higher demand for data storage space. Data compression technology not only allows for more efficient storage of this data information but also enables the transmission of this data. Therefore, in the context of limited storage space in today's world, data compression technology is of great importance in reducing the amount of information stored and making effective use of storage space.

[0003] With the rapid development of molecular biotechnology, the study of a genome sequence is particularly important in various fields of bioinformatics and is one of the important research objects. Small alphabet data and especially genome data grows very fast. Because of it, the compression methods for such data are very important. However, in addition to a compression ratio, the speed and memory consumption should also be taken into account.

[0004] Therefore, how to construct a data compression algorithm with high speed and low memory consumption is an urgent technical problem to be solved.SUMMARY

[0005] Embodiments of the present application provide a data compression method and apparatus. The present application uses a special combination of code trees and context modeling to encode symbols in Variable Length Coding (VLE) instead of using arithmetic encoding, which can improve compression speed and reduce memory consumption. i

[0006] According to a first aspect, an embodiment of the present application provides a data compression method including: obtaining data to be compressed, the data to be compressed being a sequence consisting of P symbols, the P symbols including N different symbols, with N being an integer greater than or equal to 1 ; and constructing a context table based on the data to be compressed, the context table including multiple contexts, and each of the contexts including M symbols, the M symbols including at least one of the N different symbols, with M being an integer greater than 1; and determining code trees corresponding to each of the contexts in the context table, with the code trees including encodings for the N different symbols; and compressing the data to be compressed according to the context table and the code trees.

[0007] The data to be compressed is a sequence of length P consisting of N different symbols, P being an integer greater than or equal to N. In some possible embodiments, the data to be compressed is a bioinformatics file containing P bases, with the P bases including N types.

[0008] In some possible implementations, the code trees may be Huffman trees or may also be other types of trees, and the present application does not limit the specific type of code trees.

[0009] The data compression method provided by the present application uses a special combination of code trees and context modeling to encode symbols in the VLE, which can increase the speed of compression and reduce memory consumption.

[0010] In one possible implementation, the context table includes NMcontexts.

[0011] A context table is a massive block with NMcontexts, each corresponding to N counters since the method can provide NMdifferent contexts. It should be understood that N refers to the variety of symbols in the data to be compressed, while M refers to the number of symbols contained in a context.

[0012] The data compression method provided by the present application uses a special combination of code trees and context modeling to encode symbols in the VLE, which can increase the speed of compression and reduce memory consumption.

[0013] In one possible implementation, a first context corresponds to N counters, and the N counters are in one-to-one correspondence with the N different symbols, and each of the N counters represents the number of occurrences of a corresponding symbol after the first context in the data to be compressed, and the first context is any one of the contexts in the context table.

[0014] For example, for genomic data (4 bases), a context table of M=2 is a massive blockwith 42contexts, each context corresponding to 4 counters, and each counter being 1 or 2 bytes.

[0015] Exemplarily, N=4, M=2, and the nthcontext in the context table is “AT”. The A counter represents the frequency of base A after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATA” in the data to be compressed. The C counter represents the frequency of base C after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATC” in the data to be compressed. The G counter represents the frequency of base G after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATG” in the data to be compressed. The T counter represents the frequency of base T after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATT” in the data to be compressed. The method provided in the present application compresses only the letter that follows the context. For example, in the example “ATA”, “AT” is a context used to observe the letter “A”. The method only compresses “A”.

[0016] The data compression method provided by the present application uses a special combination of code trees and context modeling to encode symbols in the VLE, which can increase the speed of compression and reduce memory consumption.

[0017] In one possible implementation, N=4O

[0018] In one possible implementation, the determining code trees corresponding to each of the contexts in the context table includes: if the sum of a first counter and a second counter is greater than a third counter, determining that a first code tree has a 3 -level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context; or if the sum of a first counter and a second counter is less than or equal to a third counter, determining that a first code tree has a 2-level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context.

[0019] For example, the data to be compressed is a sequence of length P, consisting of four different base symbols. The four base symbols are A, T, C and G. Each context corresponds to 4 counters. First sort the 4 counters in each context. Taking the nthcontext in NMas an example, max represents the maximum value among the 4 counters, mid represents the second largest value among the 4 counters, mini represents the second smallest value among the 4 counters, and min2 represents the smallest value among the 4 counters. The first counter is min2. The second counter is mini . The third counter is max. For example, A appears 200 times, C appears 100 times, G appears 30 times, and T appears 10 times, which means that the base corresponding to the max is A, the base corresponding to mid is C, the base corresponding to mini is G, and the base corresponding to min2 is T.

[0020] If max<minl+min2, a code tree with a 2-2-2-2 structure is constructed. A, T, C, and G are located at the second level of the code tree, where the binary code of A is 00, the binary code of C is 01, the binary code of G is 10, and the binary code of T is 11. It should be understood that the binary codes of A, T, C, and G are not fixed and can be mutually exchanged, e.g., the binary code of A is 01 and the binary code of C is 00.

[0021] If max>minl+min2, a code tree with a 1-2-3 -3 structure is constructed. The base corresponding to the max is located in the first level of the code tree, the base corresponding to the mid is located in the second level of the code tree, and the bases corresponding to mini and min2 are located in the third level of the code tree.

[0022] The data compression method provided by the present application uses a special combination of code trees and context modeling to encode symbols in the VLE, which can increase the speed of compression and reduce memory consumption.

[0023] In one possible implementation, a second code tree is stored by 4 bits, and the second code tree is a code tree corresponding to any one of the contexts in the context table.

[0024] The code tree with a 2-2-2-2 structure includes 1 variant tree, and the code tree with a 1-2-3 -3 structure includes 12 variant trees. Therefore, instead of storing counters for each context, this application embodiment only needs to store variant trees for each context. In order to store 13 different variants, 4 bits are needed, since 23< 13 < 24. In the classical approach for each context, it is needed to store at least 1 byte for each base and 4 bytes for each context.

[0025] The encoding of contexts is described by a tree. Based on the context table, themethod provided in this application creates a tree for each context, the method only needs to store the number of the tree.

[0026] The data compression method provided by the present application uses a special combination of code trees and context modeling to encode symbols in the VLE, which can increase the speed of compression and reduce memory consumption.

[0027] In one possible implementation, the data to be compressed includes genomic data.

[0028] The present application uses a special combination of code trees and context modeling to encode symbols in VLE instead of using arithmetic encoding. Due to the small letter size of the genomic data, this allows the method provided by this application to create code trees and encode them with a small number of bits.

[0029] The lower size of the context table and faster compression and decompression speed provides an ability to use this algorithm in fast encoding schemes for both genome data and data with a low alphabet size. The encoding of the context corresponding to data of a low letter size may not be the 13 variant trees described above, for example, it may be smaller or larger than the 13 variant trees. However, the process of determining the codes corresponding to the contexts of data containing different numbers of alphabets is similar to the process of determining the codes corresponding to the contexts of genetic data, and it is sufficient to construct variant trees according to the construction method of code trees. The number of variant trees varies, and the corresponding amount of bits needed may vary.

[0030] According to a second aspect, an embodiment of the present application provides an electronic apparatus, including an obtaining module configured to obtain data to be compressed, the data to be compressed being a sequence consisting of P symbols, the P symbols including N different symbols, with N being an integer greater than or equal to 1 ; a processing module configured to construct a context table based on the data to be compressed, the context table including multiple contexts, and each of the contexts including M symbols, the M symbols including at least one of the N different symbols, with M being an integer greater than 1 ; the processing module is further configured to determine code trees corresponding to each of the contexts in the context table, with the code trees including encodings for the N different symbols; the processing module is further configured to compress the data to be compressed according to the context table and the code trees.

[0031] In some possible implementations, the code trees may be Huffman trees or may also be other types of trees, and the present application does not limit the specific type of code trees.

[0032] In a possible design, the context table includes NMcontexts.

[0033] In a possible design, a first context corresponds to N counters, and the N counters are in one-to-one correspondence with the N different symbols, and each of the N counters represents the number of occurrences of a corresponding symbol after the first context in the data to be compressed, and the first context is any one of the contexts in the context table.

[0034] In a possible design, N=4.

[0035] In a possible design, the processing module is specifically configured to: if the sum of a first counter and a second counter is greater than a third counter, determine that a first code tree has a 3 -level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context; or if the sum of a first counter and a second counter is less than or equal to a third counter, determine that a first code tree has a 2-level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context.

[0036] In a possible design, a second code tree is stored by 4 bits, and the second code tree is a code tree corresponding to any one of the contexts in the context table.

[0037] In a possible design, the data to be compressed includes genomic data.

[0038] The beneficial effects of the second aspect and any of the possible implementations of the second aspect correspond to the beneficial effects of the first aspect and any of the possible implementations of the first aspect, to which there is no further elaboration.

[0039] According to a third aspect, an embodiment of the present application provides an electronic device, including a function of implementing the method in the first aspect. The function may be implemented by a hardware, or may be implemented by the hardware executing a corresponding software. The hardware of the software includes one or moremodules corresponding to the function.

[0040] According to a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having instructions which, when run on a computer, the computer is caused to perform the method in the first aspect or any possible implementation manners of the first aspect.

[0041] According to a fifth aspect, there is provided an electronic device, including a processor and a memory. The processor is connected to the memory, the memory is configured to store instructions, and the processor is configured to execute the instructions. When the processor executes the instructions stored in the memory, the processor is caused to perform the method in the first aspect or any possible implementation manners of the first aspect.

[0042] According to a sixth aspect, there is provided a chip system, including a memory and a processor, where the memory is configured to store a computer program, and the processor is configured to invoke the computer program from the memory and run the computer program, so that a server on which a chip is disposed performs the method in the first aspect or any possible implementation manners of the first aspect.

[0043] According to a seventh aspect, there is provided a computer program product which, when run on an electronic device, the electronic device is caused to perform the method in the first aspect or any possible implementation manners of the first aspect.DESCRIPTION OF DRAWINGS

[0044] FIG. 1 is a schematic diagram of a FASTQ file according to an embodiment of the present application.

[0045] FIG. 2 is a flowchart of an embodiment of a data compression method 200 according to an embodiment of the present application.

[0046] FIG. 3 is a flowchart of an embodiment of a data compression method 300 according to an embodiment of the present application.

[0047] FIG. 4 is a schematic diagram of a context table according to an embodiment of the present application.

[0048] FIG. 5 is a schematic diagram of the creation of a code tree according to anembodiment of the present application.

[0049] FIG. 6 is a schematic diagram of the numbering of trees corresponding to a context table according to an embodiment of the present application.

[0050] FIG. 7 is a comparative schematic diagram of four algorithms for compressing data according to an embodiment of the present application.

[0051] FIG. 8 is a comparative schematic diagram of four algorithms for decompressing data according to an embodiment of the present application.

[0052] FIG. 9 is a schematic diagram of a classical statistical compression algorithm.

[0053] FIG. 10 is a schematic block diagram of an electronic apparatus 1000 according to an embodiment of the present application.

[0054] FIG. 11 is a schematic block diagram of an electronic device 1100 according to an embodiment of the present application.DESCRIPTION OF EMBODIMENTS

[0055] The following describes the technical solutions in the present application with reference to the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without making creative labor shall fall within the scope of protection of the present application.

[0056] The present application will present aspects, embodiments, or features around systems that include multiple devices, components, modules, etc. It should be understood and appreciated that the individual systems may include additional devices, components, modules, etc., and / or may not include all of the devices, components, modules, etc. discussed in connection with the accompanying drawings. In addition, combinations of these options may be used.

[0057] In addition, in the embodiments of the present application, the word “exemplarily” and the phrase “as an example” are used to indicate for example, illustration or description. Any embodiment or design solution described as “exemplarily” in this application should not beconstrued as being superior to or more advantageous than other embodiments or design solutions. Rather, the use of the word “example” is intended to present the concept in a specific manner.

[0058] The phrases “in some possible embodiments”, “in some possible application scenarios”, etc., appearing in various places in this description, do not necessarily refer to the same embodiments, but rather mean “one or more, but not all, embodiments” unless otherwise specifically emphasized. Unless otherwise specifically emphasized, the terms “including”, “comprising”, “having”, and variations thereof all mean “including but not limited to”.

[0059] In the present application, “at least one” refers to one or more, and “multiple” refers to two or more, “and / or”, describing the association of the associated objects, indicates that three relationships can exist. For example, A and / or B can mean A alone, both A and B, and B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following associated objects are in an “or” relationship.

[0060] The application scenarios described in the present application embodiments are intended to illustrate the technical solutions of the present application embodiments more clearly and do not constitute a limitation to the technical solutions provided by the present application embodiments. It is known to those of ordinary skill in the art that the technical solutions provided by the present application embodiments are equally applicable to similar technical problems as the system architecture evolves and new application scenarios emerge.

[0061] In order to better describe the solutions of embodiments in the present application, concepts and terms that may be involved in the present application will be described below.

[0062] (1) Data compression

[0063] The process of reducing the size of a data block or file.

[0064] (2) Compression ratio

[0065] A data compression ratio is a measurement of the relative reduction in the size of data representation produced by a data compression algorithm. Compression ratio is typically expressed as the division of uncompressed size by compressed size.

[0066] (3) Typical compression

[0067] A typical compression means a set of general compression algorithms and approaches being applied in data compression.

[0068] (4) LZ

[0069] Compression algorithms proposed by Lempel-Ziv, e.g. LZ77.

[0070] (5) BWT

[0071] The Burrows-Wheeler transform (BWT, also called block-sorting compression) rearranges a character string into runs of similar characters.

[0072] (6) VLE

[0073] In coding theory, a variable-length code is a code that maps source symbols to a variable number of bits.

[0074] The compression method provided by this application can achieve a more efficient compression ratio with high speed when compressing data with a small alphabet, particularly for genome data which consists of four symbols.

[0075] With the rapid development of molecular biotechnology, the study of genome sequence is particularly important in various fields of bioinformatics and is one of the important research objects. Deoxyribonucleic acid (DNA) consists of four base types: adenine (A), thymine (T), cytosine (C), and guanine (G). FASTQ files are widely used in genome sequencing. FASTQ format is a text-based format for storing both a biological sequence (usually base sequence) and its corresponding quality scores.

[0076] FIG. 1 is a schematic diagram of a FASTQ file according to an embodiment of the present application.

[0077] Each of 4 lines in the FASTQ file represents a sequence. The first line records information about instrument used for sequencing and coordinates in a sequencing channel starting with @. The second line represents sequence information of the sequence and is denoted by symbols A, T, C, and G. The third line is a nonsense line, usually indicated by “+”. The fourth line corresponds to the second line of base information one by one, storing the quality values of the sequenced bases, and represented by ASCII characters. Genome data consists of only four symbols A, C, T, and G which are presented in a UTF-8 code by default.

[0078] FIG. 2 is a flowchart of an embodiment of a data compression method 200 according to an embodiment of the present application. The method shown in FIG. 2 can be executed by cloud service devices or terminal devices, such as computers, servers, and other devices with sufficient computing resources to execute calculations of data compression, or a systemcomposed of cloud service devices and terminal devices.

[0079] The method of the present application is not limited to the particularly illustrated order shown in FIG. 2. Steps of method 200 can be omitted, rearranged, combined, and / or adjusted in various ways without departing from the scope of the present application.

[0080] 210, obtaining data to be compressed.

[0081] The data to be compressed is a sequence consisting of P symbols, the P symbols including N different symbols, with N being an integer greater than or equal to 1. In some possible embodiments, the data to be compressed is a bioinformatics file containing P bases, with the P bases including N types.

[0082] 220, constructing a context table based on the data to be compressed.

[0083] The context table includes multiple contexts, and each of the contexts includes M symbols, the M symbols including at least one of the N different symbols, with M being an integer greater than 1.

[0084] In one possible implementation, the context table includes NMcontexts.

[0085] 230, determining code trees corresponding to each of the contexts in the context table.

[0086] In some possible implementations, the code trees may be Huffman trees or may also be other types of trees, and the present application does not limit the specific type of code trees.

[0087] For example, the data to be compressed is a sequence of length P, consisting of four different base symbols. The four base symbols are A, T, C and G. Each context corresponds to 4 counters. First sort the 4 counters in each context. Taking the nthcontext in NMas an example, max represents the maximum value among the 4 counters, mid represents the second largest value among the 4 counters, mini represents the second smallest value among the 4 counters, and min2 represents the smallest value among the 4 counters. The first counter is min2. The second counter is mini . The third counter is max. For example, A appears 200 times, C appears 100 times, G appears 30 times, and T appears 10 times, which means that the base corresponding to the max is A, the base corresponding to mid is C, the base corresponding to mini is G, and the base corresponding to min2 is T.

[0088] If max<minl+min2, a code tree with a 2-2-2-2 structure is constructed. A, T, C, and G are located at the second level of the code tree, where the binary code of A is 00, the binarycode of C is 01, the binary code of G is 10, and the binary code of T is 11. It should be understood that the binary codes of A, T, C, and G are not fixed and can be mutually exchanged, e.g., the binary code of A is 01 and the binary code of C is 00.

[0089] If max>minl+min2, a code tree with a 1-2-3 -3 structure is constructed. The base corresponding to the max is located in the first level of the code tree, the base corresponding to the mid is located in the second level of the code tree, and the bases corresponding to mini and min2 are located in the third level of the code tree.

[0090] 240, compressing the data to be compressed.

[0091] FIG. 3 is a flowchart of an embodiment of a data compression method 300 according to an embodiment of the present application. The method shown in FIG. 3 can be executed by cloud service devices or terminal devices, such as computers, servers, and other devices with sufficient computing resources to execute calculations of data compression, or a system composed of cloud service devices and terminal devices.

[0092] The method of the present application is not limited to the particularly illustrated order shown in FIG. 3. Steps of method 300 can be omitted, rearranged, combined, and / or adjusted in various ways without departing from the scope of the present application.

[0093] 310, Processing files to fill a context table.

[0094] A context table is a massive block with NMcontexts, each corresponding to N counters since the method can provide NMdifferent contexts. It should be understood that N refers to the amount of alphabetic variety in the text to be compressed, and M refers to the quantity of bases contained in a context.

[0095] For example, for genomic data (4 bases), a context table of M=5 is a massive block with 45contexts, each context corresponding to 4 counters, and each counter being 1 or 2 bytes.

[0096] FIG. 4 is a schematic diagram of a context table according to an embodiment of the present application. A FASTQ file corresponds to a context table.

[0097] Exemplarily, N=4, M=2, and the nthcontext in the context table is “AT”. The A counter represents the frequency of base A after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATA” in the data to be compressed. The C counter represents the frequency of base C after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATC” in the data to be compressed. The G counter represents the frequency ofbase G after the 11thcontext in the data to be compressed, i.e., the number of occurrences of “ATG” in the data to be compressed. The T counter represents the frequency of base T after the nthcontext in the data to be compressed, i.e., the number of occurrences of “ATT” in the data to be compressed. The method provided in the present application compresses only the letter that follows the context. For example, in the example “ATA”, “AT” is a context used to observe the letter “A”. The method only compresses “A”.

[0098] 320, Creating codes for each context.

[0099] FIG. 5 is a schematic diagram of the creation of a code tree according to an embodiment of the present application. In step 320, the counters for each context need to be sorted and a code tree is created for each context.

[0100] In some possible implementations, the code tree may be a Huffman tree or may also be other types of trees, and the present application does not limit the specific type of code trees.

[0101] As mentioned above, each context corresponds to 4 counters. First sort the 4 counters in each context. As an example, for the nthcontext, max represents the maximum value among the 4 counters, mid represents the second largest value among the 4 counters, mini represents the second smallest value among the 4 counters, and min2 represents the smallest value among the 4 counters. For example, A appears 200 times, C appears 100 times, G appears 30 times, and T appears 10 times, which means that the base corresponding to the max is A, the base corresponding to mid is C, the base corresponding to mini is G, and the base corresponding to min2 is T.

[0102] If max<minl+min2, a code tree with a 2-2-2 -2 structure is constructed. A, T, C, and G are located at the second level of the code tree, where the binary code of A is 00, the binary code of C is 01, the binary code of G is 10, and the binary code of T is 11. It should be understood that the binary codes of A, T, C, and G are not fixed and can be mutually exchanged, e.g., the binary code of A is 01 and the binary code of C is 00.

[0103] If max>minl+min2, a code tree with a 1 -2-3-3 structure is constructed. The base corresponding to the max is located in the first level of the code tree, the base corresponding to the mid is located in the second level of the code tree, and the bases corresponding to mini and min2 are located in the third level of the code tree.

[0104] The code tree with a 2-2-2-2 structure includes 1 variant tree, and the code tree witha 1 -2-3-3 structure includes 12 variant trees. Therefore, instead of storing counters for each context, this application embodiment only needs to store variant trees for each context. In order to store 13 different variants, 4 bits are needed, since 23< 13 < 24. In the classical approach for each context, it is needed to store at least 1 byte for each base and 4 bytes for each context.

[0105] The encoding of contexts is described by a tree. Based on the context table, the method provided in this application creates a tree for each context, the method only needs to store the number of the tree.

[0106] FIG. 6 is a schematic diagram of the numbering of trees corresponding to a context table according to an embodiment of the present application. Each context in the context table corresponds to the number of trees, which is a binary code in 1-13. The numbering of the trees corresponding to each context is related to the ordering of four counters.

[0107] 330, Finding a context for a current base.

[0108] On this basis, the method provided by this application processes data. For each base, the corresponding context is found in the context table and the number of the trees is obtained. Based on the tree number, it is possible to know which binary code to use for the current base.

[0109] 340, Getting a code for the current base.

[0110] The code of a base depends on the context to which the base corresponds. The method provided in the present application provides a binary code for each letter of each context. This step is simply encoded according to the binary code corresponding to each base.

[0111] The process of decompression corresponding to the compression method provided in the present application only requires the table with contextual code trees. The detailed process will not be repeated in the present application.

[0112] The present application uses a special combination of code trees and context modeling to encode symbols in VLE instead of using arithmetic encoding. Due to the small letter size of the genomic data, this allows the method provided by this application to create code trees and encode them with a small number of bits.

[0113] The lower size of the context table and faster compression and decompression speed provides an ability to use this algorithm in fast encoding schemes for both genome data and data with a low alphabet size. The encoding of the context corresponding to data of a low letter size may not be the 13 variant trees described above, for example, it may be smaller or largerthan the 13 variant trees. However, the process of determining the codes corresponding to the contexts of data containing different numbers of alphabets is similar to the process of determining the codes corresponding to the contexts of genetic data, and it is sufficient to construct variant trees according to the construction method of code trees. The number of variant trees varies, and the corresponding amount of bits needed may vary.

[0114] The following experimental data illustrates the beneficial effects of the technical solutions of the present application.

[0115] The method provided in the present application may be referred to as StatVLE. As shown in Table 1, methods for comparison with StatVLE are BSC, FSE, and ZSTD.Table 1

[0116] FIG. 7 is a comparative schematic diagram of four algorithms for compressing data according to an embodiment of the present application. FIG. 8 is a comparative schematic diagram of four algorithms for decompressing data according to an embodiment of the present application. Testing was made on the FASTQ dataset. Different files from different sequencers were used in the test. All parts of FASTQ files were separately compressed by FSE and ZSTD level 11 algorithms and the genome part was compressed by StatVLE. Compared to FSE and ZSTD, the CR of StatVLE is improved by about 20%. Compared to BSC, StatVLE is about 200% faster for the same CR.

[0117] FIG. 9 shows a schematic diagram of a classical statistical compression algorithm.

[0118] For genome compression, the main idea of classical statistical compression methods is to use the previous L symbols (called order) to predict the next one. The modeling part can be described by a context table which consists of the counters for each context.

[0119] Table 2 shows the comparison of StatVLE with the classical statistical compressionalgorithm.Table 2

[0120] It was found that statistical compression algorithms provide the best compression ratio for genome data. Applying statistical modeling can improve the compression ratio. For example, for a typical FASTQ, dataset compression ratio for genome data can be improved by 57% on average w.r.t. FSE and ZSTD.

[0121] The method provided in the present application is possible to speed up compression speed 2 times and decompression speed 3 times, with the least affecting on a compression ratio. In addition, the present method generates a context table that is 8 times less than the classical one.

[0122] Table 3 shows a comparison of StatVLE with classical context modeling methods.Table 3

[0123] In the classical context modeling method, each context model in the context table should store the number of occurrences of each nucleotide in each context. However, the frequency table will consume a lot of memory. In the data compression method provided in the present application, low alphabet size allows to pack code trees in 4 / 5 bits, and a big part of models are used less than 5 times, which can improve the data compression efficiency and reduce the memory consumption.

[0124] FIG. 10 is a schematic block diagram of an electronic apparatus 1000 according to an embodiment of the present application. As shown in FIG. 10, the electronic apparatus 1000 includes: an obtaining module 1010 and a processing module 1020.

[0125] The obtaining module 1010 is configured to obtain data to be compressed, the data to be compressed being a sequence consisting of N different symbols, with N being an integer greater than or equal to 1.

[0126] The processing module 1020 is configured to construct a context table based on the data to be compressed, the context table including multiple contexts, and each of the contexts including M symbols, with M being an integer greater than 1. The processing module 1020 is further configured to determine code trees corresponding to each of the contexts in the context table, with the code trees including encodings for the N different symbols. The processing module 1020 is further configured to compress the data to be compressed according to the context table and the code trees.

[0127] Optionally, the context table includes NMcontexts.

[0128] Optionally, a first context corresponds to N counters, and the N counters are in one- to-one correspondence with the N different symbols, and each of the N counters represents the number of occurrences of a corresponding symbol after the first context in the data to be compressed, and the first context is any one of the contexts in the context table.

[0129] Optionally, N=4.

[0130] Optionally, the processing module 1020 is specifically configured to: if the sum of a first counter and a second counter is greater than a third counter, determine that a first code tree has a 3 -level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context; or if the sum of a first counter and a second counter is less than or equal to a third counter, determine that a first code tree has a 2-level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context.

[0131] Optionally, a second code tree is stored by 4 bits, and the second code tree is a code tree corresponding to any one of the contexts in the context table.

[0132] Optionally, the data to be compressed includes genomic data.

[0133] FIG. 11 is a schematic block diagram of an electronic device 1100 according to an embodiment of the present application.

[0134] As shown in FIG.ll, the electronic device 1100 may include a transceiver 1101, a processor 1102, and a memory 1103. The memory 1103 may be configured to store codes, instructions, or the like, executed by the processor 1102.

[0135] It should be understood that the processor 1102 may be an integrated circuit chip and has a signal processing capability. In an implementation process, steps of the foregoing method embodiments may be completed by using a hardware integrated logic circuit in a processor, or by using instructions in a form of software. The processor may be a general purpose processor, a digital signal processor (digital signal processor, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA), or another programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The processor may implement or perform the methods, the steps, and the logical block diagrams that are disclosed in the embodiments of the present application. The general purpose processor may be a microprocessor, or the processor may be any conventional processor or the like. The steps of the methods disclosed with reference to the embodiments of the present application may be directly performed and completed by a hardware decoding processor, or may be performed and completed by using a combination of hardware in the decoding processor and a software module. The software module may be located in a mature storage medium in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, or a register. The storage medium is located in the memory, and the processor reads information in the memory and completes the steps of the foregoing methods in combination with hardware in the processor.

[0136] It may be understood that the memory 1103 in the embodiments of the present application may be a volatile memory or a nonvolatile memory, or may include both a volatile memory and a nonvolatile memory. The nonvolatile memory may be a read-only memory (Read-Only Memory, ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), anelectrically erasable programmable read-only memory (Electrically EPROM, EEPROM), or a flash memory. The volatile memory may be a random access memory (Random Access Memory, RAM) and is used as an external cache. By way of example rather than limitation, many forms of RAMs may be used, and are, for example, a static random access memory (Static RAM, SRAM), a dynamic random access memory (Dynamic RAM, DRAM), a synchronous dynamic random access memory (Synchronous DRAM, SDRAM), a double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDR SDRAM), an enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), a synchronous link dynamic random access memory (Synchronous link DRAM, SLDRAM), and a direct Rambus random access memory (Direct Rambus RAM, DR RAM).

[0137] It should be noted that the memory in the systems and the methods described in the specification includes but is not limited to these memories and a memory of any other appropriate type.

[0138] An embodiment of the present application further provides a system chip, where the system chip includes an input / output interface, at least one processor, at least one memory, and a bus. The at least one memory is configured to store instructions, and the at least one processor is configured to invoke the instructions of the at least one memory to perform operations in the methods in the foregoing embodiments.

[0139] An embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a program instruction for performing any of the foregoing methods.

[0140] Optionally, the storage medium may be specifically the memory 1103.

[0141] A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in the specification, units and algorithm steps can be implemented by an electronic hardware or a combination of a computer software and the electronic hardware. Whether functions are performed by a hardware or a software depends on particular applications and design constraints of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of the present application.

[0142] It may be clearly understood by a person skilled in the art that, for a purpose of a convenient and brief description, for a detailed working process of the foregoing system, apparatus, and unit, refer to a corresponding process in the foregoing method embodiment. Details are not described herein again.

[0143] In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the described apparatus embodiment is merely an example. For example, the unit division is merely logical function division and may be other division in actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented through some interfaces. The indirect couplings or communication connections between the apparatuses or units may be implemented in electronic, mechanical, or other forms.

[0144] The units described as separate parts may be or may not be physically separate, and parts displayed as units may be or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units may be selected based on actual requirements to achieve objectives of the solutions of the embodiments.

[0145] In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit.

[0146] When the functions are implemented in a form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer readable storage medium. Based on such an understanding, the technical solutions in the present application essentially, or the part contributing to the prior art, or some of the technical solutions may be implemented in a form of a software product. The computer software product is stored in a storage medium, and includes several instructions for instructing a computer device (which may be a personal computer, a server, a network device, or the like) to perform all or some of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random accessmemory (Random Access Memory, RAM), a magnetic disk, or an optical disc.

[0147] The foregoing descriptions are merely specific implementations of the present application, but are not intended to limit a protection scope of the present application. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in the present application shall fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

CLAIMSWhat is claimed is:

1. A data compression method, comprising: obtaining data to be compressed, the data to be compressed being a sequence consisting of P symbols, the P symbols comprising N different symbols, with N being an integer greater than or equal to 1 ; and constructing a context table based on the data to be compressed, the context table comprising multiple contexts, and each of the contexts comprising M symbols, the M symbols comprising at least one of the N different symbols, with M being an integer greater than 1 ; and determining code trees corresponding to each of the contexts in the context table, with the code trees comprising encodings for the N different symbols; and compressing the data to be compressed according to the context table and the code trees.

2. The method according to claim 1, wherein the context table comprises NMcontexts.

3. The method according to claim 1 or 2, wherein a first context corresponds to N counters, and the N counters are in one-to-one correspondence with the N different symbols, and each of the N counters represents the number of occurrences of a corresponding symbol after the first context in the data to be compressed, and the first context is any one of the contexts in the context table.

4. The method according to claim 3, wherein N=4O5. The method according to claim 4, wherein the determining code trees corresponding to each of the contexts in the context table comprises: if the sum of a first counter and a second counter is greater than a third counter, determining that a first code tree has a 3 -level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context; or if the sum of a first counter and a second counter is less than or equal to a third counter,determining that a first code tree has a 2-level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context.

6. The method according to any one of claims 1 to 5, wherein a second code tree is stored by 4 bits, and the second code tree is a code tree corresponding to any one of the contexts in the context table.

7. The method according to any one of claims 1 to 6, wherein the data to be compressed comprises genomic data.

8. An electronic apparatus, comprising: an obtaining module configured to obtain data to be compressed, the data to be compressed being a sequence consisting of P symbols, the P symbols comprising N different symbols, with N being an integer greater than or equal to 1 ; and a processing module configured to construct a context table based on the data to be compressed, the context table comprising multiple contexts, and each of the contexts comprising M symbols, the M symbols comprising at least one of the N different symbols, with M being an integer greater than 1 ; determine code trees corresponding to each of the contexts in the context table, with the code trees comprising encodings for the N different symbols; and compress the data to be compressed according to the context table and the code trees.

9. The electronic apparatus according to claim 8, wherein the context table comprises NMcontexts.

10. The electronic apparatus according to claim 8 or 9, wherein a first context corresponds to N counters, and the N counters are in one-to-one correspondence with the N different symbols, and each of the N counters represents the number of occurrences of a corresponding symbol after the first context in the data to be compressed, and the first context is any one of the contexts in the context table.

11. The electronic apparatus according to claim 10, wherein N=4.

12. The electronic apparatus according to claim 11, wherein the processing module isspecifically configured to: if the sum of a first counter and a second counter is greater than a third counter, determine that a first code tree has a 3 -level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context; or if the sum of a first counter and a second counter is less than or equal to a third counter, determine that a first code tree has a 2-level structure, the first counter is the smallest value among the N counters corresponding to the first context, the second counter is the second smallest value among the N counters corresponding to the first context, the third counter is the greatest value among the N counters corresponding to the first context, and the first code tree is a code tree corresponding to the first context.

13. The electronic apparatus according to any one of claims 8 to 12, wherein a second code tree is stored by 4 bits, and the second code tree is a code tree corresponding to any one of the contexts in the context table.

14. The electronic apparatus according to any one of claims 8 to 13, wherein the data to be compressed comprises genomic data.

15. An electronic device, comprising a memory and a processor, wherein the memory is configured to store a computer program, and the processor is configured to invoke the computer program from the memory and run the computer program, so that a computer on which a chip is disposed performs the method according to any one of claims 1 to 7.

16. A chip system, comprising a logic circuit configured to couple to an input / output interface to transmit data via the input / output interface to perform the method according to any one of claims 1 to 7.

17. A computer readable storage medium having instructions which, when run on a computer, cause the computer to perform the method according to any one of claims 1 to 7.

18. A computer program product which, when run on a computer, cause the computer to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Compression algorithm incorporating a feedback loop fordynamic selection of a predefined huffman dictionary

    US20130135122A1