A virus identification method based on a multi-head attention mechanism and a graph isomorphism neural network

By combining multi-head attention mechanism and graph isomorphic neural network, a composite model is constructed, which solves the problems of database dependence and insufficient feature capture in existing virus identification strategies, and achieves fast and accurate virus identification, especially the identification of unknown viruses.

CN118506872BActive Publication Date: 2026-11-24NORTHEAST FORESTRY UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410646841.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2026-11-24
Estimated Expiration
2044-05-23

AI Technical Summary

Technical Problem

Existing virus identification strategies rely on existing databases, which cannot effectively identify new viruses. Furthermore, manually designed features and single deep learning models cannot capture multi-dimensional features, resulting in low virus identification efficiency.

Method used

A combined approach using multi-head attention mechanism and graph isomorphic neural network is employed. The multi-head attention mechanism captures global dependencies in gene sequences, while the graph isomorphic network captures local topological features, thus constructing a composite model for virus identification.

Benefits of technology

It enables rapid and accurate identification of viruses, especially unknown viruses, avoiding the sequence comparison process and improving the efficiency and accuracy of virus identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118506872B_ABST
    Figure CN118506872B_ABST
Patent Text Reader

Abstract

This application discloses a virus identification method based on a multi-head attention mechanism and a graph isomorphic neural network, relating to the fields of deep learning and biological sequencing technology. The method includes: preprocessing the contiguous groups of viruses and prokaryotic gene sequences in the RefSeq library; constructing a multi-head attention mechanism and graph isomorphic neural network model; using K-fold cross-validation to obtain the optimal parameters of the model; preprocessing the metagenomic gene sequence to be identified; and inputting the preprocessed metagenomic sequence into the virus identification model to obtain the virus identification result. This invention can quickly and accurately identify virus sequences, and the trained end-to-end deep learning model overcomes the problems of excessive reliance on databases and long processing times associated with traditional methods, possessing the ability to identify unknown viruses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the fields of deep learning and biological sequencing technology, and in particular relates to a virus identification method based on multi-head attention mechanism and graph isomorphic neural network. Background Technology

[0002] Viruses are among the most abundant biological entities on Earth, widely distributed in various environments including soil, oceans, and the human body. They play crucial roles in the microbial environment by controlling host populations and acting as mediators of gene transfer. Compared to virus discovery methods that rely on laboratory culture, metagenomic sequencing technology can extract all genetic material directly from large samples without culturing. This method overcomes the limitations of traditional approaches, rapidly and accurately determining gene sequence information, greatly accelerating virus discovery, and has become the primary method for gene sequencing.

[0003] However, precisely because of the lack of culturing, a large number of sequences extracted by metagenomics techniques lack information such as classification and host. In microbial community research, whether studying temperate viruses for horizontal gene transfer exploration or virulent viruses for phage therapy, accurate and rapid identification of viruses from metagenomic sequencing data is a primary prerequisite. Therefore, virus identification has always been a hot topic in the field of microbial research.

[0004] Because both virulent and mild viruses can integrate the host's genetic material into their own genome, local sequence similarities exist between the viral and host genomes. These shared regions pose a challenge to distinguishing viruses from their hosts.

[0005] Existing virus identification strategies include:

[0006] 1. Calculate the similarity between the gene sequence to be detected and existing viruses, and infer whether the gene sequence to be detected is a virus based on the similarity. This strategy relies heavily on existing databases; however, compared to the total number of viruses, the number of viruses recorded in the current database is very limited, making it impossible to identify new viruses. The gene sequence to be detected needs to be compared with existing virus database sequences sequentially, and the comparison process is extremely time-consuming, which is the main reason hindering the application of this method. Many unknown viruses exist in microbial communities, and their similarity to known viruses in the current database is low, so similarity-based methods cannot effectively identify new viruses.

[0007] 2. Based on the characteristics of the virus, features are manually designed, and a machine learning model is trained using these features to perform virus identification tasks. This strategy requires manual feature design, which is a huge task. Moreover, the quality of the manually designed features greatly affects the accuracy of virus identification, further increasing the difficulty of the virus identification task.

