A reference-based gene compression method

By comparing the costs of direct compression and compression based on a reference genome, a more efficient compression method is selected, solving the problems of low efficiency and time-consuming search in traditional gene compression, and achieving efficient and convenient gene compression.

CN114520025BActive Publication Date: 2026-06-09GENETALKS BIO TECH (CHANGSHA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GENETALKS BIO TECH (CHANGSHA) CO LTD
Filing Date
2021-12-31
Publication Date
2026-06-09

Smart Images

  • Figure CN114520025B_ABST
    Figure CN114520025B_ABST
Patent Text Reader

Abstract

The application discloses a reference-based gene compression method, and steps of the method comprise the following steps: S1, obtaining a direct compression cost cost0 of base row data to be compressed currently; S2, comparing the direct compression cost cost0 with a reference genome-based compression cost cost2, if the cost0 is less than or equal to the cost2, the current base row is compressed by a direct compression method; otherwise, the current base row is compressed by a reference genome-based compression method. The application has the advantages of simple principle, simple operation, small overall cost, high efficiency and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention mainly relates to the field of gene detection technology, specifically a reference-based gene compression method. Background Technology

[0002] Current gene testing processes require gene compression. Traditional gene compression typically uses base-line compression, with the following steps:

[0003] Step S1: Read the current base row sequence (seq) to be compressed;

[0004] Step S2: Search the entire reference genome to find the gene sequence that is closest to the current base row, and mark it as a matching sequence as seq_ref;

[0005] Step S3: Calculate the XOR sequence seq_nor between seq and seq_ref;

[0006] Step S4: Encode the sequence enc_nor into seq_nor.

[0007] The above-mentioned traditional methods have shortcomings: in general, the reference gene sequence found is different from the original sequence, and sometimes direct compression is easier than compression based on the reference sequence.

[0008] For example: using run-length encoding for compression, such as (this only represents the effect of compression; in reality, compression may not always be performed using this method).

[0009] The sequence number "TTTTTTTTTTTTTTTT" is compressed to 16 terabytes, consuming only 2 bytes.

[0010] seq_ref:”TTTTATTTTTTTTTTTA”

[0011] Seq_nor: "0000100000000001" is compressed into: 4 zeros, 1 1, 15 zeros, and 1 1, consuming 8 bytes.

[0012] (1) The reference sequence also needs to add matching position information. Generally, the position information is a 64-bit integer, which will also increase the number of bits after encoding.

[0013] (2) The process of searching for the reference genome corresponding to the current base row is very time-consuming. Summary of the Invention

[0014] The technical problem to be solved by this invention is to provide a reference-based gene compression method that is simple in principle, easy to operate, has low overall cost, and high efficiency, in response to the technical problems existing in the prior art.

[0015] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:

[0016] A reference-based gene compression method includes the following steps:

[0017] Step S1: Obtain the cost of directly compressing the current base row data to be compressed, cost 0;

[0018] Step S2: Compare the cost of direct compression cost0 with the cost of compression based on the reference genome cost2. If cost0 is less than or equal to cost2, compress the current base row using the direct compression method; otherwise, compress the current base row using the compression method based on the reference genome.

[0019] As a further improvement to the method of the present invention: step S1 includes:

[0020] Step S101: Read the current base row data curr_base to be compressed, whose length is len;

[0021] Step S102: Calculate the cost cost0 of directly compressing the current base row;

[0022] As a further improvement to the method of the present invention: in step S102, the calculation method of cost0 is as follows:

[0023] cost0=cost_noref(curr_base,len)

[0024] Where cost_noref is the cost estimation method for direct compression. The actual compression method is used to perform compression, and the number of compressed bits is obtained. The compressed bits represent cost0.

[0025] As a further improvement to the method of the present invention: in step S102, the estimation process of cost_noref is as follows:

[0026] Step S1000: Perform run-length encoding on curr_base and obtain the number of encoded bits, denoted as GIS_bits(curr_base);

[0027] Step S1001: cost0 = GIS_bits(curr_base).

[0028] As a further improvement to the method of the present invention: in step S2, the best matching sequence curr_ref and matching ref_pos for curr_base are searched from the reference genome; the cost cost2 of compressing the current base row using the best matching sequence curr_ref is calculated.

[0029] As a further improvement to the method of the present invention: in step S2, the calculation method of cost2 is as follows:

[0030] cost2=cost_ref(curr_base,curr_ref,len,ref_pos)

[0031] The cost_ref method is a cost estimation method based on the reference gene sequence. It first calculates the XOR of curr_base and curr_ref as curr_nor, and then calculates the sum of the number of bits in compressed curr_nor and the number of encoded bits in ref_pos to estimate the cost.

[0032] As a further improvement to the method of the present invention: in step S2, the estimation process of cost_ref is as follows:

[0033] Step S10000: XOR curr_base and curr_ref to obtain the curr_nor sequence;

[0034] Step S10001: Perform run-length encoding on curr_nor to obtain the number of encoded bits, denoted as GIS_bits(curr_nor);

[0035] Step S10002: ref_pos is 4 bits;

[0036] Step S10003: Estimate the bits of curr_ref, perform GZ encoding on curr_ref to obtain the number of encoded bits, denoted as GZ-bits(curr_ref), and weight this value when calculating cost2. Count the number of times the current gene fragment is referenced as N_refed, and set the weighting coefficient w as the following function:

[0037] w = 0.2 when N_refed <= 5;

[0038] w = 1 / N_refed when N_refed > 5;

[0039] Step S1004: cost2=GIS_bits(curr_nor)+4+GZ_bits(curr_ref)*w.

[0040] Compared with the prior art, the advantages of the present invention are as follows:

[0041] The reference-based gene compression method of this invention is simple in principle, easy to operate, has low overall overhead, and high efficiency. This invention compares the cost of direct compression (cost0) with the cost of compression based on the reference genome (cost2). If cost0 is less than or equal to cost2, the current base row is compressed using the direct compression method; otherwise, the current base row is compressed using the reference genome-based compression method. This significantly improves the compression ratio. Attached Figure Description

[0042] Figure 1 This is a flowchart illustrating the method of the present invention.

[0043] Figure 2 This is a flowchart illustrating a specific application example of the present invention. Detailed Implementation

[0044] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0045] like Figure 1 and Figure 2 As shown, the reference-based gene compression method of the present invention includes the following steps:

