Metagenome classification method and system
By generating l-mer sequences and constructing hash tables, combined with the implicit knowledge of deep learning models, the problems of time-consuming and low-accuracy metagenomic species classification were solved, achieving fast and accurate species classification and improving classification accuracy and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ACADEMY OF MILITARY MEDICAL SCIENCES
- Filing Date
- 2026-01-16
- Publication Date
- 2026-04-28
AI Technical Summary
Existing metagenomic species classification methods suffer from problems such as excessive time consumption or low accuracy. In particular, when faced with sequences with high genetic variation, it is difficult to distinguish biological signals from background noise, leading to a decrease in classification accuracy.
By generating l-mer sequences, calculating biological semantic scores and establishing a mapping table, extracting feature substrings within a window and constructing a hash table, and using 64-bit integer hash values for querying, combined with the implicit knowledge of deep learning models, fast and accurate species classification is achieved.
Without increasing computational costs, it significantly improves the accuracy and robustness of species classification, effectively handles sequences containing complex variations, avoids noise interference, and preserves high-value biological signals.
Smart Images

Figure CN121938467A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of metagenomic bioinformatics analysis technology, and in particular to a metagenomic classification method and system. Background Technology
[0002] With the widespread adoption of second- and third-generation sequencing technologies, metagenomics has generated massive amounts of data, placing extremely high demands on the speed and accuracy of species identification and functional analysis.
[0003] However, existing methods for classifying metagenomics suffer from problems such as excessive time consumption or low accuracy. Therefore, designing a method for rapid and accurate metagenomic classification is an urgent problem to be solved. Summary of the Invention
[0004] The purpose of this application is to provide a metagenomic classification method and system that can be used to achieve rapid and accurate species classification.
[0005] In response to the existing problems, this application provides the following solutions: Firstly, this application provides a metagenomic classification method, including: Generate length is l The complete sequence of all DNA base combinations is denoted as . l- The MER sequence, based on a pre-trained genome model, is used to calculate the values for each of the MER sequences. l- Biological semantic scores of mer sequences were established. l- A mapping table between MER sequences and biological semantic scores; Obtain a set of reference genome sequences to be indexed; For each of the aforementioned reference genome sequences, with a length of [missing information]... k The window slides along a preset step size on the reference genome sequence to extract sequence fragments within each window; Perform feature extraction for each window: extract the sequence fragments within the window of length [length missing]. M All candidate feature substrings, among which, l ≤ M ≤ k The candidate feature substring is decomposed into partially overlapping substrings of length [missing information]. l The basic semantic unit, based on l- The mapping table between mer sequences and biological semantics is used to obtain the average biological semantic score of all the basic semantic units, which is used as the semantic quality score of the candidate feature substring; the candidate feature substring with the highest semantic quality score is selected as the feature of the window. For each feature, the 64-bit integer hash value of the feature is used as the key, and the species classification ID of the reference genome sequence to which the feature belongs is used as the value, and the hash table is stored. Receive raw sequencing read data, which includes multiple reads; For each read length, with a length of... k The window slides along the preset step size on the read length, extracts the sequence fragments in each window, and performs the feature extraction operation on each window to obtain a feature query set of the read length composed of the features of all windows. For each feature in the feature query set, the 64-bit integer hash value of the feature is used as the key to retrieve the species classification ID of the feature from the hash value table; For each read length, the species classification of the read length is obtained by querying the species classification ID of each feature in the feature query set based on the read length.
[0006] In one embodiment, the biological semantic score is a weighted composite of a semantic structure integrity score, an intrinsic information complexity score, and a semantic rarity reward score.
[0007] In one implementation, the semantic structure integrity score is calculated through the following steps: l- The MER sequence is input into the word segmenter of a pre-trained genome-based model to obtain... l- The smallest semantic unit contained in a mer sequence, where, l- The fewer the number of smallest semantic units in a MER sequence, the higher its average length. l- The higher the semantic structure integrity score of the mer sequence, the better.
[0008] In one implementation, the intrinsic information complexity score is calculated through the following steps: Calculate l- The normalized Shannon entropy of the Mer sequence, where, l- The lower the normalized Shannon entropy value of the Mer sequence, the better. l- The lower the intrinsic information complexity score of a Mer sequence.
[0009] In one implementation, the semantic rarity reward score is calculated through the following steps: Will l- The MER sequence is input into the word segmenter of a pre-trained genome-based model to obtain... l- The smallest semantic unit contained in a mer sequence; Retrieve the rarity ID of the smallest semantic unit in the vocabulary of the pre-trained genome-based model, where, l- The higher the rarity ID of the smallest semantic unit contained in a mer sequence, the better. l-The higher the semantic rarity score of a mer sequence, the better.
[0010] In one embodiment, when a window contains multiple candidate feature substrings with the highest semantic quality score, the 64-bit integer hash value of each candidate feature substring with the highest semantic quality score is calculated, and the candidate feature substring with the smallest 64-bit integer hash value among the candidate feature substrings with the highest semantic quality score is selected as the feature of the window.
[0011] In one embodiment, when a feature belongs to multiple different reference genome sequences, the species classification IDs of each reference genome sequence to which the feature belongs are collectively stored as the value of the feature in a hash table; or, the lowest common ancestor ID of the species classification IDs of each reference genome sequence to which the feature belongs is calculated, and the lowest common ancestor ID is stored as the value of the feature in a hash table.
[0012] In one embodiment, obtaining the species classification of the read length based on the species classification ID of each feature in the feature query set includes: Calculate the lowest common ancestor ID of the species classification IDs of all features in the feature query set of the read length, and use the species classification corresponding to the lowest common ancestor ID as the species classification of the read length.
[0013] In one embodiment, after obtaining the classification of each of the raw sequencing reads, the metagenomic classification method further includes: Based on the species classification of each read length, the number of reads for each species classification in the original sequencing read data is obtained; Based on the number of reads for each species classification in the raw sequencing read data, the relative abundance of each species classification in the raw sequencing read data is calculated. Generate a report containing the species classification of each species in the raw sequencing read data, the species classification ID corresponding to each species classification, and the relative abundance of each species classification; or output a file containing the species classification of each species in the raw sequencing read data, the species classification ID corresponding to each species classification, and the relative abundance of each species classification.
[0014] Secondly, this application provides a metagenomic classification system, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned metagenomic classification method.
[0015] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a metagenomic classification method and system, which first generates... l- Mer sequences, based on a pre-trained genome model, are calculated for each...l- Biological semantic scores of mer sequences and the establishment of l- A mapping table between MER sequences and biological semantic scores is generated; next, a set of reference genome sequences to be indexed is obtained; then, for each reference genome sequence, a length of [missing information] is generated. k The window slides along a preset step size on the reference genome sequence, extracting sequence fragments within each window; then, feature extraction is performed on each window: extracting sequence fragments of length [missing information]. M All candidate feature substrings; decompose the candidate feature substrings into partially overlapping substrings of length. l The basic semantic unit, based on l- A mapping table between MER sequences and biological semantics is used to obtain the average biological semantic score of all basic semantic units, which is then used as the semantic quality score of candidate feature substrings. The candidate feature substring with the highest semantic quality score is selected as the feature of the window. Next, for each feature, the 64-bit integer hash value of the feature is used as the key, and the species classification ID of the reference genome sequence to which the feature belongs is used as the value, and these are stored in a hash table. Then, raw sequencing read data is received, which includes multiple reads. Finally, for each read, a sequence is generated based on its length. k The window slides along the read length with a preset step size, extracting sequence segments within each window, and performing feature extraction operations on each window to obtain a feature query set for the read length composed of features from all windows; then, for each feature in the feature query set, the 64-bit integer hash value of the feature is used as the key to retrieve the species classification ID of the feature in the hash value table; finally, for each read length, the species classification of the read length is obtained based on the species classification IDs of each feature in the feature query set of the read length. The implicit biological knowledge of the deep learning model is transformed into an explicit feature selection strategy. Specifically, by pre-compiling biological semantic scores offline and constructing a hash index, the online classification process is transformed into a query operation with a time complexity of O(1), which can significantly improve computational efficiency. At the same time, the biological semantic scores are introduced to... l- Quantitative scoring of MER sequences avoids interference from noisy sequences and prevents the loss of high-value biologically specific signals. It can effectively distinguish biological signals from background noise. At the same time, it uses the average biological semantic score of all basic semantic units as the semantic quality score of candidate feature substrings. It can effectively solve the problem of decreased classification sensitivity caused by genetic variations such as insertions, deletions or single nucleotide polymorphisms in the sequence. It can effectively handle sequences containing complex variations and can lock sequence fragments that still retain core semantic information in the context of variation. Ultimately, it can solve the problem that existing algorithms suffer from a significant drop in accuracy when dealing with highly genetically varied sequences and cannot distinguish between biological signals and background noise. It achieves a breakthrough improvement in species classification accuracy and robustness without sacrificing computational efficiency. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of a metagenomic classification method in one embodiment of this application; Figure 2 This is a flowchart of a combined embodiment of a metagenomic classification method according to this application. Detailed Implementation
[0018] 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, and 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] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] The inventors of this application have discovered that existing computational methods for processing metagenomic data mainly fall into two technical routes: one is the exhaustive alignment paradigm represented by BLAST and BWA, which finds the best matching position by performing detailed base-level alignment between the sequencing sequence and the reference genome, thus providing high accuracy; the other is the heuristic substring indexing paradigm, which was developed to solve the bottleneck of large-scale data processing, represented by tools such as Kraken2. In order to pursue extremely high processing speed, this type of method adopts a sparse sampling strategy based on the Minimizer algorithm, that is, according to manually set syntax rules (such as hash value or lexicographical order), specific k-mers are selected as representatives to build the index within a sliding window, and the species classification is quickly determined by accurately matching these selected substrings.
[0021] While exhaustive alignment methods, such as BLAST, are highly accurate, they rely on detailed base-level alignments, resulting in extremely high computational complexity and excessive time consumption when processing large-scale metagenomic data.
[0022] Minimizer algorithms, exemplified by Kraken2, rely entirely on manually defined syntactic rules (such as hash value size or lexicographical order) for feature selection (sampling). This sampling is completely unaware of the biological significance of the sequences. Consequently, the index may contain not only low-complexity noisy sequences but also lose valuable biologically specific signals, limiting the upper limit of classification accuracy.
[0023] Existing fast classification algorithms based on exact matching often fail to distinguish between conserved sequences and variant-sensitive sequences due to the randomness of their sampling. When genetic variations such as insertions, deletions, or single nucleotide polymorphisms (SNPs) exist in the sequencing sequence, the selected k-mers are easily rendered ineffective, leading to a sharp decrease in classification sensitivity and making it difficult to effectively handle real samples containing complex variations.
[0024] Therefore, given the existence of the aforementioned technical problems, such as Figure 1 As shown, this application provides a metagenomic classification method, which is executed by a computer device. Specifically, it can be executed by a computer device such as a terminal or server alone, or by both a terminal and a server. The method includes the following steps S1 to S9. Wherein: In step S1, a length of [length missing] is generated. l The complete sequence of all DNA base combinations is denoted as . l- Mer sequences, based on a pre-trained genome model, are calculated for each... l- Biological semantic scores of mer sequences and the establishment of l- Mapping table between MER sequences and biological semantic scores L score ; In step S1, a set of reference genome sequences to be indexed is obtained; In step S1, for each reference genome sequence, with a length of k The window slides along a preset step size on the reference genome sequence to extract sequence fragments within each window; In step S4, feature extraction is performed on each window: the sequence fragments within the window with a length of... M All candidate feature substrings, among which, l ≤ M ≤ k Decompose the candidate feature substring into partially overlapping substrings of length . l The basic semantic unit, based on l- The mapping table between MER sequences and biological semantics is used to obtain the average biological semantic score of all basic semantic units, which is used as the semantic quality score of candidate feature substrings; the candidate feature substring with the highest semantic quality score is selected as the feature of the window. In step S5, for each feature (i.e., the feature of each window), the 64-bit integer hash value of the feature (obtained through calculation) is used as the key and the species classification ID of the reference genome sequence to which the feature belongs is used as the value, and stored in the hash table; In step S6, raw sequencing read data is received, which includes multiple reads; In step S7, for each read length, the length is... k The window slides along the read length with a preset step size, extracts the sequence fragments in each window, and performs feature extraction operation on each window to obtain a feature query set of the read length consisting of the features of all windows (here, the features of all windows refer to the features of all windows in the read length). In step S8, for each feature in the feature query set, the 64-bit integer hash value of the feature (obtained through calculation) is used as the key to retrieve the species classification ID of the feature from the hash value table; In step S9, for each read length, the species classification ID of each feature in the feature query set based on the read length is used to obtain the species classification of the read length.
[0025] The metagenomic classification method in this application first generates... l- Mer sequences, based on a pre-trained genome model, are calculated for each... l- Biological semantic scores of mer sequences and the establishment of l- A mapping table between MER sequences and biological semantic scores is generated; next, a set of reference genome sequences to be indexed is obtained; then, for each reference genome sequence, a length of [missing information] is generated. k The window slides along a preset step size on the reference genome sequence, extracting sequence fragments within each window; then, feature extraction is performed on each window: extracting sequence fragments of length [missing information]. M All candidate feature substrings; decompose the candidate feature substrings into partially overlapping substrings of length. l The basic semantic unit, based on l- A mapping table between MER sequences and biological semantics is used to obtain the average biological semantic score of all basic semantic units, which is then used as the semantic quality score of candidate feature substrings. The candidate feature substring with the highest semantic quality score is selected as the feature of the window. Next, for each feature, the 64-bit integer hash value of the feature is used as the key, and the species classification ID of the reference genome sequence to which the feature belongs is used as the value, and these are stored in a hash table. Then, raw sequencing read data is received, which includes multiple reads. Finally, for each read, a sequence is generated based on its length. kThe window slides along the read length with a preset step size, extracting sequence segments within each window, and performing feature extraction operations on each window to obtain a feature query set for the read length composed of features from all windows; then, for each feature in the feature query set, the 64-bit integer hash value of the feature is used as the key to retrieve the species classification ID of the feature in the hash value table; finally, for each read length, the species classification of the read length is obtained based on the species classification IDs of each feature in the feature query set of the read length. The implicit biological knowledge of the deep learning model is transformed into an explicit feature selection strategy. Specifically, by pre-compiling biological semantic scores offline and constructing a hash index, the online classification process is transformed into a query operation with a time complexity of O(1), which can significantly improve computational efficiency. At the same time, the biological semantic scores are introduced to... l- Quantitative scoring of MER sequences avoids interference from noisy sequences and prevents the loss of high-value biologically specific signals. It can effectively distinguish biological signals from background noise. At the same time, it uses the average biological semantic score of all basic semantic units as the semantic quality score of candidate feature substrings. It can effectively solve the problem of decreased classification sensitivity caused by genetic variations such as insertions, deletions or single nucleotide polymorphisms in the sequence. It can effectively handle sequences containing complex variations and can lock sequence fragments that still retain core semantic information in the context of variation. Ultimately, it can solve the problem that existing algorithms suffer from a significant drop in accuracy when dealing with highly genetically varied sequences and cannot distinguish between biological signals and background noise. It achieves a breakthrough improvement in species classification accuracy and robustness without sacrificing computational efficiency.
[0026] Below, for reference Figure 1 and Figure 2 The metagenomic classification method of the embodiments of this application will be described in detail, wherein, Figure 1 This is a flowchart of a metagenomic classification method according to an embodiment of this application. Figure 2 This is a flowchart of a combined embodiment of a metagenomic classification method according to this application.
[0027] In an exemplary embodiment of this application, steps S1 to S5 are offline construction stages, and steps S6 to S9 are online real-time classification stages.
[0028] In an exemplary embodiment of this application, in step S1, the complete sequence of all DNA base combinations refers to the complete sequence of adenine, thymine, cytosine, and guanine, and in this step, 4... 11 indivual l- Mer sequence. Among them, l It can take any suitable value. l For example, it could be 11bp. For instance, l- The mer sequence is generated in memory.
[0029] In one exemplary embodiment of this application, the pre-trained genome base model may include, but is not limited to, DNABert2-117M.
[0030] In an exemplary embodiment of this application, in step S1, the biological semantic score is introduced... l- Quantitative scoring of MERS sequences avoids interference from noisy sequences and prevents the loss of high-value biologically specific signals, effectively distinguishing biological signals from background noise. The biological semantic score is a weighted composite of semantic structure integrity score, intrinsic information complexity score, and semantic rarity reward score.
[0031] Specifically, the semantic structure integrity score is calculated through the following steps: l- The MER sequence is input into the tokenizer of a pre-trained genome-based model to obtain... l- The smallest semantic unit (token) contained in a mer sequence, where, l- The fewer the number of smallest semantic units in a MER sequence, the higher its average length. l- The higher the semantic structure integrity score of the mer sequence, the better. l- Mer sequences are more in line with the "grammar rules" of the genome and have a more complete structure.
[0032] The intrinsic information complexity score is calculated using the following steps: Calculate l- The normalized Shannon entropy of the Mer sequence, where the lower the entropy value of the normalized Shannon entropy (e.g., continuous AAAA or simple repeating patterns), the better. l- The lower the intrinsic information complexity score of the MER sequence, the better. This intrinsic information complexity score is used to automatically identify and suppress low-complexity biological noise.
[0033] The semantic rarity reward score is calculated using the following steps: l- The MER sequence is input into the word segmenter of a pre-trained genome-based model to obtain... l- The smallest semantic unit contained in the mer sequence; retrieve the rarity ID of the smallest semantic unit in the vocabulary of the pre-trained genome-based model, where, l- The higher the rarity ID of the smallest semantic unit contained in a mer sequence, the better. l- The higher the semantic rarity score of a MER sequence, the higher its reward score. During training, the genome-based model assigns high-rarity IDs to rare minimum semantic units and rewards minimum semantic units containing high-rarity IDs. l- Mer sequences provide nonlinear rewards to amplify the weight of specific signals.
[0034] In this way, the biological semantic score is composed of multi-dimensional scores, which can further avoid the interference of noisy sequences and avoid losing high-value biological specific signals, and can further distinguish biological signals from background noise.
[0035] In one exemplary embodiment of this application, step S1 cleverly separates the time-consuming deep learning inference process (which typically requires GPU acceleration) from the real-time classification path. This allows subsequent steps to obtain knowledge guidance from state-of-the-art AI models at extremely low computational cost (table lookup), achieving a perfect fusion of "deep learning accuracy" and "hash algorithm speed".
[0036] In an exemplary embodiment of this application, in step S2, a set of reference genome sequences to be indexed, G={(Sequence...}, can be obtained from a standard database (such as NCBIRefSeq). i TaxonID i The database can customize categories according to user needs, such as bacteria, archaea, fungi, viruses, and host (e.g., human) genomes. Among these, Sequence... i Indicates the first i One reference genome sequence, TaxonID i Indicates the first i A species classification ID for each reference genome sequence. For example, there is a one-to-one correspondence between species classification and species classification ID.
[0037] In an exemplary embodiment of this application, in step S3, the sequence fragment within each captured window can be represented as W = [b i , b i+1 , ..., b i+k−1 The preset step size can be 1 bp or any other suitable value. k It can take any suitable value, for example, k It can be 31bp.
[0038] In an exemplary embodiment of this application, in step S4, the sequence segment with a length of [length missing] within the window can be extracted by sliding or enumeration. M Taking the extraction of all candidate feature substrings (Candidate Minimizers) using a sliding method with a sliding step size of 1bp as an example, it can extract the sequence segments within the window. k - M +1 candidate feature substrings. More specifically, when k and M When both are 31bp, one candidate feature substring can be extracted; when k For 35bp, MWhen the length is 31bp, five candidate feature substrings can be extracted.
[0039] In an exemplary embodiment of this application, in step S4, in order to evaluate the biological value of each candidate feature substring, this application does not directly hash it, but adopts a "divide and conquer" evaluation strategy. For each candidate feature substring, it is decomposed into partially overlapping substrings of length [missing information]. l The basic semantic units are defined as follows: Candidate feature substrings can be decomposed into basic semantic units using sliding or enumeration methods. Taking the sliding method with a sliding step size of 1bp as an example, the candidate feature substring can be decomposed into... M - l +1 basic semantic unit.
[0040] In an exemplary embodiment of this application, in steps S4 and S7, when there are multiple candidate feature substrings with the highest semantic quality scores within a window, the 64-bit integer hash value of each candidate feature substring with the highest semantic quality score is calculated, and the candidate feature substring with the smallest 64-bit integer hash value among the candidate feature substrings with the highest semantic quality scores is selected as the feature of the window to ensure the determinism of the algorithm.
[0041] Thus, this application adopts the "use" l evaluate M ,use M represent k The hierarchical mechanism utilizes the smoothing effect of moving averages: even if a candidate feature substring as long as 31bp contains a mutation of 1-2 bases (SNP), as long as most of its internal substrings contain SNPs, the mechanism will still be considered as a whole. l The semantic units of the bp remain intact, and the overall average score of the candidate feature substring will still be high, thus enabling it to win in window competition. This makes the present invention exhibit robustness exceeding that of traditional exact matching algorithms when facing insertions, deletions, and mutations.
[0042] In an exemplary embodiment of this application, in step S5, feature extraction is performed on each window of all reference genome sequences in the set of reference genome sequences to be indexed. It is possible that the same feature is extracted from windows of different reference genome sequences, which indicates that the feature belongs to multiple different reference genome sequences (i.e., the feature is a non-specific feature). For example, when a feature is extracted from one window of a reference genome sequence, it means that the feature belongs to that reference genome sequence.
[0043] In an exemplary embodiment of this application, when a feature belongs to multiple different reference genome sequences, the species classification IDs of each reference genome sequence to which the feature belongs are collectively stored as the value of the feature in a hash table. Alternatively, the lowest common ancestor ID of the species classification IDs of each reference genome sequence to which the feature belongs is calculated, and the lowest common ancestor ID is stored as the value of the feature in a hash table. For example, a list of multiple species classification IDs to which the feature belongs can be stored and stored as the value of the feature in a hash table.
[0044] In one exemplary embodiment of this application, after all reference genome sequences have been scanned, the hash table in memory contains all semantically filtered high-value features and their classification. This data structure can be serialized into a binary file and stored on disk for loading during the online classification phase.
[0045] In one exemplary embodiment of this application, in step S6, raw sequencing reads data are received from a sequencing platform (such as Illumina).
[0046] In one exemplary embodiment of this application, for each read length to be classified, the operation logic is performed that is completely "symmetrical" to steps S3 and S4: for each read length, with a length of... k The window slides along the read length with a preset step size, extracting sequence segments within each window, and performing feature extraction on each window: extracting sequence segments of length [missing information]. M All candidate feature substrings, among which, l ≤ M ≤ k Decompose the candidate feature substring into partially overlapping substrings of length . l The basic semantic unit, based on l- A mapping table between MER sequences and biological semantics is used to obtain the average biological semantic score of all basic semantic units, which is then used as the semantic quality score of candidate feature substrings. The candidate feature substring with the highest semantic quality score is selected as the feature of the window. Finally, a feature query set consisting of the features of all windows is obtained. M R .
[0047] Thus, this application utilizes the "stability of local semantic maxima." Within a window, the highest-scoring "core semantic unit" (i.e., the candidate feature substring with the highest semantic quality score) is usually an evolutionarily conserved functional region. Even if the background sequence around this core unit undergoes mutations, insertions, or deletions, as long as the core unit itself is not destroyed, it will still be stably selected by the algorithm because its score is much higher than the surrounding background noise. This mechanism allows the present invention to "see through" surface sequence variations and accurately anchor conserved biological signals, thereby exhibiting extremely high robustness when processing highly variable samples.
[0048] In an exemplary embodiment of this application, in step S8, the feature query set is traversed. M R For each feature, its hash value is used as the key for retrieval in an offline-loaded hash database. Due to the characteristics of the hash database, the time complexity of a single query remains O(1) regardless of the database size (how many species it contains). Thus, although this application introduces complex semantic analysis logic, since all computational overhead has been absorbed in the preceding offline stages (steps S1 to S5) and feature selection stage (step S7), the core matching process still maintains a speed comparable to the world's fastest tools such as Kraken2.
[0049] In an exemplary embodiment of this application, a read may hit multiple features, and these features may point to different species (e.g., some features point to "E. coli" and some to "Salmonella"). Based on the species classification IDs of each feature in the feature query set, the species classification of the read is obtained, including: calculating the Lowest Common Ancestor (LCA) ID of the species classification IDs of all features in the feature query set of the read, and using the species classification corresponding to the LCA ID as the species classification of the read. Exemplarily, a taxonomy tree structure can be used to calculate the LCA ID of the species classification IDs of all features in the feature query set of the read. In this way, if a read's features point to two genera simultaneously, the LCA algorithm will classify the read at their common "family" level, rather than forcibly classifying it to a specific genus. This ensures the scientific validity and accuracy of the classification results and reduces the false positive rate.
[0050] In an exemplary embodiment of this application, after obtaining the classification of each raw sequencing read data, the metagenomic classification method further includes: obtaining the number of reads for each species classification in the raw sequencing read data based on the species classification of each read; calculating the relative abundance of each species classification in the raw sequencing read data based on the number of reads for each species classification in the raw sequencing read data; generating a report containing each species classification in the raw sequencing read data, the species classification ID corresponding to each species classification, and the relative abundance of each species classification, or outputting a file containing each species classification in the raw sequencing read data, the species classification ID corresponding to each species classification, and the relative abundance of each species classification for downstream analysis. The output file is a standard format file.
[0051] An embodiment in this application, as a combination of the above embodiments, such as... Figure 2 As shown, the metagenomic classification method of this application includes an offline database construction stage and an online real-time classification stage, wherein: During the offline database construction phase, the first step is to generate... l- The complete MER sequence, based on the DNABert2 genome model, is obtained from three dimensions: semantic structural integrity, intrinsic information complexity, and semantic rarity. l- Biological semantic scores of mer sequences were obtained, and a semantic score lookup table was constructed (i.e., l- Mapping table between MER sequences and biological semantic scores L score Next, obtain the reference genome (i.e., the set of reference genome sequences), and select it using a sliding window. k- mers (i.e., based on length) k The window slides along a preset step size on the reference genome sequence, extracting sequence fragments within each window, and then extracts candidate Minimizers within that window; the candidate Minimizers are traversed and decomposed into... l -mers (decomposes the candidate feature substring into partially overlapping substrings of length 1) l (basic semantic unit); query L score The average score is calculated as the Minimizer score (i.e., the semantic quality score of the candidate feature substring); the Minimizer with the highest score is compared and selected as the representative (i.e., the feature); a hash index is constructed: Key=Hash (i.e., the 64-bit integer hash value of the feature is used as the key), Value=TaxonID (i.e., the species classification ID of the reference genome sequence to which the feature belongs is used as the value).
[0052] In the online real-time classification phase, firstly, the raw sequencing reads (i.e., raw sequencing read data including multiple read lengths) are processed; then, a sliding window is used to select... k- mers (i.e., based on length) k The window slides along a preset step size on the reference genome sequence, extracting sequence fragments within each window, and then extracts candidate Minimizers within that window; the candidate Minimizers are traversed and decomposed into... l -mers (decomposes the candidate feature substring into partially overlapping substrings of length 1) l (basic semantic unit); query L score The average score is calculated as the Minimizer score (i.e., the semantic quality score of the candidate feature substring); the highest-scoring Minimizer is compared and selected as the representative (i.e., the feature); the feature set is obtained; a high-speed hash query is performed (i.e., the 64-bit integer hash value of the feature is used as the key to search the hash value table to obtain the species classification ID of the feature), and it is determined whether the hash value table is hit. If it is not hit, it is marked as unclassified. If it is hit, it is aggregated with LCA evidence and determined by species. Finally, the relative abundance is calculated and the sample classification is output.
[0053] In one exemplary embodiment of this application, a metagenomic dataset simulating Illumina sequencing was constructed to simulate human pharyngeal swab samples after host removal treatment. The reference genome for this dataset was derived from the NCBI RefSeq database, covering humans and five major microbial domains (archaea, bacteria, fungi, protozoa, and viruses). To ensure broad microbial diversity, 50 species were randomly selected from each microbial domain, totaling 250 microbial species, as positive controls. Simultaneously, sequences were generated from random regions of the 50 human genomes and variants were introduced to simulate widespread host genome contamination as negative controls. To closely approximate the community structure of real oral pharyngeal swab samples, the proportion of reads contributed by different species in the final mixed dataset was set as follows: bacteria (95.5%), human host remnants (3%), fungi (0.9%), viruses (0.5%), and protozoa and archaea (0.05% each). To test the robustness of all algorithms, multiple types of genetic variation were systematically introduced into all microbial reference genomes. The final generated simulated reads were intentionally designed with the following source proportions: original sequence (10%), sequence containing multiple site variations (30%), sequence containing insertion / deletion variations (30%), and sequence containing structural variations (30%).
[0054] The final sensitivity (%), specificity (%), and computation time (minutes) of the method (XDetector) obtained in this application were 16.99, 100.00, and 0.72, respectively. In contrast, the sensitivity (%), specificity (%), and computation time (minutes) of mainstream algorithms in related technologies were as follows: Megablast algorithm: 15.29, 100.00, and 309.14, respectively; Bowtie2 algorithm: [missing data - likely a missing value]. The computation times (in minutes) for the BWA algorithm were 5.45, 100.00, and 38.95, respectively. The sensitivity (%), specificity (%), and computation time (in minutes) for the MetaPhlAn2 algorithm were 16.46, 92.93, and 55.92, respectively. The sensitivity (%), specificity (%), and computation time (in minutes) for the MetaPhlAn2 algorithm were 0.14, 100.00, and 0.89, respectively. The sensitivity (%), specificity (%), and computation time (in minutes) for the Kraken2 algorithm were 16.84, 99.88, and 11.62, respectively. Therefore, the metagenomic classification method proposed in this application has higher sensitivity and specificity than mainstream algorithms in related technologies, and its computation time is also very short.
[0055] In summary, the metagenomic classification method proposed in this application first generates... l- Mer sequences, based on a pre-trained genome model, are calculated for each... l- Biological semantic scores of mer sequences and the establishment of l- A mapping table between MER sequences and biological semantic scores is generated; next, a set of reference genome sequences to be indexed is obtained; then, for each reference genome sequence, a length of [missing information] is generated. k The window slides along a preset step size on the reference genome sequence, extracting sequence fragments within each window; then, feature extraction is performed on each window: extracting sequence fragments of length [missing information]. M All candidate feature substrings; decompose the candidate feature substrings into partially overlapping substrings of length. l The basic semantic unit, based on l- A mapping table between MER sequences and biological semantics is used to obtain the average biological semantic score of all basic semantic units, which is then used as the semantic quality score of candidate feature substrings. The candidate feature substring with the highest semantic quality score is selected as the feature of the window. Next, for each feature, the 64-bit integer hash value of the feature is used as the key, and the species classification ID of the reference genome sequence to which the feature belongs is used as the value, and these are stored in a hash table. Then, raw sequencing read data is received, which includes multiple reads. Finally, for each read, a sequence is generated based on its length. kThe window slides along the read length with a preset step size, extracting sequence segments within each window, and performing feature extraction operations on each window to obtain a feature query set for the read length composed of features from all windows; then, for each feature in the feature query set, the 64-bit integer hash value of the feature is used as the key to retrieve the species classification ID of the feature in the hash value table; finally, for each read length, the species classification of the read length is obtained based on the species classification IDs of each feature in the feature query set of the read length. The implicit biological knowledge of the deep learning model is transformed into an explicit feature selection strategy. Specifically, by pre-compiling biological semantic scores offline and constructing a hash index, the online classification process is transformed into a query operation with a time complexity of O(1), which can significantly improve computational efficiency. At the same time, the biological semantic scores are introduced to... l- Quantitative scoring of MER sequences avoids interference from noisy sequences and prevents the loss of high-value biologically specific signals. It can effectively distinguish biological signals from background noise. At the same time, it uses the average biological semantic score of all basic semantic units as the semantic quality score of candidate feature substrings. It can effectively solve the problem of decreased classification sensitivity caused by genetic variations such as insertions, deletions or single nucleotide polymorphisms in the sequence. It can effectively handle sequences containing complex variations and can lock sequence fragments that still retain core semantic information in the context of variation. Ultimately, it can solve the problem that existing algorithms suffer from a significant drop in accuracy when dealing with highly genetically varied sequences and cannot distinguish between biological signals and background noise. It achieves a breakthrough improvement in species classification accuracy and robustness without sacrificing computational efficiency.
[0056] This application also provides a metagenomic classification system, including a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the computer program to implement the metagenomic classification method described above.
[0057] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0058] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0059] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0060] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A metagenomic classification method, characterized in that, include: Generate length is l The complete sequence of all DNA base combinations is denoted as . l- The MER sequence, based on a pre-trained genome model, is used to calculate the values for each of the MER sequences. l- Biological semantic scores of mer sequences were established. l- A mapping table between MER sequences and biological semantic scores; Obtain a set of reference genome sequences to be indexed; For each of the aforementioned reference genome sequences, with a length of... k The window slides along a preset step size on the reference genome sequence to extract sequence fragments within each window; Perform feature extraction for each window: extract the sequence fragments within the window of length [length missing]. M All candidate feature substrings, among which, l ≤ M ≤ k The candidate feature substring is decomposed into partially overlapping substrings of length [missing information]. l The basic semantic unit, based on l- The mapping table between mer sequences and biological semantics is used to obtain the average biological semantic score of all the basic semantic units, which is used as the semantic quality score of the candidate feature substring; the candidate feature substring with the highest semantic quality score is selected as the feature of the window. For each feature, the 64-bit integer hash value of the feature is used as the key, and the species classification ID of the reference genome sequence to which the feature belongs is used as the value, and the hash table is stored. Receive raw sequencing read data, which includes multiple reads; For each read length, with length as k The window slides along the preset step size on the read length, extracts the sequence fragments in each window, and performs the feature extraction operation on each window to obtain a feature query set of the read length composed of the features of all windows. For each feature in the feature query set, the 64-bit integer hash value of the feature is used as the key to retrieve the species classification ID of the feature from the hash value table; For each read length, the species classification of the read length is obtained by querying the species classification ID of each feature in the feature query set based on the read length.
2. The metagenomic classification method according to claim 1, characterized in that, The biological semantic score is a weighted composite of the semantic structure integrity score, the intrinsic information complexity score, and the semantic rarity reward score.
3. The metagenomic classification method according to claim 2, characterized in that, The semantic structure integrity score is calculated using the following steps: l- The MER sequence is input into the word segmenter of a pre-trained genome-based model to obtain... l- The smallest semantic unit contained in a mer sequence, where, l- The fewer the number of smallest semantic units in a MER sequence, the higher its average length. l- The higher the semantic structure integrity score of the mer sequence, the better.
4. The metagenomic classification method according to claim 2, characterized in that, The intrinsic information complexity score is calculated using the following steps: Calculate l- The normalized Shannon entropy of the Mer sequence, where, l- The lower the normalized Shannon entropy value of the Mer sequence, the better. l- The lower the intrinsic information complexity score of a Mer sequence.
5. The metagenomic classification method according to claim 2, characterized in that, The semantic rarity reward score is calculated using the following steps: Will l- The MER sequence is input into the word segmenter of a pre-trained genome-based model to obtain... l- The smallest semantic unit contained in a mer sequence; Retrieve the rarity ID of the smallest semantic unit in the vocabulary of the pre-trained genome-based model, where, l- The higher the rarity ID of the smallest semantic unit contained in a mer sequence, the better. l- The higher the semantic rarity score of a mer sequence, the better.
6. The metagenomic classification method according to claim 1, characterized in that, When a window contains multiple candidate feature substrings with the highest semantic quality score, calculate the 64-bit integer hash value of each candidate feature substring with the highest semantic quality score, and select the candidate feature substring with the smallest 64-bit integer hash value among the candidate feature substrings with the highest semantic quality score as the feature of the window.
7. The metagenomic classification method according to claim 1, characterized in that, When a feature belongs to multiple different reference genome sequences, the species classification IDs of each reference genome sequence to which the feature belongs are used together as the value of the feature and stored in a hash table. Alternatively, the lowest common ancestor ID of the species classification IDs of each reference genome sequence to which the feature belongs is calculated and stored in a hash table as the value of the feature.
8. The metagenomic classification method according to claim 1, characterized in that, The process of obtaining the species classification of the read length based on the species classification ID of each feature in the feature query set includes: Calculate the lowest common ancestor ID of the species classification IDs of all features in the feature query set of the read length, and use the species classification corresponding to the lowest common ancestor ID as the species classification of the read length.
9. The metagenomic classification method according to claim 1, characterized in that, After obtaining the classification of each of the raw sequencing reads, the metagenomic classification method further includes: Based on the species classification of each read length, the number of reads for each species classification in the original sequencing read data is obtained; Based on the number of reads for each species classification in the raw sequencing read data, the relative abundance of each species classification in the raw sequencing read data is calculated. Generate a report containing the species classification of each species in the raw sequencing read data, the species classification ID corresponding to each species classification, and the relative abundance of each species classification; or output a file containing the species classification of each species in the raw sequencing read data, the species classification ID corresponding to each species classification, and the relative abundance of each species classification.
10. A metagenomic classification system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the metagenomic classification method according to any one of claims 1-9.