[0008] 3. Utilize viral and non-viral databases to train deep learning models such as CNNs and LSTMs. For example, use convolutional neural networks to perform convolution operations on the one-hot encoded matrix of codons or use LSTM to capture the dependencies between codons. Then, use the trained deep learning model for virus identification tasks. However, this strategy often uses only one model and can only capture features in a single dimension, failing to effectively capture all features. Summary of the Invention

[0009] To overcome the shortcomings of existing technologies, this invention provides a virus identification method based on multi-head attention mechanism and graph isomorphic neural network. For the large amount of gene sequence data generated by metagenomic sequencing technology, multi-head attention mechanism and graph isomorphic neural network are used for training, and the multi-head attention mechanism and graph isomorphic neural network model is used to identify virus sequences.

[0010] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0011] A virus identification method based on multi-head attention mechanism and graph isomorphic neural network, the method comprising the following steps:

[0012] Step 1: Preprocess the contiguous groups of virus and prokaryotic gene sequences in the RefSeq library for training the model in Step 2;

[0013] Step 2: Construct a multi-head attention mechanism and a graph isomorphic neural network model;

[0014] Step 3: Use K-fold cross-validation to obtain the optimal parameters of the model;

[0015] Step 4: Preprocess the metagenomic gene sequences to be identified;

[0016] Step 5: Input the preprocessed metagenomic sequence into the virus identification model to obtain the virus identification result.

[0017] Further, step 1 specifically includes:

[0018] Step 1.1: Filter out the viral and prokaryotic gene sequences extracted from the RefSeq library that are longer than 999bp, cut them into 999bp gene sequence fragments without overlap, and discard the last fragment that is not long enough to meet the 999bp requirement.

[0019] Step 1.2: Label the gene sequence fragments cut from the viral gene sequence as positive samples and assign them label 1; label the gene sequence fragments cut from the prokaryotic gene sequence as negative samples and assign them label 0.

[0020] Step 1.3: Cut the fixed-length gene sequence fragment into three-base segments and convert them into a 333-digit sequence according to the codon correspondence table;

[0021] Step 1.4: Ensure that all test data in the test set conforms to the characteristics of the first discovery of viral contigs in actual applications. According to the release date of the viral contigs, divide the whole genome of the viral (bacteriophage) samples into training set and test set; for example, divide the whole genome of viral samples released before 2020 into training set for training the model to be trained, and divide the whole genome of viral samples released after 2020 into test set for testing the model to be trained.

[0022] Step 1.5: Ensure data balance (using the smaller number of viruses as a benchmark, maintain a 1:1 ratio between viruses and hosts (non-viruses)) to avoid bias in the model towards a certain type of sample during training due to data imbalance; based on the number of viral gene sequence fragments that have been converted into numbers, randomly select the same number of prokaryotic gene sequence fragments and adjust their distribution in the training set and test set so that the ratio of training data to test data is 4:1 or 9:1.

[0023] Furthermore, step 2 specifically includes:

[0024] Step 2.1: The model mainly includes an embedding layer, a multi-head attention layer, a layer normalization layer, a graph isomorphic convolutional layer (GINConv), a global add pooling layer, a batch normalization layer, a fully connected layer (FC), a dropout layer, a concat layer, and an activation layer to extract features from the input data. The multi-head attention layer captures global dependencies, obtains the feature matrix and weight matrix, and further transforms them into an edge adjacency matrix. The batch normalization layer adjusts the input of each layer of the neural network to a standard normal distribution with a variance of 1 and a variance of 0. The activation layer uses ReLU and softmax functions to prevent neuron death and gradient vanishing problems during model training. The global add pooling layer is used to extract multi-level features. The dropout layer discards neurons during training at a certain proportion to prevent overfitting.

[0025] Step 2.2: Calculate the loss value between the predicted label and the true label using the cross-entropy loss function, and use the Adam optimizer to optimize the parameters in the model so that the parameters can be fitted to the output by performing a non-linear transformation on the input gene sequence, thereby minimizing the loss function.

