Metagenome-assembled genome-oriented gram attribute identification method and terminal
By constructing metagenomics to assemble the genome, extracting and fusing compositional and functional features, and using the Transformer encoder to identify Gram attributes, the problems of long time consumption and high cost of traditional methods are solved, and efficient Gram attribute identification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JILIN UNIVERSITY
- Filing Date
- 2026-03-31
- Publication Date
- 2026-05-12
AI Technical Summary
Existing bioinformatics methods are insufficient for efficiently identifying the Gram properties of metagenomically assembled genomes. Traditional experimental methods are time-consuming and costly, failing to meet the demand for efficient batch processing of large-scale pathogen metagenomic next-generation sequencing data.
A metagenomic assembly genome is constructed, and the assembled genome is screened through quality assessment. Compositional and functional features are extracted, and the genomes are mapped to the same dimensional space using a parallel mapping module. Features are fused using a cross-attention module, and feature extraction is performed using a Transformer encoder to output Gram attribute recognition results.
It improves the accuracy and efficiency of Gram attribute recognition by deeply integrating multi-dimensional information and adaptively learning feature interaction patterns, reducing reliance on manual presets and enhancing the accuracy and efficiency of recognition.
Smart Images

Figure CN122024845A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of bioinformatics technology, and in particular to a method for identifying Gram attribute of genomes for metagenomic assembly, a computer-readable storage medium, and a terminal. Background Technology
[0002] Traditional methods for identifying bacterial Gram attributes primarily rely on Gram staining experiments. This method classifies bacteria as Gram-positive or Gram-negative based on staining results and has long been considered the gold standard for bacterial classification. However, this biology-based experimental method has significant limitations: the experimental procedures are cumbersome and time-consuming, requiring specialized personnel and equipment, resulting in high human and material costs. More importantly, traditional experimental methods struggle to meet the demands of analyzing large-scale next-generation metagenomic sequencing data of pathogens, necessitating efficient and high-volume processing.
[0003] To address these challenges, researchers have developed various bioinformatics methods for predicting bacterial Gram staining. However, existing bioinformatics methods primarily target microbial data with complete taxonomic information, and for metagenomic assembly genomes (MAGs) obtained through assembly and binning in metagenomic studies, current technologies have not yet provided effective Gram attribute identification schemes. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention proposes a Gram attribute identification method, a computer-readable storage medium, and a terminal for metagenomic genome assembly, aiming to solve the problems of high cost and low efficiency in existing methods for identifying bacterial Gram attributes. Specifically: In a first aspect, a Gram attribute identification method for metagenomic assembly genomes includes the following steps: An assembled genome of the microorganism to be tested is constructed, and the assembled genome is screened using quality assessment software to retain the assembled genomes that meet the preset integrity and contamination requirements. Extracting the compositional features of the assembled genome and functional characteristics ; wherein, the constituent features After normalization of the total genome length, the functional characteristics After normalization of the total number of genes; Using a parallel first mapping module and a second mapping module, the constituent features are respectively... and the aforementioned functional features Mapping to the same-dimensional representation space yields the constituent embeddings. and functional embedding ; The above is fused by a pair of cross-attention modules. and Generate fusion features T Among them, the first cross-attention module is based on For the query, the second cross-attention module uses For Query; The fusion features T The input is a Transformer encoder for feature extraction, and the Gram attribute recognition results are output through mean pooling and a fully connected layer.
[0005] The following are preferred technical solutions of the present invention, but are not intended to limit the technical solutions provided by the present invention. The purpose and beneficial effects of the present invention can be better achieved and realized through the following preferred technical solutions.
[0006] As a preferred technical solution, the identification method, wherein constructing the assembled genome of the microorganism to be tested specifically includes: The raw DNA sequence fragments obtained from metagenomic sequencing were assembled using assembly software to obtain DNA contig sequences; The DNA contiguous sequences were clustered using binning software, and the quality of the clustering results was evaluated. Results with ≥50% integrity and ≤10% contamination were retained to obtain the assembled genome.
[0007] As a preferred technical solution, the identification method, wherein the extraction of constituent features... Specifically, it includes: The 4-mer frequencies of each DNA contig sequence in the assembled genome were extracted. The sum of all 4-mer frequencies was then divided by the total length of all DNA contig sequences to obtain the normalized 4-mer frequency characteristics. .
[0008] As a preferred technical solution, the identification method, wherein the extraction of functional features... Specifically, it includes: Identify gene coding regions in the assembled genome sequence to obtain the total number of genes. N ; Gene coding regions were annotated using functional databases, and the number of genes annotated to different databases and taxonomic levels was counted. Divide the number of genes by the total number of genes. N Normalization is performed to obtain the functional feature vector; The functional feature vector comprises a feature vector consisting of the following 27 statistical features: The number of genes annotated to the GO, COG, and KEGG databases; the number of genes annotated to the three subcategories of the COG database; the number of genes annotated to the three GO domains; and the number of genes annotated to the 18 COG secondary categories.
[0009] As a preferred technical solution, the recognition method wherein the first and second mapping modules each comprise two linear perceptron layers and use the GELU activation function; the embedding and embedding They have the same dimensions.
[0010] As a preferred technical solution, in the aforementioned recognition method, the fusion logic of the cross-attention module is as follows: The first cross-attention module uses For Query, with Given the key and value, we obtain the embedded representation. ; The second cross-attention module uses For Query, with Given the key and value, we obtain the embedded representation. ; Will and The concatenation yields a fused representation with two-dimensional values. T .
[0011] As a preferred technical solution, the identification method, wherein... The calculation formula is as follows:
[0012] in, for linear transformation, , , ; , , There are three learnable matrices, each with a dimension of 128×128; the second module uses... For Query, Given the key and value, we obtain the embedded representation. :
[0013] in, , , . , , There are three learnable matrices, each with a dimension of 128×128. and for The linear transformation of , where d is the feature dimension.
[0014] As a preferred technical solution, the recognition method wherein the Transformer encoder includes a multi-head self-attention mechanism and a feedforward neural network, and each layer of the encoder is provided with residual connections.
[0015] In a second aspect, a computer-readable storage medium stores one or more programs that can be executed by one or more processors to implement the steps in the Gram attribute identification method for metagenomic assembly of genomes as described above.
[0016] Thirdly, a terminal includes: a processor and a memory; the memory stores a computer-readable program executable by the processor; the processor executes the computer-readable program to implement the steps in the Gram attribute identification method for metagenomic assembly of genomes as described above.
[0017] Beneficial effects: Compared with existing technologies, this invention fully utilizes the multidimensional information of the genome by extracting and fusing compositional and functional features in parallel. The two types of features characterize the genome from different perspectives and have significant complementarity. By deeply fusing the two types of features, the model can obtain a more comprehensive genomic representation than a single feature, thereby improving the accuracy of Gram attribute identification. By projecting the two types of features onto the same dimensional space through independent mapping modules, the heterogeneity of the feature space is eliminated; furthermore, through a bidirectional cross-attention mechanism, the two types of features can mutually influence and reinforce each other, capturing complex relationships between features. This enables the model to adaptively learn feature interaction patterns, rather than relying on manually preset fusion rules. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a schematic diagram of the Gram attribute identification method for metagenomic assembly of genomes provided in an embodiment of the present invention.
[0020] Figure 2This is a diagram of the Gram attribute recognition model architecture based on deep learning provided in an embodiment of the present invention.
[0021] Figure 3 This is a graph showing the performance of the deep learning-based Gram attribute recognition model provided in this embodiment of the invention on a test set.
[0022] Figure 4 This is a schematic diagram of the terminal structure provided in an embodiment of the present invention. Detailed Implementation
[0023] The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and should not be construed as limiting the scope of the invention.
[0024] In the description of the embodiments of the present invention, it should be noted that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of the present invention. In addition, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0025] In the description of the embodiments of the present invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in the embodiments of the present invention based on the specific circumstances.
[0026] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0027] like Figure 1 As shown, this invention provides a Gram attribute identification method for metagenomic assembly, comprising the following steps: S100. Construct the assembled genome of the microorganism to be tested, and use quality assessment software to screen the assembled genome, retaining the assembled genome that meets the preset integrity and contamination requirements.
[0028] Specifically, metagenomic DNA is first extracted from environmental samples and subjected to high-throughput sequencing to obtain raw sequencing reads. Then, assembly software (such as MEGAHIT, metaSPAdes, etc.) is used to assemble the sequencing reads, resulting in contiguous sequences. Since metagenomic samples contain genomic fragments from various microorganisms, binning software (such as MetaBAT, MaxBin, CONCOCT, etc.) is used to cluster the contiguous sequences according to their genomic origin, resulting in different genomic bins. Each genomic bin represents a candidate microbial genome.
[0029] After obtaining the genome bins, quality assessment software (such as CheckM) is needed to calculate the integrity and contamination of each bin. Integrity reflects the proportion of conserved single-copy genes in the genome and is used to assess the integrity of the genome; contamination reflects the proportion of repetitive conserved single-copy genes in the genome and is used to assess the purity of the genome. Based on the established quality criteria (integrity ≥ 50% and contamination ≤ 10%), assembled genomes that meet the requirements are selected for subsequent analysis.
[0030] S200. Extract the compositional features of the assembled genome. and functional characteristics ; wherein, the constituent features After normalization of the total genome length, the functional feature x f After normalization of the total number of genes.
[0031] Specifically, for the assembled genome after screening, two types of features are extracted simultaneously. The compositional features are calculated using 4-mer frequencies, which is the frequency of occurrence of all nucleotide sequences of length 4 in the genome. Since there are 4 to the power of 4 (256) possible 4-mers, the compositional features are a 256-dimensional vector. To eliminate the influence of differences in genome length, the count of each 4-mer is normalized by dividing the count by the total genome length.
[0032] Functional feature extraction begins with identifying gene coding regions in the genome, which can be accomplished using gene prediction software such as Prodigal. The predicted protein sequences are then extracted and compared with functional databases (such as GO, COG, and KEGG) for annotation. Based on the annotation results, a 27-dimensional functional feature vector is constructed, with each dimension corresponding to a different functional category (such as cell wall synthesis, membrane transport, and energy metabolism). To eliminate the influence of differences in genome size, the counts of each functional dimension are normalized by dividing by the total number of genes.
[0033] S300, using the parallel first mapping module and second mapping module, respectively, the constituent features are... and the aforementioned functional features Mapping to the same-dimensional representation space yields the constituent embeddings. and functional embedding .
[0034] Specifically, due to compositional characteristics and functional characteristics Since the features reside in different feature spaces with different dimensions (256 and 27 dimensions respectively), they need to be projected to the same dimensional space through a mapping module. This embodiment uses two parallel mapping modules to process compositional features and functional features respectively. Each mapping module consists of two perceptron layers: the first layer maps the input features to an intermediate dimension, and the second layer maps the intermediate representation to the target dimension. A GELU activation function is used between the two layers to introduce non-linear transformation capability. After mapping, the compositional embedding is obtained. and functional embedding The two types of features have the same dimension and can interact in a unified representation space.
[0035] S400, the above is fused through a pair of cross-attention modules. and Generate fusion features T Among them, the first cross-attention module is based on For the query, the second cross-attention module uses For Query.
[0036] Specifically, a pair of cross-attention modules can be used to achieve deep fusion of the two types of features. The first cross-attention module uses the component feature representation as the query and the functional feature representation as the key and value, calculating the degree of attention of the component features to the functional features, and generating a component feature representation enhanced with functional information. The second cross-attention module uses the functional feature representation as the query and the component feature representation as the key and value, calculating the degree of attention of the functional features to the component features, and generating a functional feature representation enhanced with component information. The enhanced representations from the two directions are then concatenated or added to obtain the final fused feature. T .
[0037] The core idea of cross-attention is to allow associations to be established between two different sequences. When calculating the attention score, the similarity between the query and the key is measured by the dot product of the query and the key; higher similarity indicates stronger attention. Then, the attention score is normalized to a probability distribution using the softmax function, and the values are weighted and summed using this distribution to obtain the attention output. This mechanism enables the model to adaptively determine the correspondence between two types of features, rather than relying on manually pre-defined mapping rules.
[0038] S500, The fusion feature T The input is a Transformer encoder for feature extraction, and the Gram attribute recognition results are output through mean pooling and a fully connected layer.
[0039] Specifically, it will integrate features T The input is processed by a Transformer encoder. The Transformer encoder consists of multiple identical coding layers stacked together, each containing two sub-layers: a multi-head self-attention sub-layer and a feedforward network sub-layer. The multi-head self-attention sub-layer allows the model to capture dependencies between features from multiple perspectives, while the feedforward network sub-layer performs a non-linear transformation on the features at each location. The sub-layers are connected through residual connections and layer normalization, which helps alleviate the vanishing gradient problem and accelerates model convergence.
[0040] After processing by the Transformer encoder, the sequence features are aggregated into a fixed-length vector representation using a mean pooling layer, and then mapped to the output space through a fully connected layer. The output layer typically contains two neurons, corresponding to the Gram-positive and Gram-negative bacteria categories, respectively. The softmax function is used to convert the output into a probability distribution, and the category with the higher probability is taken as the final Gram attribute recognition result.
[0041] In one implementation of this embodiment, constructing the assembled genome of the microorganism to be tested specifically includes: S101. Use assembly software to assemble the original gene sequence fragments obtained from metagenomic sequencing to obtain the assembled gene.
[0042] Specifically, quality control of the raw sequencing data is required before assembly. Tools such as FastQC are used to assess sequencing data quality metrics, including base quality fraction, GC content distribution, and sequence length distribution. Tools such as Trimmomatic or FastP are used to remove low-quality bases and adapter sequences, retaining high-quality sequencing reads for subsequent assembly.
[0043] The quality-controlled reads were assembled using assembly software suitable for metagenomic data. MEGAHIT is a commonly used metagenomic assembly software that employs a de Bruijn diagram-based approach, effectively handling large-scale metagenomic data. metaSPAdes is another commonly used assembly software, performing excellently in single-cell genome and metagenomic assembly. After assembly, a series of contig sequences were obtained, each contig representing a continuous segment of the genome.
[0044] S102. Cluster the contiguous groups using binning software, and evaluate the quality of the clustered assembled genomes, retaining the assembled genomes with integrity ≥50% and contamination ≤10%.
[0045] Specifically, since metagenomic samples contain genomes of various microorganisms, it is necessary to group contiguous sequences according to their genomic origin. Genome binning is a key step in achieving this goal. MetaBAT2 is a binning software based on tetranucleotide frequency and coverage depth, which can effectively cluster contiguous sequences into different genome bins. MaxBin2 combines the expectation-maximization algorithm with coverage depth information for binning. Users can choose the appropriate binning software based on the characteristics of their data, or combine multiple software programs to achieve better binning results.
[0046] After obtaining the genome bins, it is necessary to assess the quality level of each bin. CheckM is a commonly used genome quality assessment tool that evaluates integrity and contamination by detecting the presence of conserved single-copy genes in the genome. The integrity calculation formula is: the number of conserved single-copy genes detected divided by the expected total number of conserved single-copy genes; the contamination calculation formula is: the number of conserved single-copy genes detected repeatedly divided by the total number of conserved single-copy genes detected.
[0047] According to the quality standards of this embodiment, genome bins with a completeness of no less than 50% and a contamination rate of no more than 10% are retained. This threshold setting ensures data quality while also taking into account the actual situation of metagenomic data. Overly strict quality standards may lead to the filtering out of a large number of genomes, reducing the applicability of the method; overly lenient standards may introduce low-quality data, affecting prediction accuracy. Genomes that pass the quality screening can be further optimized. Tools such as refineM are used to identify and remove possible contaminating sequences, and tools such as GapFiller are used to fill gaps in the genome. The optimized genome has higher completeness and lower contamination, which is beneficial to improving the accuracy of subsequent feature extraction.
[0048] In one implementation of this embodiment, the compositional feature uses 4-mer frequency, which is the frequency of occurrence of all nucleotide sequences of length 4 in the genome. A 4-mer refers to a nucleotide sequence of length 4. Since there are four types of nucleotides: A, T, C, and G, there are 4 to the power of 4, or 256 possible combinations of 4-mers. The calculation process for 4-mer frequency includes: scanning the assembled genome sequence and extracting all nucleotide sequences of length 4 using a sliding window method. For a genome sequence of length L, L-3 4-mer sequences can be extracted. During the scanning process, both the sense and antisense strands are considered simultaneously, or inversely complementary 4-mers are treated as the same class, depending on the analytical requirements. The occurrence frequency of each type of 4-mer is counted, constructing a 256-dimensional original counting vector. Each dimension of the vector corresponds to a specific 4-mer sequence, and the value represents the number of times that 4-mer appears in the genome.
[0049] The original count vector is normalized. The counts of each dimension are divided by the total genome length (or the total number of 4-mers) to obtain the frequency values. Normalization eliminates the influence of differences in genome length, making genomes of different sizes comparable. The normalized 4-mer frequency vector is the representation of the compositional features.
[0050] In this embodiment, the 4-mer length is moderate, capturing local sequence patterns without resulting in excessively high feature dimensionality. 2-mers and 3-mers have lower feature dimensionality (16 and 64 dimensions, respectively), but contain limited sequence information; while 5-mers and longer k-mers contain richer information, their feature dimensionality increases dramatically (1024 dimensions for 5-mers) and they are more susceptible to sequencing errors and assembly quality. 4-mer frequencies are closely related to species evolution. Different species exhibit variations in their genome base composition due to differences in genetic background and evolutionary history, which are reflected in 4-mer frequencies. Studies have shown that 4-mer frequencies can be used for species classification and phylogenetic analysis. 4-mer frequency calculation is simple and efficient, suitable for large-scale data processing. For the large amounts of genomic data in metagenomic research, computational efficiency is a crucial consideration.
[0051] In one implementation of this embodiment, the functional feature extraction process includes three main steps: gene prediction, functional annotation, and feature construction. Specifically, gene prediction software is used to identify gene coding regions in the assembled genome. Prodigal is a commonly used prokaryotic gene prediction software capable of quickly and accurately identifying protein-coding genes in the genome. Prodigal uses a dynamic programming algorithm, combined with codon usage frequency and sequence features, to predict genes, outputting the nucleotide and protein sequences of the predicted genes. For each predicted gene, its start position, end position, strand direction, and other information are recorded. Simultaneously, the protein sequence of the gene is extracted for subsequent functional annotation.
[0052] The predicted protein sequences are compared with functional databases to obtain gene functional annotation information. Commonly used functional databases include: GO (Gene Ontology) database: provides standardized gene function descriptions, including three ontology categories: molecular function, biological process, and cellular component. GO annotations reveal the functional activity of genes at the molecular level, the biological processes they participate in, and their cellular location. COG (Clusters of Orthologous Groups) database: classifies proteins according to orthologous relationships, with each COG category corresponding to a conserved functional category. COG annotations can reveal the evolutionary origin and functional conservation of genes. KEGG (Kyoto Encyclopedia of Genes and Genomes) database: integrates genomic, chemical, and systems functional information, providing annotations for biological pathways such as metabolic pathways and signal transduction pathways. KEGG annotations help understand the role of genes in metabolic networks.
[0053] Functional annotation is usually done using sequence alignment tools (such as BLAST, DIAMOND, etc.), which perform a similarity search between the query protein sequence and reference sequences in the database, and infer the function of the query sequence based on the alignment results.
[0054] Based on the functional annotation results, a 27-dimensional functional feature vector was constructed. These 27 dimensions correspond to functional categories related to Gram properties, including: cell wall synthesis-related: peptidoglycan synthesis, lipopolysaccharide synthesis, teichoic acid synthesis, etc.; membrane transport-related: ABC transporters, MFS transporters, RND transporters, etc.; energy metabolism-related: glycolysis, tricarboxylic acid cycle, electron transport chain, etc.; cell division-related: cell division proteins, septum formation, etc.; signal transduction-related: two-component systems, signal peptides, etc.; other functional categories: including DNA replication, transcriptional regulation, stress response, etc.
[0055] For each functional dimension, the number of genes annotated to that functional category in the genome is counted to construct an original count vector. Then, the counts for each dimension are normalized by dividing by the total number of genes to eliminate the influence of differences in genome size. The normalized 27-dimensional vector is the functional feature representation.
[0056] Combination Figure 2 As shown, in one implementation of this embodiment, the first mapping module and the second mapping module adopt the same network structure, both consisting of two perceptron layers. The first mapping module processes compositional features (256 dimensions), and its structure includes: a first-layer perceptron with an input dimension of 256 and an output dimension of 128. This layer compresses the high-dimensional compositional features to an intermediate dimension, extracting the main compositional patterns. The weight matrix has a size of 256×128, and the bias vector has a dimension of 128. The first-layer activation function uses the GELU (Gaussian Error Linear Unit) activation function. GELU is a smooth non-linear activation function, defined as:
[0057] in It is the cumulative distribution function of the standard normal distribution. Compared with ReLU, GELU has a non-zero gradient in the negative region, which can provide a smoother gradient flow and help improve the training stability of the model.
[0058] The second perceptron layer has an input dimension of 128 and an output dimension of 64. This layer further maps the intermediate representations to the target dimension of 64, consistent with the dimension after the functional feature mapping. The weight matrix has a size of 128×64, and the bias vector has a dimension of 64. The second activation function also uses the GELU activation function.
[0059] The second mapping module processes functional features (27 dimensions), and its structure includes: First-layer perceptron: input dimension 27, output dimension 64. Since the original functional features have a low dimension, the first layer expands the features to a higher dimension to extract richer functional patterns. The weight matrix is 27×64, and the bias vector is 64. First-layer activation function: GELU activation function. Second-layer perceptron: input dimension 64, output dimension 64. This layer maps the intermediate representation to the target dimension, consistent with the output dimension of the first mapping module. The weight matrix is 64×64, and the bias vector is 64. Second-layer activation function: GELU activation function.
[0060] After processing by two mapping modules, both compositional and functional features are mapped to a 64-dimensional representation space, allowing them to interact and merge within the same space.
[0061] In one implementation of this embodiment, a pair of cross-attention modules are used for feature fusion in order to perform more in-depth feature fusion. and Among them, the first cross-attention module uses For Query, with Given the key and value, we obtain the embedded representation. :
[0062] in, for linear transformation, , , ; , , There are three learnable matrices, each with a dimension of 128×128; The second cross-attention module uses For Query, with Given the key and value, we obtain the embedded representation. :
[0063] in, , , . , , There are three learnable matrices, each with a dimension of 128×128. and for The linear transformation of , where d is the feature dimension.
[0064] Will and The concatenation yields a fused representation with two-dimensional values. T The dimension is 2×128.
[0065] In one implementation of this embodiment, the Transformer encoder is composed of... N It is composed of stacked identical coding layers in this embodiment. N The value is 4. Each encoding layer contains two sub-layers: a multi-head self-attention sub-layer and a feedforward network sub-layer. The multi-head self-attention mechanism allows the model to capture the dependencies between features from multiple perspectives. Its basic idea is to project the query, key, and value to multiple different subspaces, compute attention independently in each subspace, and then concatenate the results of each head.
[0066] The feedforward network performs independent nonlinear transformations on the features at each location, consisting of two linear transformation layers and an activation function. Residual connections are used around each sub-layer to help alleviate the vanishing gradient problem and make the training of deep networks more stable. After being stacked through N encoding layers, the input fused features are transformed into a high-level abstract representation containing rich semantic information, suitable for the final classification task.
[0067] In one implementation of this embodiment, to ensure good predictive performance of the Gram attribute recognition method, the model needs to be sufficiently trained. The training process includes steps such as data preparation, model initialization, forward propagation, loss calculation, backpropagation, and parameter update.
[0068] Collect bacterial genomes with known Gram attributes as training data. These genomes can come from publicly available genome databases (such as NCBI RefSeq, PATRIC, etc.) or from laboratory sequencing data. For each genome, record its Gram attribute label (positive or negative).
[0069] Following the method described above, compositional and functional features are extracted from the genome. Standardizing these features to have a mean of 0 and a standard deviation of 1 helps accelerate model convergence.
[0070] The dataset is divided into training, validation, and test sets. The training set is used for learning model parameters, the validation set is used for hyperparameter tuning and model selection, and the test set is used to evaluate the final performance of the model. A typical split is 70% training set, 15% validation set, and 15% test set.
[0071] The model's weight parameters are randomly initialized. Common initialization methods include Xavier initialization and He initialization. Xavier initialization adjusts the initialization range according to the input and output dimensions and is suitable for networks using tanh or sigmoid activation functions; He initialization is designed for ReLU and its variant activation functions, using a larger initialization variance. Bias parameters are initialized to 0.
[0072] The training samples are input into the model, and following the processing flow described above, they sequentially undergo feature mapping, cross-attention fusion, Transformer encoding, pooling, and classification to obtain the predicted output. The cross-entropy loss function is used to measure the difference between the predicted output and the true label.
[0073] The gradient of the loss function with respect to each parameter is calculated using the chain rule. Starting from the output layer, the gradient is calculated layer by layer forward until the input layer.
[0074] The model parameters are updated based on gradients using an optimization algorithm. The process of forward propagation, loss calculation, backpropagation, and parameter update is repeated until the model converges or reaches the preset number of training epochs. During training, the model performance is periodically evaluated on the validation set, and checkpoints showing the best performance are saved. Training results can be referenced. Figure 3 As shown.
[0075] Based on the above-described method for Gram attribute identification in metagenomic genome assembly, this invention also provides a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement the steps in the above-described method for Gram attribute identification in metagenomic genome assembly.
[0076] Based on the Gram attribute identification method for metagenomic assembly described in the above embodiments, this invention also provides a terminal, such as... Figure 4 As shown, it includes at least one processor 30; a display screen 31; and a memory 32, and may also include a communications interface 33 and a bus 34. The processor 30, display screen 31, memory 32, and communications interface 33 can communicate with each other via the bus 34. The display screen 31 is configured to display a preset user guide interface in the initial setup mode. The communications interface 33 can transmit information. The processor 30 can invoke logical instructions in the memory 32 to execute the methods described in the above embodiments.
[0077] Furthermore, the logic instructions in the aforementioned memory 32 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.
[0078] The memory 32, as a computer-readable storage medium, can be configured to store software programs, computer-executable programs, such as program instructions or modules corresponding to the methods in the embodiments of this disclosure. The processor 30 executes functional applications and data processing by running the software programs, instructions, or modules stored in the memory 32, thereby implementing the methods in the above embodiments.
[0079] The memory 32 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal. Furthermore, the memory 32 may include high-speed random access memory (RAM) and non-volatile memory. Examples include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks; these can also be transient storage media.
[0080] Furthermore, the specific process of loading and executing multiple instruction processors in the aforementioned storage medium and terminal has been described in detail in the above method, and will not be repeated here.
[0081] Finally, it should be noted that the above embodiments are only for illustrating the present invention and not for limiting the present invention. Although the present invention has been described in detail with reference to the embodiments, those skilled in the art should understand that various combinations, modifications, or equivalent substitutions of the technical solutions of the present invention do not depart from the spirit and scope of the technical solutions of the present invention and should be covered within the scope of the claims of the present invention.
Claims
1. A method for identifying Gram attribute information in metagenomic assembly, characterized in that, Includes the following steps: An assembled genome of the microorganism to be tested is constructed, and the assembled genome is screened using quality assessment software to retain the assembled genomes that meet the preset integrity and contamination requirements. Extracting the compositional features of the assembled genome and functional characteristics ; wherein, the constituent features After normalization of the total genome length, the functional characteristics After normalization of the total number of genes; Using a parallel first mapping module and a second mapping module, the constituent features are respectively... and the aforementioned functional features Mapping to the same-dimensional representation space yields the constituent embeddings. and functional embedding ; The component embedding is fused through a pair of cross-attention modules. and functional embedding Generate fusion features T Among them, the first cross-attention module is based on For the query, the second cross-attention module uses For Query; The fusion features T The input is a Transformer encoder for feature extraction, and the Gram attribute recognition results are output through mean pooling and a fully connected layer.
2. The identification method according to claim 1, characterized in that, The construction of the assembled genome of the microorganism to be tested specifically includes: The raw DNA sequence fragments obtained from metagenomic sequencing were assembled using assembly software to obtain DNA contig sequences; The DNA contiguous sequences were clustered using binning software, and the quality of the clustering results was evaluated. Results with ≥50% integrity and ≤10% contamination were retained to obtain the assembled genome.
3. The identification method according to claim 1, characterized in that, The extracted composition features Specifically, it includes: The 4-mer frequencies of each DNA contig sequence in the assembled genome were extracted. The sum of all 4-mer frequencies was then divided by the total length of all DNA contig sequences to obtain the normalized 4-mer frequency characteristics. .
4. The identification method according to claim 1, characterized in that, The extraction function features Specifically, it includes: Identify gene coding regions in the assembled genome sequence to obtain the total number of genes. N ; Gene coding regions were annotated using functional databases, and the number of genes annotated to different databases and taxonomic levels was counted. Divide the number of genes by the total number of genes. N Normalization is performed to obtain the functional feature vector; The functional feature vector comprises a feature vector consisting of the following 27 statistical features: The number of genes annotated to the GO, COG, and KEGG databases; the number of genes annotated to the three subcategories of the COG database; the number of genes annotated to the three GO domains; and the number of genes annotated to the 18 COG secondary categories.
5. The identification method according to claim 1, characterized in that, The first and second mapping modules each contain two linear perceptron layers and use the GELU activation function; the constituent embedding and functional embedding They have the same dimensions.
6. The identification method according to claim 1, characterized in that, The fusion logic of the cross-attention module is as follows: The first cross-attention module uses For Query, with Given the key and value, we obtain the embedded representation. ; The second cross-attention module uses For Query, with Given the key and value, we obtain the embedded representation. ; Will and The concatenation yields a fused representation with two-dimensional values. T .
7. The identification method according to claim 6, characterized in that, The The calculation formula is as follows: in, for linear transformation, , , ; , , There are three learnable matrices, each with a dimension of 128×128; the second cross-attention module uses... For Query, Given the key and value, we obtain the embedded representation. : in, , , . , , There are three learnable matrices, each with a dimension of 128×128. and for The linear transformation of , where d is the feature dimension.
8. The identification method according to claim 1, characterized in that, The ransformer encoder includes a multi-head self-attention mechanism and a feedforward neural network, and each encoder layer is equipped with residual connections.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more processors to implement the steps in the Gram attribute identification method for metagenomic assembly of genomes as described in any one of claims 1 to 8.
10. A terminal, characterized in that, include: A processor and a memory; the memory stores a computer-readable program that can be executed by the processor; when the processor executes the computer-readable program, it implements the steps in the Gram attribute identification method for metagenomic assembly of genomes as described in any one of claims 1 to 8.