[0046] Step S1: Obtain the cost of directly compressing the current base row data to be compressed, cost 0;

[0047] Step S2: Compare the cost of direct compression cost0 with the cost of compression based on the reference genome cost2. If cost0 is less than or equal to cost2, compress the current base row using the direct compression method; otherwise, compress the current base row using the compression method based on the reference genome.

[0048] In a specific application example, step S1 includes:

[0049] Step S101: Read the current base row data curr_base to be compressed, whose length is len;

[0050] Step S102: Calculate the cost cost0 of directly compressing the current base row.

[0051] In a preferred embodiment, in step S102, cost0 is calculated as follows:

[0052] cost0=cost_noref(curr_base,len)

[0053] Where cost_noref is the cost estimation method for direct compression. In practice, the actual compression method can be used directly to compress the data and obtain the number of compressed bits. The compressed bits represent cost0.

[0054] It is understood that in other embodiments, the bits can also be estimated using a simple and quick method, depending on actual needs.

[0055] In another, better example, to effectively reduce the time required for cost estimation, one implementation of the cost_noref estimation method is as follows:

[0056] Step S1000: Perform run-length encoding on curr_base to obtain the number of encoded bits. This method is denoted as GIS_bits(curr_base).

[0057] Step S1001: cost0 = GIS_bits(curr_base).

[0058] In a specific application example, in step S2, the present invention further searches for the best matching sequence curr_ref and matching ref_pos from the reference genome that match curr_base. The cost cost2 of compressing the current base row using the best matching sequence curr_ref is calculated.

[0059] In a preferred embodiment, the calculation method for cost2 in step S5 is as follows:

[0060] cost2=cost_ref(curr_base,curr_ref,len,ref_pos)