[0026] Further, step 3 specifically involves: evaluating deep learning algorithm-based models (including convolutional neural networks, multi-head attention mechanisms, and graph isomorphic neural networks) using K-fold cross-validation. K-fold cross-validation divides the dataset into training and testing sets. When the sample size is insufficient, to fully utilize the dataset for testing the algorithm's performance, the dataset is randomly divided into K parts. Each time, one part is used as the testing set, and the remaining K-1 parts are used as the training set for training. The specific evaluation process is as follows: First, different combinations of hyperparameters (human-set and adjusted parameters, such as learning rate, edge generation threshold, etc.) are set. The parameter settings can be manually set to 10 or 5 groups. K-fold cross-validation is performed on each group of parameters to obtain the average accuracy (the accuracy obtained from K-fold cross-validation is not random). Then, the hyperparameter group with the highest accuracy is taken as the optimal parameters.

[0027] Furthermore, the K-fold cross-validation method uses 5-fold cross-validation to obtain the final accuracy of the model.

[0028] Furthermore, step 4 specifically includes:

[0029] Step 4.1: Filter out gene sequences longer than 999bp from metagenomic sequencing data. For each gene sequence, randomly cut 10 sequence fragments of fixed length 999bp from a random starting point. The sequence fragments may overlap. For example, a sequence of length 5000bp may randomly reach position 9, and then cut 999bp sequence fragments from the next position, which may randomly reach position 111. In this way, 10 fragments are randomly cut.

[0030] Step 4.2: Cut the sequence fragment into three bases at a time and convert it into a 333-bit number sequence according to the codon correspondence table.

[0031] Furthermore, step 5 includes the following:

[0032] Step 5.1: Input the 10 pre-processed sequence fragments cut from each contiguous group of the gene sequence to be tested into the optimized virus recognition model to obtain 10 predicted probabilities;

[0033] Step 5.2: The 10 predicted probabilities obtained for each gene sequence are summed and averaged. The label at the position with the highest probability is taken as the prediction result. If the predicted label is 1, the contiguous group of the gene sequence is a virus. If the predicted label is 0, the contiguous group of the gene sequence is a non-virus.

[0034] This invention discloses a virus identification method based on multi-head attention mechanism and graph isomorphic neural network. The method utilizes multi-head attention to capture the global dependencies between codons in a gene sequence, obtaining the codon feature vector matrix and relation weight matrix. Based on a set edge threshold, an adjacency matrix is ​​constructed between highly correlated codons. The codon feature matrix and the edge adjacency matrix are then input into the graph isomorphic network, which captures local topological features, transforming the virus identification problem into a graph classification task. This model uses a composite model to capture multi-dimensional gene sequence features. The model is trained based on virus sequences discovered in a virus database. The final model can capture features from known viruses that are also distributed in unknown viruses. Furthermore, since there is no sequence alignment step, the model is not dependent on a database. Therefore, the model has the ability to identify unknown viruses and can quickly, accurately, and effectively address the problem of virus identification from gene sequence fragments generated by metagenomic sequencing. Attached Figure Description

[0035] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the examples of this application 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.

[0036] Figure 1 This is a flowchart of a virus identification method based on a multi-head attention mechanism and a graph isomorphic neural network disclosed in an embodiment of this application;

[0037] Figure 2 This is a schematic diagram illustrating the conversion of gene sequence contigs into digital sequences according to an embodiment of this application;

[0038] Figure 3 This is a schematic diagram of the model structure constructed in this application;

[0039] Figure 4 This is a schematic diagram of a method for generating a codon feature matrix and an edge adjacency matrix using an attention mechanism, as described in this application.

[0040] Figure 5 This is a schematic diagram illustrating the principle of K-fold cross-validation used in an embodiment of this application. Detailed Implementation

[0041] The technical solutions in 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, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.

[0042] like Figure 1 As shown in the figure, this application discloses a flowchart of a virus identification method based on a multi-head attention mechanism and a graph isomorphic neural network, including the following steps:

[0043] Step 1: Preprocess the contiguous groups of viral and prokaryotic gene sequences in the RefSeq library;

[0044] Specifically, step 1 includes the following:

