A k-mer encoding scheme for fuzzy matching
By using the k-mer encoding method with fuzzy matching, the problem of low mismatch sensitivity in genome sequence alignment is solved, improving the sensitivity and efficiency of sequence alignment, reducing computational and memory costs, and making it suitable for bioinformatics research.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN BAIREN TECH CO LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies have low sensitivity to mismatches caused by sequencing errors and polymorphisms in local genome sequence alignment. Traditional k-mer matching methods are not sensitive enough when tolerating mismatches, making it difficult to effectively improve the accuracy of sequence alignment.
The k-mer encoding method using fuzzy matching converts bases into binary numbers by constructing a mapping, uses multiple hash functions for encoding, allows base substitution, uses a hash table to store k-mers, tolerates mismatches, improves sensitivity, and assigns different mappings to each base using multiple hash functions to tolerate more substitutions and reduce memory conflicts.
It improves the sensitivity of k-mer matching, reduces alignment runtime and memory costs, has high HGT detection accuracy, is suitable for situations with low genome integrity, and significantly improves the sequence alignment efficiency of bioinformatics research.
Smart Images

Figure CN116206687B_ABST
Abstract
Description
A k-mer encoding method for fuzzy matching Technical Field
[0001] This invention relates to the field of k-mer encoding technology, and specifically to a k-mer encoding method for fuzzy matching. Background Technology
[0002] k-mers, or continuous strings of length k in biological sequences, are widely used in bioinformatics. Analyzing k-mers in DNA sequences is a crucial step in numerous applications, including genome assembly, sequencing read alignment, and metagenomic classification. Currently, calculating all k-mers in a given dataset primarily relies on standardized k-mer counters, such as Jellyfish and KMC. In addition, some k-mer counting tools, such as gkm-SVM, modify standard k-mers, using gapped k-mers to support fuzzy matching and improve matching sensitivity. This involves adding intervals to allow for fuzzy sequence matching.
[0003] One of the main applications of k-mers is aligning local sequencing data to a reference genome. However, local genome sequences may differ significantly from the reference genome. These differences include sequencing errors, SNPs, and small INDELs. In such cases, the sensitivity of traditional precise k-mer matching is very low. Gapped k-mers also exhibit low sensitivity when aligning locally obtained k-mers to a reference genome. This invention proposes a fuzzy matching k-mer encoding method to tolerate mismatches during alignment, thereby improving the sensitivity of k-mer-based sequence alignment. Summary of the Invention
[0004] This invention provides a k-mer encoding method for fuzzy matching to solve the problems mentioned in the background art.
[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0006] A k-mer encoding method for fuzzy matching includes the following steps:
[0007] S1: Construct three mappings to convert bases into binary numbers;
[0008] S2: Construct a hash function to encode k-mer into decimal numbers;
[0009] S3: Use multiple hash functions to repeatedly encode k-mer;
[0010] S4: Use a hash table to store the k-mer obtained from the local data;
[0011] S5: Traverse the reference genome to obtain the count of each k-mer in the hash table.
[0012] A further improvement of the technical solution of the present invention is that: S1 tolerates substitutions in genome alignment, and in each mapping, every two bases are mapped to the same value, i.e., 0 or 1.
[0013] A further improvement of the technical solution of the present invention is that: S2 randomly selects the mapping described in S1 at different positions, converts all bases on the k-mer into binary numbers, and then converts the binary numbers into decimal numbers.
[0014] A further improvement to the technical solution of this invention lies in that: S3 uses multiple hash functions (three by default) to encode the same k-mer. For a given k-mer, each position is assigned a different mapping in different hash functions as much as possible.
[0015] A further improvement to the technical solution of the present invention is that: S4 creates a size of 2 k An array.
[0016] A further improvement of the technical solution of the present invention is that: for each genome on the reference genome, S5 starts from the beginning, extracts each k-mer sequentially, and encodes the k-mer using n hash functions.
[0017] Due to the adoption of the above technical solution, the technical progress achieved by this invention compared to the prior art is as follows:
[0018] The most significant advantage of this invention compared to existing technologies is its ability to tolerate substitutions during alignment, specifically mismatches caused by sequencing errors and polymorphisms, thereby improving the sensitivity of k-mer matching. By converting bases in the DNA sequence into binary numbers through three mappings and then encoding k-mers using multiple hash functions, different hash functions are used to assign different mappings to each base to tolerate more substitutions. This improves both the sensitivity of sequence alignment and the efficiency of k-mer counting. This invention significantly reduces the alignment runtime in HGT detection experiments and can perform sequence alignment even with low genome integrity, achieving considerable HGT detection accuracy. This further demonstrates the efficient application of this invention in numerous bioinformatics-related research studies. Furthermore, in the second part of this invention, the k-mer storage process allows for the occurrence of conflicts caused by two k-mers being mapped to the same location, thereby reducing memory usage and computational and memory costs. Attached Figure Description
[0019] Figure 1 is a schematic diagram of the process of the present invention. Detailed Implementation
[0020] The present invention will be further described in detail below with reference to embodiments:
[0021] Example 1
[0022] As shown in Figure 1, this invention provides a k-mer encoding method for fuzzy matching, comprising the following steps:
[0023] S1: Construct three mappings to convert bases into binary numbers;
[0024] S2: Construct a hash function to encode k-mer into decimal numbers;
[0025] S3: Use multiple hash functions to repeatedly encode k-mer;
[0026] S4: Use a hash table to store the k-mer obtained from the local data;
[0027] S5: Traverse the reference genome to obtain the count of each k-mer in the hash table.
[0028] in,
[0029] S1: Since there are four bases, A, T, C, and G, there are 12 types of substitutions: A>T, T>A, C>G, G>C, T>G, G>T, T>C, C>T, A>G, G>A, A>C, and C>A. In each mapping, every two bases map to the same value, either 0 or 1. Therefore, each mapping allows for four types of substitution mismatches and tolerates substitutions in genome alignment, thereby improving sensitivity in practical applications.
[0030] S2: In the hash function, for each k-mer, the mapping described in the first part is randomly selected at different positions, and all bases on the k-mer are converted into binary numbers. This produces a binary number A = (a1a2…a ... k Using formulas Convert the binary number A to the decimal number L.
[0031] S3: To tolerate more mismatches, we use multiple hash functions (three by default) to encode the same k-mer. For a given k-mer, we assign different mappings to each position across different hash functions as much as possible. For three mappings, there are 6 possible permutations (012, 021, 120, 210, 201, 102). Assuming we use n hash functions in total, for each position, we randomly select... We take several permutations and combinations and combine them into an array X. For the i-th hash function, we choose the mapping X[i]. In this way, a k-mer is converted into n decimal numbers.
[0032] S4: Created a size of 2 k The array is defined by the decimal number L, which represents the location where the k-mer is stored. During storage, each k-mer is stored n times. If two k-mers are mapped to the same location, a conflict will occur. However, in this invention, such conflicts are allowed to occur in order to save memory.
[0033] S5: For each genome segment on the reference genome, starting from the beginning, extract each k-mer sequentially. Encode each k-mer using n hash functions to obtain n values. Use these n values as indices to extract the corresponding counts from the hash table, resulting in a total of n counts. Select the maximum value as the final count for this k-mer.
Claims
1. A k-mer encoding method for fuzzy matching, characterized in that: Includes the following steps: S1: Construct three mappings to convert bases into binary numbers; S1 tolerates substitutions in genome alignment, and in each mapping, every two bases map to the same value, i.e., 0 or 1; S2: Construct a hash function to encode the k-mer into a decimal number; S2 randomly selects the mapping described in S1 at different positions, converts all bases on the k-mer into binary numbers, and then converts the binary numbers into decimal numbers; S3: Repeatedly encode the k-mer using multiple hash functions; S3 uses three hash functions to encode the same k-mer, assigning different mappings to each position in different hash functions as much as possible for each k-mer; S4: Use a hash table to store the k-mer obtained from the local data; S4 creates a hash table of size... An array that allows for collisions caused by two k-mers being mapped to the same position; S5: Traverse the reference genome to obtain the count of each k-mer in the hash table.
2. The k-mer encoding method for fuzzy matching according to claim 1, characterized in that: For each genome in the reference genome, S5 extracts each k-mer sequentially from the beginning and encodes the k-mer using n hash functions.
Citation Information
Patent Citations
Suffix array based fuzzy tandem repeat recognition method
CN104156636A
Image deblurring method based on genetic algorithm and Wiener filtering
CN106296619A