Barcode correction method and device, electronic equipment and storage medium
By generating pattern strings and constructing a multi-level index mapping mechanism during the barcode correction process, the problems of low query efficiency, high resource consumption, and insufficient robustness in existing technologies are solved, achieving efficient and reliable barcode correction, which is applicable to the fields of molecular biology and gene sequencing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU DYNAMIC BIOSYSTEMS CO LTD
- Filing Date
- 2025-12-19
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies suffer from low query efficiency during barcode correction, explosive candidate generation during fuzzy matching, severe computational resource consumption, and insufficient robustness, making it difficult to achieve a balance between memory usage, query speed, and result accuracy.
By generating a pattern string in the target barcode and replacing bases, a pattern candidate set is constructed and matched. Combining compressed value comparison and Hamming distance calculation, a multi-level index mapping mechanism is established, including Bloom filter, Hamming sphere index and locality-sensitive hash rescue mechanism, to optimize the barcode correction process.
It significantly improves query speed, reduces computing resource consumption, enhances system robustness and query efficiency, and supports reliable matching in high-concurrency scenarios.
Smart Images

Figure CN122090967A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of biological information processing technology, specifically to barcode correction methods, devices, electronic devices, and storage media. Background Technology
[0002] In fields such as molecular biology and gene sequencing, barcodes are widely used as sequence tags for sample identification and data association. In practical applications, to determine whether the current barcode is a correct sequence tag, it is usually necessary to compare the target barcode to be judged with a known barcode whitelist to determine whether there is an exact match or a near match, so as to correct the target barcode (that is, to correct the barcode that is identified as wrong but whose number of incorrect bases is below the error tolerance).
[0003] However, the current method of comparing the target barcode to be determined with a known barcode whitelist to correct the target barcode has problems such as low query efficiency and an explosion of candidate generation during fuzzy matching, resulting in serious consumption of computing resources. Summary of the Invention
[0004] In view of this, this application provides a barcode correction method, apparatus, electronic device, and storage medium to solve the problems of low query efficiency and severe consumption of computational resources in the related technologies for correcting target barcodes, which result in an explosion of candidate generation during fuzzy matching.
[0005] In a first aspect, this application provides a method for correcting barcodes, the method comprising: Obtain the target barcode to be corrected; Generate a pattern string at each base position in the target barcode, and replace the base at the current position with the pattern string to obtain a preset number of new target barcodes. The new target barcodes are obtained by replacing the bases in the pattern string, and the preset number is consistent with the length of the target barcode. The new target barcode is matched with each pattern candidate set constructed from the barcode whitelist. After matching the target pattern candidate set, the new target barcode is matched with each new reference barcode in the target pattern candidate set to obtain the first matching result. The barcode whitelist includes multiple reference barcodes. Each new reference barcode in the same pattern candidate set is formed by replacing the bases at the same position in the pattern string. The target pattern candidate set is any set in the pattern candidate set. Based on the first matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist.
[0006] Furthermore, before generating the pattern string at each base position contained in the target barcode, the method also includes: The target barcode is compressed to obtain a compressed value; The compressed value is compared with multiple reference compressed values to obtain the comparison result. The reference compressed values are included in the set of compressed values constructed from reference barcodes in the barcode whitelist. Based on the comparison results, if it is determined that the compressed value does not match the reference compressed value, a pattern string is generated at each base position of the compressed value.
[0007] Furthermore, after obtaining the comparison results, the method also includes: Based on the comparison results, if the compressed value matches the reference compressed value, the target barcode is determined to be included in the barcode whitelist.
[0008] Furthermore, based on the first matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist, including: If a new target barcode matches a new reference barcode, the target barcode is determined to be included in the barcode whitelist. If the new target barcode does not match the new reference barcode, the target barcode is segmented to obtain the first segment data; The first segment data is matched with the second segment data of each reference barcode in the barcode whitelist to obtain the second matching result; The target barcode is corrected based on the second matching result to determine the inclusion relationship between the target barcode and the barcode whitelist.
[0009] Furthermore, the new target barcode is matched with a new reference barcode, including: The Hamming distance is obtained by performing bitwise operations on the new target barcode and the new reference barcode. If the Hamming distance is less than or equal to a preset threshold, the new target barcode is determined to match the new reference barcode.
[0010] Furthermore, the first segment data is matched with the second segment data of each reference barcode in the barcode whitelist to obtain the second matching result, including: The first segment of data with the same hash key is assigned to the same data bucket, and the data bucket is identified with the first identification information. The second segment of data with the same hash key is assigned to the same data bucket, and the data bucket is identified with the second identification information. The first segment data in the data bucket with the same first and second identification information is matched with the second segment data to obtain the second matching result.
[0011] Furthermore, based on the second matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist, including: Based on the second matching result, candidate barcodes are selected from the reference barcodes; The Hamming distance is obtained by performing bitwise operations on the target barcode and the candidate barcode; If the Hamming distance value is less than or equal to a preset threshold, the target barcode is determined to be included in the barcode whitelist.
[0012] Secondly, this application provides a barcode correction device, the device comprising: The acquisition module is used to acquire the target barcode to be corrected; The replacement module is used to generate a pattern string at each base position in the target barcode, and replace the base at the current position with the pattern string to obtain a preset number of new target barcodes. The new target barcodes are obtained by replacing the bases with the pattern string, and the preset number is consistent with the length of the target barcode. The matching module is used to match the new target barcode with each pattern candidate set constructed from the barcode whitelist. After matching the target pattern candidate set, the new target barcode is matched with each new reference barcode in the target pattern candidate set to obtain the first matching result. The barcode whitelist includes multiple reference barcodes. Each new reference barcode in the same pattern candidate set is formed by replacing the bases at the same position in the pattern string. The target pattern candidate set is any set in the pattern candidate set. The correction module is used to correct the target barcode based on the first matching result and determine the inclusion relationship between the target barcode and the barcode whitelist.
[0013] Thirdly, this application provides a computer device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the barcode correction method of the first aspect or any corresponding embodiment described above.
[0014] Fourthly, this application provides a computer-readable storage medium storing computer instructions for causing a computer to execute the barcode correction method of the first aspect or any corresponding embodiment described above.
[0015] In this embodiment, a pattern string is generated for each base position in the obtained target barcode to be corrected, and the base at the current position is replaced with the pattern string to obtain a preset number of new target barcodes. Then, the new target barcodes are matched against various pattern candidate sets constructed from a barcode whitelist. After matching a target pattern candidate set, the new target barcodes are matched against each new reference barcode in the target pattern candidate set to obtain a first matching result. Based on this first matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist. Thus, this embodiment achieves index mapping through positional patterns, avoiding redundant calculations that generate a certain number of mutants, solving the candidate generation explosion problem in traditional methods, reducing query complexity, significantly improving query speed, and significantly reducing computational resource consumption. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating a barcode correction method according to an embodiment of this application; Figure 2 This is a three-layer query architecture for the barcode correction method according to embodiments of this application; Figure 3 This is a block diagram of a barcode correction method apparatus according to an embodiment of this application; Figure 4 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0020] In fields such as molecular biology and gene sequencing, barcodes are widely used as sequence labels for sample identification and data association. In practical applications, it is usually necessary to compare the target barcode with a known whitelist of barcodes to determine whether there is an exact match or a near match (e.g., Hamming distance ≤ 1) in order to correct the target barcode.
[0021] The existing technology currently suffers from the following main drawbacks: (1) Excessive memory usage: Traditional methods often use strings to directly store barcode sequences, with each character occupying 1 byte (8 bits). For whitelists containing millions or even tens of millions of 32-base barcodes, this will consume a lot of memory resources, leading to a decrease in system operating efficiency.
[0022] (2) Low query efficiency: Exact matching often relies on hash tables, but for large-scale data, the hash collision rate increases, and the query time increases; Fuzzy matching (such as Hamming distance ≤ 1) usually adopts the method of "generating all possible mutants and then verifying". For a 32-base barcode, each query needs to generate 32×3=96 candidates, which is slow in high-concurrency scenarios.
[0023] (3) Insufficient robustness: The existing system lacks an effective verification and rescue mechanism. When the index is abnormal (such as hash collision, data corruption) or other special needs occur, it may lead to missed detection and affect the reliability of the results.
[0024] (4) Uneven resource consumption: Some methods sacrifice memory for speed or reduce accuracy for efficiency, making it difficult to achieve a balance between memory usage, query speed and result accuracy.
[0025] Based on this, according to the embodiments of this application, a method embodiment for correcting barcodes is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0026] This embodiment provides a barcode correction method, such as... Figure 1 As shown, Figure 1 This is a flowchart of a barcode correction method according to an embodiment of this application. The method includes the following steps: Step S101: Obtain the target barcode to be corrected.
[0027] Optionally, the target barcode (i.e. the barcode sequence to be queried) that needs to be "identified and corrected" can be extracted from scenarios such as gene sequencing data and sample identification processes.
[0028] In addition, the target barcode must meet basic requirements, such as a fixed length (e.g., 32 bases) and characters containing only the four bases A, T, C, and G (i.e., the four basic characters). If it does not meet these requirements, it must be filtered or a message indicating that it does not meet the basic requirements must be displayed before proceeding to the next step.
[0029] Example: The target barcode obtained is ATCGGATC...GCA (32 bases).
[0030] Step S102: Generate a pattern string at each base position in the target barcode, and replace the base at the current position with the pattern string to obtain a preset number of new target barcodes. The new target barcodes are obtained by replacing the bases with the pattern string, and the preset number is consistent with the length of the target barcode.
[0031] Optionally, for each base position of the target barcode, the base at that position is replaced with a "pattern string" (such as the wildcard "?", representing any base A / T / C / G) to generate a new sequence with the same length as the target barcode. The final number of new target barcodes is equal to the base length of the target barcode.
[0032] Specific operations: Traverse each base position i of the target barcode (0≤i<barcode length, such as traversing 32 positions sequentially); For each position i, retain the original bases of all other positions, and replace only the bases at position i with the pattern string "?"; After each position is replaced, a new target barcode is generated. After traversing the entire sequence, a new sequence of "preset quantity" (consistent with the length) is obtained.
[0033] Example: Target sequence T is ATCG... (32 bases): Replacing the 0th base yields the new target barcode 1: ?TCG...; Replacing the first base yields the new target barcode 2: A?CG...; Replacing the second base, we obtain the new target barcode 3: AT?G...; This process is repeated until 32 new target barcodes are generated (each with only one position marked "?", and the rest being identical to the target barcode).
[0034] Step S103: Match the new target barcode with each pattern candidate set constructed from the barcode whitelist. After matching the target pattern candidate set, match the new target barcode with each new reference barcode in the target pattern candidate set to obtain the first matching result. The barcode whitelist includes multiple reference barcodes. Each new reference barcode in the same pattern candidate set is formed by replacing the bases at the same position in the pattern string. The target pattern candidate set is any set in the pattern candidate set.
[0035] Optionally, the barcode whitelist consists of multiple known reference barcodes that meet the basic requirements (such as sample label sequences already labeled in the experiment), forming a matching "standard library".
[0036] When constructing the barcode whitelist, after performing "same position pattern replacement as S102" on each reference barcode, multiple pattern candidate sets are formed by grouping them according to "replacement position + pattern string". That is, for each reference barcode R, each position j is traversed to generate a new reference barcode where position j is "?" and the remaining bases remain unchanged. Then, all new reference barcodes with "the same replacement position and the same remaining string" are grouped into one category to form a pattern candidate set.
[0037] Example: The reference barcodes included in the barcode whitelist are: R1=GTCG..., R2=CTCG..., R3=ATAG.... Replace the 0th bit to generate a new reference barcode: R1=?TCG..., R2=?TCG..., R3=?TAG.... Then, R1=?TCG..., R2=?TCG..., R3=?TAG... are added to the pattern candidate set S0 of "0th bit is '?'".
[0038] For each new target barcode, based on its "pattern string replacement position", find the corresponding pattern candidate set in the whitelist. The specific process is as follows: Iterate through any new target barcode 1 (where the 0th position is "?") and match it against each pattern candidate set in the whitelist. For example, match S0 (all new reference barcodes where the 0th position is "?"), S1 (all new reference barcodes where the 1st position is "?"), S2 (all new reference barcodes where the 2nd position is "?"), and so on. If the pattern candidate set corresponding to the new target barcode does not exist (the pattern set is not in the whitelist), create a new pattern candidate set and add the new target barcode to the new pattern candidate set. If the new target barcode matches any pattern candidate set in the pattern candidate set, such as matching S0, then S0 is used as the target pattern candidate set. Perform a base comparison between the new target barcode and each new reference barcode in the S0 set (only compare "non-pattern string positions", i.e., all bases except the replacement position) to obtain the first matching result.
[0039] Example: The new target barcode 1=?TCG... (the 0th position is "?") is compared with the new reference barcode R1=?TCG... in the S0 set, and the remaining 31 bases are compared except for the 0th position.
[0040] If the number of identical or non-identical bases in the remaining 31 positions is less than the error tolerance rate (e.g., 3%), then the first matching result is a successful match; otherwise, the first matching result is a failed match.
[0041] It should be noted that when determining the comparison result between the number of inconsistent bases and the error tolerance, the Hamming distance can be used to calculate the number of base differences and thus determine the first result.
[0042] Furthermore, bitwise operations are performed between the new target barcode and the new reference barcode to obtain the Hamming distance.
[0043] A distance threshold is preset (which can be 1, meaning that the new target barcode is allowed to have ≤1 base difference from the new reference barcode, to accommodate sequence variations caused by experimental errors). This threshold can be set flexibly.
[0044] If the Hamming distance is less than or equal to a preset threshold (e.g., 1), the new target barcode is determined to match the new reference barcode, and the first matching result is considered a successful match.
[0045] Step S104: Correct the target barcode based on the first matching result and determine the inclusion relationship between the target barcode and the barcode whitelist.
[0046] Optionally, target barcodes whose Hamming distance between the new target barcode and the new reference barcode is less than or equal to a preset threshold are corrected to be correct barcodes and included in the barcode whitelist.
[0047] Other target barcodes with a first match result of "successful match" are considered correct barcodes and added to the barcode whitelist. If the Hamming distance between the new target barcode and the new reference barcode is greater than a preset threshold, the target barcode is considered incorrect and is excluded from the barcode whitelist.
[0048] In this embodiment, a pattern string is generated for each base position in the obtained target barcode to be corrected, and the base at the current position is replaced with the pattern string to obtain a preset number of new target barcodes. Then, the new target barcodes are matched against various pattern candidate sets constructed from a barcode whitelist. After matching a target pattern candidate set, the new target barcodes are matched against each new reference barcode in the target pattern candidate set to obtain a first matching result. Based on this first matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist. Thus, this embodiment achieves index mapping through positional patterns, avoiding redundant calculations that generate a certain number of mutants, solving the candidate generation explosion problem in traditional methods, reducing query complexity, significantly improving query speed, and significantly reducing computational resource consumption.
[0049] As an optional embodiment, the method further includes: Step a1: Before generating the pattern string at each base position in the target barcode, the target barcode is compressed to obtain a compressed value; Step a2: Compare the compressed value with multiple reference compressed values to obtain the comparison result, wherein the reference compressed values are included in the set of compressed values constructed from reference barcodes in the barcode whitelist; Step a3: Based on the comparison results, if it is determined that the compressed value does not match the reference compressed value, a pattern string is generated at each base position of the compressed value.
[0050] Optionally, in the embodiments of this application, for each reference barcode in the barcode whitelist, the characteristic that the barcode only has four bases A / T / C / G can be taken advantage of. For example, two bits can be used to represent one base (A=00, T=01, C=10, G=11) to compress these reference barcodes into a string and obtain a reference compressed value.
[0051] Specifically, each base (A / T / C / G) is represented by 2 bits (e.g., A=00, T=01); a 32-base barcode has a total of 32 × 2 = 64 bits; converted to bytes: 64 bits ÷ 8 = 8 bytes, thus obtaining multiple reference compressed values. These reference compressed values are then written into a compressed value set.
[0052] In this way, during subsequent queries, as long as the target barcode is also compressed into an integer to obtain the compressed value, it is possible to quickly check whether this compressed value is in the exact_set: compare the compressed value with multiple reference compressed values to obtain the comparison result.
[0053] If the compressed value matches the reference compressed value, it means that the target barcode and a reference barcode in the barcode whitelist are completely identical, confirming that the target barcode is included in the barcode whitelist; if the compressed value does not match the reference compressed value, it means that the first stage of precise matching by matching the compressed value has failed, and the second stage of matching query for "generating the pattern string of the target barcode" needs to be started.
[0054] In addition, in this embodiment of the application, before the target barcode is compressed, the original string of the target barcode (i.e. the data before compression) is added to the Bloom filter. The target barcode is mapped to a "bit array" (an array with only 0 and 1, such as an array of length 10000, where each position has only 0 or 1) through multiple hash functions. This can quickly determine "whether a certain data may exist", thereby enabling fast and accurate matching and checking.
[0055] Specifically, 1. Retrieve the original string of the reference barcode in the current barcode whitelist (e.g., "ATCG"); 2. Call multiple independent hash functions (such as Hash1, Hash2, Hash3) preset by the Bloom filter to calculate the hash value of the original string, resulting in multiple different numbers (such as Hash1=5, Hash2=8, Hash3=12). 3. Set all positions in the Bloom filter bit array corresponding to these hash values to 1 (e.g., change the 5th, 8th, and 12th bits from 0 to 1); 4. After all reference barcodes in the barcode whitelist have completed this operation, the position marked as 1 in the bit array indicates that "a whitelisted original barcode has been mapped here".
[0056] During subsequent queries, simply pass the raw string of the target barcode to `exact_bloom.might_contain(barcode)`. If the return value is "false", it means that the target barcode has not been mapped to all the flag bits of the bit array. The possibility of an exact match can be directly ruled out, and there is no need to enter the subsequent exact_set check. If the return value is "true", it means that the target barcode "may exist in the whitelist" (Bloom filters have a very small false positive rate) and needs to be checked in the exact_set check step to confirm.
[0057] In this embodiment, the barcode is stored by 2-bit encoding, which reduces memory usage by 75% compared to string storage (e.g., the 32-base barcode is reduced from 32 bytes to 8 bytes), supports larger-scale whitelist storage, and significantly improves memory efficiency.
[0058] As an optional embodiment, step S104 includes: Step S1041: If the new target barcode matches the new reference barcode, determine that the target barcode is included in the barcode whitelist; Step S1042: If the new target barcode does not match the new reference barcode, the target barcode is segmented to obtain the first segment data; Step S1043: Match the first segment data with the second segment data of each reference barcode in the barcode whitelist to obtain the second matching result; Step S1044: Correct the target barcode based on the second matching result and determine the inclusion relationship between the target barcode and the barcode whitelist.
[0059] Optionally, as in the above embodiments, when determining the matching status of the new target barcode and the new reference barcode, the Hamming distance between the new target barcode and the new reference barcode can be calculated by bitwise operations (counting the number of non-zero 2-bit groups after XOR).
[0060] Additionally, if the target barcode and reference barcode have been compressed, the Hamming distance between the compressed new target barcode and the compressed new reference barcode is calculated (by XORing and counting the number of non-zero 2-bit groups).
[0061] A distance threshold is preset (which can be 1, meaning that the new target barcode is allowed to have ≤1 base difference from the new reference barcode, to accommodate sequence variations caused by experimental errors). This threshold can be set flexibly.
[0062] If the Hamming distance is less than or equal to a preset threshold, the new target barcode is determined to match the new reference barcode.
[0063] If the Hamming distance value is greater than the preset threshold, or if the matching range is temporarily adjusted (such as allowing a larger Hamming distance), it is considered that the new target barcode has not matched the new reference barcode. In this case, LSH (LocalitySensitiveHashing) index matching mode is enabled, triggering the fault tolerance and rescue mechanism, specifically: First, create a "similarity search directory" to facilitate quickly finding sequences that are similar to the target barcode.
[0064] Specifically, the 3-gram features of reference barcodes in the barcode whitelist are generated (e.g., "ATCG" → ["ATC", "TCG"]). "3-gram" means that the reference barcode is segmented into groups of three consecutive bases, without overlap or omission. For example, in the document, the barcode "ATCG" (4 bases) is segmented into ["ATC", "TCG"] (the first group takes the first three ATC bases, and the second group takes the last three TCG bases). Another example is the longer barcode "ATCGGAT," whose 3-gram features are ["ATC", "TCG", "CGG", "GGA", "GAT"]. The reason for this is that if two barcodes are similar, their 3-gram segments will have a high degree of overlap (for example, "ATCG" and "ATCA" both have 3-grams of ["ATC", "TCG"] and ["ATC", "TCA"], with one segment being completely identical). This segment analysis allows for quick capture of "similarity."
[0065] Then, by taking the minimum value from multiple random hash functions, a random number is calculated for each 3-gram fragment (for example, "ATC" is 5 when calculated by function 1 and 8 when calculated by function 2). For each hash function, take the "minimum value" from the numbers of all 3-gram segments of that barcode (for example, if function 1 calculates numbers 5, 12, and 7, take 5; if function 2 calculates numbers 8, 3, and 10, take 3). By concatenating the "minimum values" obtained from all hash functions, a MinHash signature that can approximately preserve the similarity of the original data is generated (for example, using 3 hash functions, the final MinHash signature is [5,3,6]).
[0066] The MinHash signature is divided into multiple consecutive second segments, each second segment serving as a hash key. The same processing method is applied to the target barcode to obtain multiple consecutive first segments, each first segment serving as a hash key.
[0067] Further, step S1043 includes: Step b1: Assign the first segment of data with the same hash key to the same data bucket and identify the data bucket with the first identification information; assign the second segment of data with the same hash key to the same data bucket and identify the data bucket with the second identification information. Step b2: Match the first segment data and the second segment data in the data bucket where the first and second identification information are the same to obtain the second matching result.
[0068] Optionally, the first segment of data with the same hash key is grouped into the same data bucket, and the second segment of data with the same hash key is grouped into the same data bucket to create a similarity index.
[0069] In subsequent queries, as long as the data buckets of the first and second segments with the same hash key are found (by comparing the identification information of the data buckets), the first and second segments are compared in that data bucket to obtain the matching result (i.e. the second matching result), without having to traverse all the data.
[0070] In this embodiment, the LSH rescue mechanism can effectively compensate for missed detections and special query needs caused by index anomalies, and is especially suitable for scenarios with high reliability requirements.
[0071] As an optional embodiment, step S1044 includes: Step c1: Based on the second matching result, select candidate barcodes from the reference barcodes; Step c2: Perform bitwise operations on the target barcode and the candidate barcode to calculate the Hamming distance; Step c3: If the Hamming distance value is less than or equal to a preset threshold, determine that the target barcode is included in the barcode whitelist.
[0072] Optionally, after matching a reference barcode similar to the target barcode using the LSH index (e.g., determining from the second matching result that the similarity between the first segment data and the second segment data meets 98%), it is selected from the reference barcodes as a candidate barcode.
[0073] Optionally, if the Hamming distance between a candidate barcode and the target barcode is less than or equal to a preset threshold, it indicates that the two are highly similar (or completely identical), and the target barcode should be included in the barcode whitelist. If the Hamming distance between all candidate barcodes and the target barcode is greater than the preset threshold, it indicates that the difference between the target barcode and all reference barcodes in the whitelist is too large, and the target barcode is determined not to be included in the barcode whitelist.
[0074] In the embodiments of this application, based on base-level difference statistics (Hamming distance), and adapting to scenarios such as experimental sequencing errors, the reliability of the matching results is ensured, providing a core basis for target barcode correction.
[0075] In addition, the above embodiments can flexibly adjust the balance between speed and accuracy of the system through parameter configuration (such as threshold setting, Bloom filter error rate, etc.) to adapt to the needs of different application scenarios.
[0076] like Figure 2 As shown, Figure 2The three-layer query architecture of the barcode correction method according to the embodiments of this application includes the following process: Enter the target barcode.
[0077] Phase 1: Fast and accurate matching detection Bloom filter (fast exclusion) → exact set validation (comparison of compressed values).
[0078] Phase 2: Matching queries with Hamming distance ≤ 1 Hamming Ball Index Query (Pattern Matching) → Bitwise Operation Verification (Distance Calculation).
[0079] Phase 3: LSH Rescue Mode (triggered based on conditions) LSH candidate query (similarity search) → distance verification (missed detection supplement).
[0080] This system establishes a multi-level query verification and rescue mechanism. Through a progressive process of "fast filtering with Bloom filter – precise matching with Hamming Ball index – robust rescue", it improves system robustness, avoids missed detections, and achieves efficient and reliable barcode matching. While ensuring accuracy, it controls the average query time to the microsecond level and supports high-concurrency scenarios.
[0081] This embodiment provides a barcode correction device, such as... Figure 3 As shown, it includes: The acquisition module 301 is used to acquire the target barcode to be corrected; The replacement module 302 is used to generate a pattern string at each base position in the target barcode, and replace the base at the current position with the pattern string to obtain a preset number of new target barcodes. The new target barcodes are obtained by replacing the bases with the pattern string, and the preset number is consistent with the length of the target barcode. The matching module 303 is used to match the new target barcode with each pattern candidate set constructed from the barcode whitelist, and after matching the target pattern candidate set, to match the new target barcode with each new reference barcode in the target pattern candidate set to obtain the first matching result. The barcode whitelist includes multiple reference barcodes, and each new reference barcode in the same pattern candidate set is formed by replacing the bases at the same position in the pattern string. The target pattern candidate set is any set in the pattern candidate set. The correction module 304 is used to correct the target barcode based on the first matching result and determine the inclusion relationship between the target barcode and the barcode whitelist.
[0082] In this embodiment, a pattern string is generated for each base position in the obtained target barcode to be corrected, and the base at the current position is replaced with the pattern string to obtain a preset number of new target barcodes. Then, the new target barcodes are matched against various pattern candidate sets constructed from a barcode whitelist. After matching a target pattern candidate set, the new target barcodes are matched against each new reference barcode in the target pattern candidate set to obtain a first matching result. Based on this first matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist. Thus, this embodiment achieves index mapping through positional patterns, avoiding redundant calculations that generate a certain number of mutants, solving the candidate generation explosion problem in traditional methods, reducing query complexity, significantly improving query speed, and significantly reducing computational resource consumption.
[0083] In some alternative embodiments, the device further includes: The compression module is used to compress the target barcode into a compressed value before generating a pattern string at each base position contained in the target barcode. The comparison module is used to compare the compressed value with multiple reference compressed values and obtain the comparison result. The reference compressed values are included in the set of compressed values constructed from reference barcodes in the barcode whitelist. The first determining module is used to generate a pattern string at each base position of the compressed value when the compressed value does not match the reference compressed value based on the comparison result.
[0084] In some alternative embodiments, the device further includes: The second determining module is used to determine, after obtaining the comparison result, if the compressed value matches the reference compressed value, that the target barcode is included in the barcode whitelist.
[0085] In some optional implementations, the correction module 304 is further configured to: determine that the target barcode is included in the barcode whitelist when the new target barcode matches a new reference barcode; segment the target barcode to obtain first segment data when the new target barcode does not match a new reference barcode; match the first segment data with the second segment data of each reference barcode in the barcode whitelist to obtain a second matching result; and correct the target barcode based on the second matching result to determine the inclusion relationship between the target barcode and the barcode whitelist.
[0086] In some optional implementations, the correction module 304 is further configured to perform bitwise operations on the new target barcode and the new reference barcode to obtain the Hamming distance; if the value of the Hamming distance is less than or equal to a preset threshold, it is determined that the new target barcode matches the new reference barcode.
[0087] In some optional implementations, the correction module 304 is further configured to assign the first segment data with the same hash key to the same data bucket and identify the data bucket with first identification information; assign the second segment data with the same hash key to the same data bucket and identify the data bucket with second identification information; and match the first segment data and the second segment data in the data bucket with the same first identification information and second identification information to obtain a second matching result.
[0088] In some optional implementations, the correction module 304 is further configured to select candidate barcodes from the reference barcodes based on the second matching result; perform bitwise operations on the target barcode and the candidate barcodes to obtain the Hamming distance; and determine that the target barcode is included in the barcode whitelist if the value of the Hamming distance is less than or equal to a preset threshold.
[0089] In this embodiment, the barcode correction device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0090] This application also provides a computer device having the above-described features. Figure 3 The barcode correction device shown.
[0091] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of this application, such as... Figure 4As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 4 Take a processor 10 as an example.
[0092] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0093] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.
[0094] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0095] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0096] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0097] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0098] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for correcting barcodes, characterized in that, The method includes: Obtain the target barcode to be corrected; A pattern string is generated at each base position in the target barcode, and the base at the current position is replaced by the pattern string to obtain a preset number of new target barcodes. The new target barcodes are obtained by replacing the bases in the pattern string, and the preset number is consistent with the length of the target barcode. The new target barcode is matched with various pattern candidate sets constructed from the barcode whitelist. After matching the target pattern candidate set, the new target barcode is matched with each new reference barcode in the target pattern candidate set to obtain a first matching result. The barcode whitelist includes multiple reference barcodes. Each new reference barcode in the same pattern candidate set is formed by replacing the bases at the same position in the pattern string. The target pattern candidate set is any set in the pattern candidate set. Based on the first matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist.
2. The method according to claim 1, characterized in that, Before generating a pattern string at each base position contained in the target barcode, the method further includes: The target barcode is compressed to obtain a compressed value; The compressed value is compared with multiple reference compressed values to obtain a comparison result, wherein the reference compressed values are included in the set of compressed values constructed from reference barcodes in the barcode whitelist; Based on the comparison results, if it is determined that the compressed value does not match the reference compressed value, a pattern string is generated at each base position of the compressed value.
3. The method according to claim 2, characterized in that, After obtaining the comparison results, the method further includes: Based on the comparison results, if the compressed value matches the reference compressed value, the target barcode is determined to be included in the barcode whitelist.
4. The method according to claim 1 or 2, characterized in that, The step of correcting the target barcode based on the first matching result and determining the inclusion relationship between the target barcode and the barcode whitelist includes: If the new target barcode matches the new reference barcode, it is determined that the target barcode is included in the barcode whitelist; If the new target barcode does not match the new reference barcode, the target barcode is segmented to obtain the first segment data; The first segmented data is matched with the second segmented data of each reference barcode in the barcode whitelist to obtain the second matching result; Based on the second matching result, the target barcode is corrected to determine the inclusion relationship between the target barcode and the barcode whitelist.
5. The method according to claim 4, characterized in that, The matching of the new target barcode with the new reference barcode includes: The Hamming distance is obtained by performing bitwise operations on the new target barcode and the new reference barcode. If the Hamming distance value is less than or equal to a preset threshold, it is determined that the new target barcode matches the new reference barcode.
6. The method according to claim 4, characterized in that, The step of matching the first segmented data with the second segmented data of each reference barcode in the barcode whitelist to obtain a second matching result includes: The first segment of data with the same hash key is assigned to the same data bucket, and the data bucket is identified with a first identification information. The second segment of data with the same hash key is assigned to the same data bucket, and the data bucket is identified with a second identification information. The first segment data in the data bucket with the same first and second identification information is matched with the second segment data to obtain the second matching result.
7. The method according to claim 6, characterized in that, The step of correcting the target barcode based on the second matching result and determining the inclusion relationship between the target barcode and the barcode whitelist includes: Based on the second matching result, candidate barcodes are selected from the reference barcodes; The Hamming distance is obtained by performing bitwise operations on the target barcode and the candidate barcode; If the Hamming distance value is less than or equal to a preset threshold, the target barcode is determined to be included in the barcode whitelist.
8. A barcode correction device, characterized in that, The device includes: The acquisition module is used to acquire the target barcode to be corrected; The replacement module is used to generate a pattern string at each base position contained in the target barcode, and use the pattern string to replace the base at the current position to obtain a preset number of new target barcodes, wherein the new target barcodes are obtained by replacing the bases in the pattern string, and the preset number is consistent with the length of the target barcode; The matching module is used to match the new target barcode with various pattern candidate sets constructed from the barcode whitelist, and after matching the target pattern candidate set, to match the new target barcode with each new reference barcode in the target pattern candidate set to obtain a first matching result. The barcode whitelist includes multiple reference barcodes, and each new reference barcode in the same pattern candidate set is formed by replacing the bases at the same position in the pattern string. The target pattern candidate set is any set in the pattern candidate set. The correction module is used to correct the target barcode based on the first matching result and determine the inclusion relationship between the target barcode and the barcode whitelist.
9. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the barcode correction method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the barcode correction method according to any one of claims 1 to 7.