[0045] Step 1.1: Filter out the viral and prokaryotic gene sequences extracted from the RefSeq library that are longer than 999 bp, cut them into 999 bp fragments without overlap, and discard the last fragment that is not 999 bp long.

[0046] Step 1.2: Label the gene sequence fragments cut from the viral gene sequence as positive samples and assign them label 1; label the gene sequence fragments cut from the prokaryotic gene sequence as negative samples and assign them label 0.

[0047] Step 1.3: Cut the fixed-length gene sequence fragment into three-base segments and convert them into a 333-length numerical sequence according to the codon correspondence table.

[0048] Step 1.4: Ensure that all test data in the test set conforms to the characteristics of the first discovery of viral contigs in actual applications. Divide the whole genomes of phage samples into training and test sets according to the release date of the viral contigs. For example, divide the whole genomes of viral samples released before 2020 into the training set for training the model to be trained, and divide the whole genomes of viral samples released after 2020 into the test set for testing the model to be trained.

[0049] Step 1.5: Ensure data balance to avoid bias in model training due to data imbalance, which could lead to the model favoring one type of sample. Using the number of viral gene sequence fragments converted to numbers as a baseline, randomly select the same number of prokaryotic gene sequence fragments and adjust their distribution in the training and test sets to ensure a 9:1 ratio between training and test data.

[0050] Figure 2 This is an example of the present application, illustrating the conversion of gene sequence contigs into digital sequences, as shown in the diagram. Figure 3As shown in one example of this application, the contiguous gene sequence is first cut into gene sequence fragments of fixed length 999bp. The last fragment that does not meet the 999bp length condition is directly discarded. The base information of one gene sequence fragment is ATTTAGCGCAATGGACCTAAGCAA. The gene sequence is cut into three bases at a time, into ATT, TAG, CGC, AAT, GGA, CCT, AAG, and CAA. Then, according to the codon correspondence table (AAA:0, AAC:1, AAG:2, ..., TTC:61, TTG:62, TTT:63), each cut codon is converted into a number. Finally, each 999bp gene sequence fragment is converted into a 333-bit number sequence.

[0051] Step 2: Construct a multi-head attention mechanism and a graph isomorphic neural network model;

[0052] Specifically, step 2 includes the following:

[0053] Step 2.1: The model mainly includes an embedding layer, a multi-head attention layer, a layer normalization layer, a graph isomorphic convolutional layer (GINConv), a global add pooling layer, a batch normalization layer, a fully connected layer (FC), a dropout layer, a concat layer, and an activation layer to extract features from the input data. The multi-head attention layer captures global dependencies, obtaining the feature matrix and weight matrix, which are further transformed into an edge adjacency matrix. Batch normalization adjusts the input of each layer of the neural network to a standard normal distribution with a variance of 1 and a minimum of 0. The activation layer uses ReLU and softmax functions to prevent neuron death and gradient vanishing problems during model training. The global add pooling layer is used to extract multi-level features. The dropout layer discards neurons during training at a certain ratio to prevent overfitting.

[0054] Step 2.2: Calculate the loss value between the predicted label and the true label using the cross-entropy loss function, and use the Adam optimizer to optimize the parameters in the model so that the parameters can be fitted to the output by performing a non-linear transformation on the input gene sequence, thereby minimizing the loss function.

[0055] Figure 3 A schematic diagram of the model structure constructed for an embodiment of the present invention; Figure 3The order cannot be changed. First, the input enters the embedding layer, where a preprocessed sequence of numbers of length 333 is embedded. The embedding is essentially a dictionary containing the embeddings of 64 codons. When a codon is input, the embedding layer outputs a vector with a fixed embedding dimension. This method chooses an embedding dimension of 100, so the 333-length sequence after the embedding layer is embedded into a 333×100 matrix. Since the multi-head attention mechanism does not include positional information, the matrix is ​​input into the position embedding layer to incorporate positional information. Then, it is input into the multi-head attention module (the main part of the multi-head attention module is the multi-head attention layer, which uses layer normalization layers, residual connections, and random dropout layers to prevent overfitting). Figure 4 Similarly, the correlation between codons is captured to obtain the adjacency matrix of edges and the feature matrix incorporating global dependencies. Then, it is input into three graph isomorphism modules (the graph isomorphism module mainly contains two fully connected layers, and the global accumulation pooling layer is used to accumulate the 333×100 dimension feature matrix into a 100-length vector, representing the graph features) to distinguish the graph structure generated by the multi-head attention module. Then, the output vectors of each graph isomorphism module are concatenated, and the concatenated vector is input into fully connected layer 1, batch normalization layer 1, random dropout layer 1, and fully connected layer 2 in sequence, and finally the result is output.