[0061] Cost_ref is a cost estimation method based on the reference gene sequence. In practice, the cost can be estimated by first calculating the XOR of curr_base and curr_ref as curr_nor, and then calculating the sum of the number of bits in compressed curr_nor and the number of encoded bits in ref_pos.

[0062] It is understood that in other embodiments, the present invention may also use some rapid estimation methods as needed.

[0063] In another, better example, to effectively reduce the time required for cost estimation, one implementation of the cost_ref estimation method is as follows:

[0064] Step S10000: XOR curr_base and curr_ref to obtain the curr_nor sequence;

[0065] Step S10001: Perform run-length encoding on curr_nor to obtain the number of encoded bits. This method is denoted as GIS_bits(curr_nor).

[0066] Step S10002: ref_pos is generally 4 bits;

[0067] Step S10003: Estimate the bits of curr_ref: GZ encoding is performed on curr_ref to obtain the number of encoded bits, denoted as GZ-bits(curr_ref). Since this reference gene fragment may also be referenced by other base rows, this value is weighted when calculating cost2. The number of times the current gene fragment is referenced is counted as N_refed, and the weighting coefficient w is set as follows:

[0068] w = 0.2 when N_refed <= 5

[0069] w = 1 / N_refed When N_refed > 5

[0070] Step S1004: cost2=GIS_bits(curr_nor)+4+GZ_bits(curr_ref)*w.

[0071] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should be considered within the scope of protection of the present invention.

Claims

1. A reference-based gene compression method, characterized by the steps of include: Step S1: Obtain the cost of directly compressing the current base row data to be compressed, cost 0; Step S2: Compare the cost of direct compression cost0 with the cost of compression based on the reference genome cost2. If cost0 is less than or equal to cost2, then compress the current base row using the direct compression method. Otherwise, compress the current base row using a compression method based on the reference genome; Step S1 includes: Step S101: Read the current base row data curr_base to be compressed, whose length is len; Step S102: Calculate the cost cost0 of directly compressing the current base row; the calculation method for cost0 is as follows: cost0 = cost_noref(curr_base, len) Where cost_noref is the cost estimation method for direct compression. The actual compression method is used to compress the data and obtain the number of bits after compression. The number of bits after compression represents cost0. In step S2, the best matching sequence curr_ref and matching ref_pos for curr_base are searched from the reference genome; the cost cost2 of compressing the current base row using the best matching sequence curr_ref is calculated; the calculation method of cost2 is as follows: cost2 = cost_ref(curr_base, curr_ref, len, ref_pos) The cost_ref method is a cost estimation method based on the reference gene sequence. It first calculates the XOR of curr_base and curr_ref as curr_nor, and then calculates the sum of the number of bits in compressed curr_nor and the number of encoded bits in ref_pos to estimate the cost.

2. The reference-based genetic compression method of claim 1, wherein, In step S102, the estimation process for cost_noref is as follows: Step S1000: Perform run-length encoding on curr_base and obtain the number of encoded bits, denoted as GIS_bits(curr_base); Step S1001: cost0 = GIS_bits(curr_base).

3. The reference-based genetic compression method of claim 1, wherein, In step S2, the cost_ref estimation process is as follows: Step S10000: XOR curr_base and curr_ref to obtain the curr_nor sequence; Step S10001: Perform run-length encoding on curr_nor to obtain the number of encoded bits, denoted as GIS_bits(curr_nor); Step S10002: ref_pos is 4 bits; Step S10003: Estimate the bits of curr_ref, perform GZ encoding on curr_ref to obtain the number of encoded bits, denoted as GZ-bits(curr_ref), and apply weighting when calculating cost2. Count the number of times the current gene fragment is referenced as N_refed, and set the weighting coefficient w as the following function: w=0.2 when N_refed<=5; w = 1 / N_refed when N_refed > 5; Step S1004: cost2=GIS_bits(curr_nor) + 4 + GZ_bits(curr_ref)*w.

Citation Information

Patent Citations

  • Multiple-sequence oriented gene sequence data compression method

    CN109979537A

  • Gene sequencing data compression and decompression method and system and computer readable medium

    CN110021369A