[0056] 1. Embedding layer

[0057] Embedding layers map discrete symbols (such as words, characters, or other entities) into a continuous, high-dimensional space. This layer trains the model to transform each unique symbol into a fixed-length dense vector. These vectors represent the semantic features of the symbol, ensuring that semantically similar symbols are close together in the embedding space, thus providing an effective feature representation for various downstream tasks. Embedding not only significantly reduces the complexity of the model in processing high-dimensional sparse data but also significantly improves the model's performance in tasks such as language understanding, text classification, and sentiment analysis by capturing rich semantic relationships. In this embodiment, an embedding dimension of 100 is used, embedding all 64 codons into 100-dimensional vector representations.

[0058] 2. Multi-head attention layer

[0059] Multi-head attention layers are based on the multi-head attention mechanism and are used to capture global dependencies in sequence models. In this embodiment, a multi-head attention layer is used to capture global dependencies between codons, outputting a feature vector matrix of the codons. Furthermore, using a codon relation weight matrix, edges are constructed between highly correlated codons, generating an adjacency matrix of the edges.

[0060] Figure 4 This is a schematic diagram illustrating how an attention mechanism is used to generate a codon feature matrix and an edge adjacency matrix according to an embodiment of the present invention. The calculation formula for the multi-head self-attention neural network model is as follows:

[0061]

[0062] Head h =AttentionWeights h V h

[0063] MultiHeadOutput=Concat(Head1,Head2,...,Head H W O

[0064] Where: Q = [q1, q2, q3, ..., q n K = [k1,k2,k3,...,k] n V = [v1, v2, v3, ..., v] n This involves creating a query vector, key vector, and value vector for each codon. is the dimension of the key vector, used to scale the dot product to prevent excessively large values ​​from causing the softmax function to enter regions with small gradients. h is the number of multi-head attention points, AttentionWeights is the weight matrix, and W... O This is the output of the previous layer. For example... Figure 4 As shown, after obtaining the codon relation weight matrix, if the number of heads is 1, it is directly used to generate the adjacency matrix of the edges; if there are multiple heads, the multiple relation weight matrices are averaged. Positions with weights greater than a threshold are converted to 1, representing that an edge is constructed between the codons corresponding to that position, and vice versa, they are converted to 0, representing that there is no edge between the codons corresponding to that position. First, the Q and K matrices are used to obtain the weight matrix using the first formula. Then, the feature matrix is ​​multiplied by the V matrix to obtain the feature matrix with fully local dependencies, which is 333×100. Each codon is regarded as a node in the graph neural network. Using the weight matrix (333×333), a threshold is set, and weights greater than the threshold are converted to 1, and weights less than or equal to the threshold are converted to 0, thus obtaining the adjacency matrix of the edges.

[0065] 3. Layer Normalization

[0066] Layer normalization is a normalization technique proposed in RNNs. It normalizes each neuron along the channel dimension, ensuring that the activation values ​​within the same layer have the same distribution. In this embodiment, layer normalization layers are superimposed on multi-head attention layers to accelerate model training.

[0067] 4. Graph Isomorphic Convolutional Layer

[0068] Graph Isomorphic Networks (GINs) enhance the representativeness of traditional graph neural networks by generalizing the Weisfeiler-Lehman (WL) test. GINs generate a neighborhood node feature aggregator using an injective function learned by an MLP, making the non-isomorphic graph embedding representation discrete. Its performance in distinguishing different graph structures achieves the same effect as the Weisfeiler-Lehman (WL) test. Embodiments of this application use graph isomorphic layers to distinguish graph structures formed from multi-head attention layers for graph classification tasks.

[0069] 5. Global cumulative pooling layer

[0070] Global accumulating pooling layers are used to extract useful features. Adding a global accumulating pooling layer after the graph isomorphic convolutional layer can effectively reduce the size of the parameter matrix. In this embodiment, a global accumulating pooling layer is added after each graph isomorphic convolutional layer to effectively capture graph structure feature information.

[0071] 6. Batch Normalization Layer

[0072] In Batch Normalization (BN), a batch refers to a batch of data. The data distribution is readjusted before it is fed into the activation function, accelerating the gradient descent calculation. In this embodiment, a BN layer is used to adjust the input of each layer of the neural network to a standard normal distribution with a mean of 0 and a variance of 1, thus accelerating model training.

[0073] 7. Random Drop-off Layer

[0074] When training a neural network, there are a large number of neurons. Therefore, a random dropout layer is added to temporarily discard some neurons from the neural network with a certain probability, so as to speed up the training of the model and enhance the generalization of the neural network. When the neural network is used, the discarded neurons are reconnected.

[0075] 8. Activation layer

[0076] Common activation functions include the Sigmoid, Tanh, ReLU, and Leaky ReLU functions. Using activation functions can solve the problems of neuron death and gradient vanishing. The ReLU function converges faster than the Sigmoid and Tanh functions. The softmax function transforms the output of the fully connected layers of the neural network, making the output follow a probability distribution, which facilitates better observation of classification results. Therefore, this embodiment uses both ReLU and softmax activation functions.

[0077] Step 3: Use K-fold cross-validation to obtain the optimal parameters of the model;

[0078] Specifically, step 3 includes the following:

[0079] Step 3.1: Use K-fold cross-validation to evaluate the model based on the deep learning algorithm. K-fold cross-validation divides the dataset into training and test sets. In the case of insufficient sample size, in order to make full use of the dataset to test the algorithm's performance, the dataset is randomly divided into K parts. Each time, one part is used as the test set, and the remaining K-1 parts are used as the training set for training.

[0080] Preferably, the K-fold cross-validation method in step 3.1 uses 5-fold cross-validation to obtain the final accuracy of the model.

[0081] Step 4: Preprocess the metagenomic gene sequences to be identified;

[0082] Specifically, step 4 includes the following:

[0083] Step 4.1: Filter out contiguous gene sequences longer than 999 bp from the metagenomic sequencing data, and randomly cut each contiguous gene sequence into 10 fragments of fixed length 999 bp starting point;

[0084] Step 4.2: Cut the sequence fragment into three bases at a time and convert it into a 333-bit number sequence according to the codon correspondence table.

[0085] Step 5: Input the preprocessed metagenomic sequence into the virus identification model to obtain the virus identification result.

[0086] Specifically, step 5 includes the following:

[0087] Step 5.1: Input the 10 pre-processed sequence fragments cut from each gene sequence to be tested into the optimized virus recognition model to obtain 10 predicted probabilities;

[0088] Step 5.2: The 10 predicted probabilities obtained for each gene sequence are summed and averaged. The label at the position with the highest probability is taken as the prediction result. If the predicted label is 1, the contiguous group of the gene sequence is a virus. If the predicted label is 0, the contiguous group of the gene sequence is a non-virus.

[0089] Figure 5This diagram illustrates the principle of K-fold cross-validation. To improve the model's generalization performance and robustness, this embodiment uses K-fold cross-validation to optimize the model and obtain the final model accuracy. K-fold cross-validation divides the dataset into a training set and a test set. When sample data is insufficient, to fully utilize the dataset for testing the algorithm's performance, the dataset is randomly divided into K parts. Each time, one part is used as the test set, and the remaining K-1 parts are used as the training set for training. Specifically, the dataset is randomly divided into 5 equal parts; one part is selected as the test set, and the remaining 4 parts are used as the training set to train the model and test its performance; this process is repeated, selecting each part as the test set and the others as the training set, for a total of 5 iterations; the average accuracy of the 5 test results is calculated as the final performance evaluation metric for the model.

[0090] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations and substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A virus identification method based on multi-head attention mechanism and graph isomorphic neural network, characterized in that: The method includes the following steps: Step 1: Preprocess the contiguous groups of viral and prokaryotic gene sequences in the RefSeq library; Step 1 specifically involves: Step 1.1: Filter out the viral and prokaryotic gene sequences extracted from the RefSeq library that are longer than 999bp, cut them into 999bp gene sequence fragments without overlap, and discard the last fragment that is not long enough to meet the 999bp requirement. Step 1.2: Label the gene sequence fragments cut from the viral gene sequence as positive samples and assign them label 1; label the gene sequence fragments cut from the prokaryotic gene sequence as negative samples and assign them label 0. Step 1.3: Cut the fixed-length gene sequence fragment into three-base segments and convert them into a 333-digit sequence according to the codon correspondence table; Step 1.4: Ensure that all test data in the test set conforms to the characteristics of the first discovery of viral contigs in actual applications. Divide the whole genome of the viral samples into training set and test set according to the release date of the viral contigs. Step 1.5: Ensure data balance to avoid bias in the model towards a certain type of sample during training due to data imbalance; based on the number of viral gene sequence fragments that have been converted into numbers, randomly select the same number of prokaryotic gene sequence fragments and adjust their distribution in the training and test sets so that the ratio of training data to test data is 4:1 or 9:

1. Step 2: Construct a multi-head attention mechanism and a graph isomorphic neural network model; Step 2 specifically involves: Step 2.1: The model mainly includes an embedding layer, a multi-head attention layer, a layer normalization layer, a graph isomorphic convolutional layer, a global pooling layer, a batch normalization layer, a fully connected layer, a random dropout layer, a connection layer, and an activation layer to extract features from the input data. The multi-head attention layer captures global dependencies, obtains the feature matrix and weight matrix, and further transforms them into the edge adjacency matrix. The batch normalization layer adjusts the input of each layer of the neural network to a standard normal distribution with a variance of 1 and a set of 0. The activation layer uses ReLU and softmax functions to prevent neuron death and gradient vanishing problems during model training. The global pooling layer is used to extract multi-level features. The random dropout layer discards neurons during training at a certain ratio to prevent overfitting. Step 2.2: Calculate the loss value between the predicted label and the true label using the cross-entropy loss function, and use the Adam optimizer to optimize the parameters in the model so that the parameters can be non-linearly transformed to fit the output of the input gene sequence, thereby minimizing the loss function; Step 3: Use K-fold cross-validation to obtain the optimal parameters of the model; Step 4: Preprocess the metagenomic gene sequences to be identified; specifically, Step 4 involves: Step 4.1: Filter out gene sequences longer than 999 bp from metagenomic sequencing data, and randomly cut each gene sequence into 10 fragments of a fixed length of 999 bp starting point; Step 4.2: Cut the sequence fragment into three bases at a time and convert it into a 333-bit number sequence according to the codon correspondence table; Step 5: Input the preprocessed metagenomic sequence into the neural network model of Step 2, and use the optimal parameters of the model obtained in Step 3 to obtain the virus identification result; Step 5 includes the following: Step 5.1: Input the 10 preprocessed sequence fragments cut from the contiguous group of each gene sequence to be tested into the optimized neural network model to obtain 10 predicted probabilities; Step 5.2: The 10 predicted probabilities obtained for each gene sequence are summed and averaged. The label at the position with the highest probability is taken as the prediction result. If the predicted label is 1, the contiguous group of the gene sequence is a virus. If the predicted label is 0, the contiguous group of the gene sequence is a non-virus.

2. The virus identification method based on multi-head attention mechanism and graph isomorphic neural network according to claim 1, characterized in that: Step 3 specifically involves evaluating the model based on the deep learning algorithm using the K-fold cross-validation method. Specifically, different combinations of hyperparameters are set, with 10 or 5 groups of parameters set manually. K-fold cross-validation is performed on each group of parameters to obtain the average accuracy, and then the hyperparameters with the highest accuracy are taken as the optimal parameters.

3. The virus identification method based on multi-head attention mechanism and graph isomorphic neural network according to claim 2, characterized in that: The K-fold cross-validation method uses 5-fold cross-validation to obtain the final accuracy of the model.