Sequence recognition methods and their model training methods, systems, devices, and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-08-14
AI Technical Summary
[0006]因此,本领域仍然迫切需要一种新的技术方案,该方案不仅要具备深度学习模型强大的特征学习能力,还要在系统架构和识别流程上进行创新,以解决现有技术中传统比对方法精度不足,以及深度学习模型在处理高通量数据时计算效率低下的难题
本发明构建的全局表征组件和局部表征组件,通过“全局快速预筛选+局部精准再筛选”的识别方法,能够同时捕捉序列的整体信息和局部细微差异。此架构创造性地解决了大规模序列识别任务中计算效率与识别精度之间的矛盾。该方法避免了将复杂模型直接应用于海量数据所带来的巨大计算量和较低的效率;也克服了传统快速算法精度不足的缺陷。实现了二者的有效结合,提高了识别的灵敏度和准确率。
Smart Images

Figure CN121884946B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of biological sequence information recognition technology, specifically to sequence recognition methods and their model training methods, systems, devices, and storage media. Background Technology
[0002] In the fields of tumor immunology and personalized medicine, the precise identification of specific biological sequences is a core element. For example, T cells recognize tumor neoantigens presented by human leukocyte antigens (HLA) through their T cell receptors (TCRs), which is crucial for the body's anti-tumor immunity. Simultaneously, killer cell immunoglobulin-like receptors (KIRs) on the surface of natural killer cells also trigger immune responses through interaction with HLA molecules on target cells. Therefore, accurately identifying the sequence types of HLA, TCRs, and KIRs is essential for guiding treatment. With the rapid and widespread application of high-throughput sequencing technologies, especially transcriptome sequencing (RNA-seq), it has become possible to mine this information from massive amounts of data. However, due to the high polymorphism and diversity of these gene sequences, efficiently and accurately identifying them from millions of sequences remains a challenge. To address this challenge, existing technologies have mainly developed along two paths, but both suffer from the technical dilemma of not being able to perfectly balance detection accuracy and efficiency.
[0003] The first category is represented by the classic sequence alignment (SA) method. The relevant patent literature retrieved is: published in China, publication number CN120299521A, publication date July 11, 2025. This literature discloses a heuristic biological sequence clustering method based on semi-global alignment, which determines whether a sequence belongs to a certain category by calculating the similarity score between the sequence to be clustered and the representative sequence.
[0004] The prior art represented by the aforementioned documents has at least the following unresolved technical problems or defects: The aforementioned patent document CN120299521A is based on the traditional sequence alignment (SA) analysis method. The core of this type of method relies on a pre-defined alignment method to assess sequence similarity. However, this method has a fundamental flaw: it cannot automatically learn and capture deep features in biological sequences from the data. For highly polymorphic sequences like HLA, TCR, and KIR, with subtle differences between alleles, traditional alignment methods are not high in sensitivity and accuracy, especially when distinguishing highly similar sequences or processing low-abundance signals, where performance is limited and it is difficult to meet the needs of precision medicine.
[0005] The second category comprises deep learning solutions that have emerged in recent years. To overcome the limitations of traditional methods, deep learning technology has been introduced into biological sequence analysis. These advanced models automatically learn feature representations of sequences through neural networks, demonstrating higher accuracy on certain specific tasks. However, existing deep learning solutions typically construct a monolithic, complex model, aiming to compress all sequence information into a unified representation vector. While this design maximizes the model's representational power, it neglects the application scenarios of high-throughput sequencing data analysis. Directly applying a large and complex deep learning model to the vast amounts of sequences generated by RNA-seq for feature extraction and alignment is computationally intensive, resulting in low analytical efficiency and a lack of feasibility in practical applications. These solutions fail to provide an effective mechanism for rapid initial screening followed by high-precision validation.
[0006] Therefore, there is still an urgent need in this field for a new technical solution that not only possesses the powerful feature learning capabilities of deep learning models, but also innovates in system architecture and recognition processes to solve the problems of insufficient accuracy of traditional comparison methods and low computational efficiency of deep learning models when processing high-throughput data. Summary of the Invention
[0007] In order to solve at least one of the above-mentioned technical problems existing in the prior art, the present invention provides a sequence recognition method and its model training method, system, device and storage medium.
[0008] To achieve the above objectives, the technical solution of the present invention is as follows: In a first aspect, the present invention provides a method for training a sequence recognition model, the training method comprising: constructing a reference dataset of sequences, the reference dataset comprising at least one reference sequence and divided into at least one batch; Construct a sequence recognition model, which includes a global representation component and a local representation component, wherein: The global representation component includes a preprocessor, a tagger, an embedding layer, an encoder, a decoder, and an output layer, used to obtain the global representation vector of the sequence and calculate the global similarity measure between sequences; The local representation component includes a block feature extractor, a local similarity tensor extractor, a local similarity gradient tensor extractor, and a weighted aggregation and pooling module, used to obtain local similarity measures between sequences; The reference sequence is input into the global representation component, and the parameters of the global representation component are iteratively trained using the first loss function to obtain the trained global representation component. The reference sequence is input into the local representation component, and the parameters of the local representation component are iteratively trained using the second loss function to obtain the trained local representation component. The trained global representation component and the trained local representation component are combined to form a trained sequence recognition model.
[0009] Furthermore, the step of training the global representation component further includes: In each training iteration, the reference sequence is input into the preprocessor within the global representation component and then dynamically destroyed to obtain the derived sequence. The tagger segments the derived sequence to obtain derived sequence tags and adds global representation tags; The embedding layer maps the derived sequence markers and global representation markers to the derived sequence initial embedding vector and the global representation initial embedding vector; The encoder encodes the initial embedding vector of the derived sequence and the initial embedding vector of the global representation to obtain the encoded embedding vector of the derived sequence and the encoded embedding vector of the global representation. The decoder reconstructs and decodes the global representation encoded embedding vector and the initial embedding vector of the derived sequence, and the output layer outputs the predicted sequence based on the decoding result. The interaction phase between the encoder and the decoder employs a cross-attention mechanism that relies solely on the global representation encoding embedding vector. The first loss function calculates the loss value based on the difference between the predicted sequence and the reference sequence, and is used to update the parameters of the global representation component.
[0010] Furthermore, the step of training the local representation component further includes: in each iteration of training, randomly selecting a reference sequence as the anchor sequence in a batch, using the slightly perturbed sequence generated by randomly discarding the anchor sequence (i.e., the slightly perturbed sequence obtained by performing a random discarding operation on the anchor sequence) as the positive sequence, and the remaining reference sequences as the negative sequences; After inputting the anchor sequence and negative sequence into the marker and embedding layer of the global representation component in the sequence recognition model, the anchor sequence embedding vector and negative sequence embedding vector are obtained respectively. The block feature extractor divides the block into overlapping block tensors based on the anchor sequence embedding vector and the negative sequence embedding vector, and then performs one-dimensional convolution processing to obtain the anchor sequence block tensor and the negative sequence block tensor, respectively. After randomly discarding the anchor sequence block tensor, the positive sequence block tensor is obtained; The local similarity tensor extractor calculates the positive local similarity tensor between the anchor sequence block tensor and the positive sequence block tensor, and the negative local similarity tensor between the anchor sequence block tensor and the negative sequence block tensor, respectively. The local similarity gradient tensor extractor calculates the gradient tensors corresponding to the positive local similarity tensor and the negative local similarity tensor, respectively. The similarity tensor and its corresponding gradient tensor are input into the weighted aggregation and pooling module to calculate the positive local similarity measure and the negative local similarity measure, respectively. The second loss function calculates the loss value based on the positive local similarity measure and the negative local similarity measure, and is used to update the parameters of the local representation component.
[0011] Furthermore, the step of inputting the similarity tensor and its corresponding gradient tensor into the weighted aggregation and pooling module to calculate the positive local similarity measure and the negative local similarity measure respectively includes: performing element-wise multiplication of the similarity tensor and its corresponding gradient tensor and then inputting it into the weighted aggregation and pooling module to calculate the positive local similarity measure and the negative local similarity measure respectively.
[0012] Furthermore, the dynamic destruction is a mixed destruction performed randomly at different positions in each reference sequence at a set ratio. The mixed destruction at the set ratio includes a mixed destruction with a ratio of 2 replacements, 1 insertion, and 1 deletion, or a mixed destruction with a ratio of 8 replacements, 1 insertion, and 1 deletion.
[0013] Furthermore, the first loss function is the cross-entropy function, and the second loss function is calculated as follows: ,in This represents the positive local similarity measure. This represents the negative local similarity measure. To set the temperature.
[0014] Secondly, the present invention also provides a sequence recognition method, the recognition method comprising: employing a trained sequence recognition model obtained by the training method described above; The global representation component of the trained sequence recognition model is used to process the reference sequence to obtain and store the global representation vector of each reference sequence. Obtain the input sequence to be identified, and use the global representation component to calculate the global representation vector of the input sequence; By calculating the global similarity measure between the global representation vector of the input sequence and the global representation vectors of each stored reference sequence, the input sequence is pre-screened to obtain one or more candidate reference sequences, forming a pre-screened sequence set. For each candidate reference sequence in the pre-screened sequence set, the input sequence and the candidate reference sequence are input into the local representation component of the trained sequence recognition model, the local similarity measure between them is calculated, and the input sequence is further screened based on the local similarity measure to determine its recognition result.
[0015] Thirdly, the present invention also provides a sequence recognition model training system, the training system comprising: a data construction module for constructing a reference dataset of sequences; The model building module is used to build a sequence recognition model. The sequence recognition model includes a global representation component and a local representation component. The global representation component includes a preprocessor, a tagger, an embedding layer, an encoder, a decoder, and an output layer. The local representation component includes a block feature extractor, a local similarity tensor extractor, a local similarity gradient tensor extractor, and a weighted aggregation and pooling module. The model training module is used for the aforementioned sequence recognition model training method. It iteratively trains the global representation component using a first loss function and iteratively trains the local representation component using a second loss function to obtain the trained global representation component and the trained local representation component. The model storage module is used to store the sequence recognition model trained by the model training module.
[0016] Fourthly, the present invention also provides a sequence recognition system, the recognition system comprising: a reference sequence construction module for constructing a reference sequence and its label; The reference sequence representation module is used to obtain and store the global representation vector of the reference sequence from the global representation component of the trained sequence recognition model obtained by the aforementioned sequence recognition model training method. The pre-screening module is used to obtain the input sequence to be identified and to calculate the global representation vector of the input sequence using the global representation component of the trained sequence recognition model. By calculating the global similarity measure between the global representation vector of the input sequence and the global representation vectors of each stored reference sequence, a pre-screened sequence set is obtained. The re-filtering module is used to input the input sequence and the candidate reference sequence into the local representation component of the trained sequence recognition model for each candidate reference sequence in the pre-filtered sequence set, so as to calculate the local similarity measure between the two, and output the final recognition result based on the measure.
[0017] Fifthly, the present invention also provides an electronic device, the electronic device comprising: a memory and a processor; The memory is used to store program instructions, and the processor is used to execute the program instructions to implement the aforementioned sequence recognition model training method.
[0018] In a sixth aspect, the present invention also provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, enable the aforementioned sequence recognition model training system to perform its functions.
[0019] In a seventh aspect, the present invention also provides an electronic device, the electronic device comprising: a memory and a processor; The memory is used to store program instructions; the processor is used to execute the program instructions to implement the aforementioned sequence recognition method.
[0020] Eighthly, the present invention also provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implement the functions of the aforementioned sequence recognition system.
[0021] Compared with the prior art, the present invention has the following beneficial effects: The global and local representation components constructed in this invention, through a recognition method of "global fast pre-screening + local precise re-screening," can simultaneously capture the overall information and subtle local differences of a sequence. This architecture creatively resolves the contradiction between computational efficiency and recognition accuracy in large-scale sequence recognition tasks. This method avoids the enormous computational burden and low efficiency resulting from directly applying complex models to massive amounts of data; it also overcomes the insufficient accuracy of traditional fast algorithms. It achieves an effective combination of both, improving the sensitivity and accuracy of recognition.
[0022] This invention employs different training strategies for different components. For the pre-training of the global representation component, a dynamic destruction and reconstruction training strategy is used to enable it to learn general sequence features from the data; while the contrastive learning of the local representation component focuses on optimizing its fine-grained discriminative ability. This combined strategy is more targeted than a single training method and can train a model with superior performance.
[0023] This invention employs a cross-attention mechanism in the encoder-decoder interaction stage that relies solely on the global representation encoding embedding vector. This allows the decoder to rely only on this single global representation vector when reconstructing the sequence. As a result, the reconstruction loss during training will directly drive the learning of more complete and discriminative global semantics, thus forming a closed loop in which the encoder is responsible for compression and the decoder is responsible for reconstruction, thereby improving the quality of global representation.
[0024] Experimental results using the method of this invention show that this invention not only demonstrates higher accuracy and sensitivity compared to existing methods in HLA typing and TCR clone identification tasks, but can also be effectively applied to KIR typing tasks where there are no mature analysis methods. This fills the technological gap in this field for analyzing sequencing data and has significant scientific research and clinical application value. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the sequence recognition model structure of the present invention.
[0026] Figure 2This is an evaluation chart of the effect of identifying KIR classification in specific embodiment 1 of the present invention.
[0027] Figure 3 This is a pre-training loss function curve for identifying KIR classification in specific embodiment 1 of the present invention. Specifically, it is a curve showing the global average training loss changing with the number of iterations under a multi-machine, multi-card distributed data parallel training setting.
[0028] Figure 4 This is an evaluation chart of the HLA typing effect in specific embodiment 2 of the present invention.
[0029] Figure 5 This is a pre-training loss function curve for HLA typing identification in specific embodiment 2 of the present invention. Specifically, it is a curve showing the global average training loss changing with the number of iterations under a multi-machine, multi-card distributed data parallel training setting.
[0030] Figure 6 This is an evaluation chart of the effect of identifying TCR clones in specific embodiment 3 of the present invention.
[0031] Figure 7 This is a pre-training loss function curve for identifying TCR clones in specific embodiment 3 of the present invention. Specifically, it is a curve showing the global average training loss changing with the number of iterations under a multi-machine, multi-card distributed data parallel training setting.
[0032] Figure 8 This is an evaluation diagram of the effect of identifying gene fusion in specific embodiment 4 of the present invention.
[0033] Figure 9 This is a pre-training loss function curve for identifying gene fusion in specific embodiment 4 of the present invention. Specifically, it is a curve showing the global average training loss changing with the number of iterations under a multi-machine, multi-card distributed data parallel training setting. Detailed Implementation
[0034] The technical solution of the present invention will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are not all embodiments of the present invention. All other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.
[0035] It should be noted that, unless otherwise specifically stated, the relative arrangement and numerical expressions of the components and steps described in these embodiments should not be construed as limiting the scope of the invention.
[0036] The following description of exemplary embodiments is merely illustrative and is not intended to limit the invention or its application or use in any way. Techniques, methods, and apparatus known to those skilled in the art may not be discussed in detail herein, but where applicable, such techniques, methods, and apparatus should be considered part of this specification.
[0037] In this specification, the term "tensor" refers to a multidimensional array with arbitrary dimensions. The use of the term "tensor" is intended to encompass all high-dimensional data structures that the model processes during training and inference.
[0038] This invention provides a sequence recognition method, its model training method, system, device, and storage medium. For example... Figure 1 As shown, its core lies in the model architecture of global representation components and local representation components, as well as the corresponding stage training and recognition processes.
[0039] I. Sequence Recognition Model and Training Method The core of this invention is to provide a sequence recognition model and training method, the details of which are as follows: 1. Construct a reference dataset First, based on the specific recognition task (such as HLA typing, KIR typing, or TCR recognition), a reference dataset containing several reference sequences and their corresponding labels is constructed. For example: HLA genotyping task: The reference sequences are known HLA allele sequences from authoritative databases such as IPD-IMGT / HLA, tagged with "HLA-A". Precise classifications such as "01:01" are used.
[0040] KIR typing task: The reference sequences are the KIR gene sequences in the IPD / KIR database, and the tags are gene names such as "KIR2DL1".
[0041] TCR identification task: The reference sequence can be a known TCRV(D)J gene fragment or a complete clone sequence, and the tag is the corresponding gene name or clone ID.
[0042] The constructed dataset is divided into several batches for subsequent iterative training.
[0043] 2. Construct a sequence recognition model like Figure 1 As shown, the sequence recognition model of the present invention consists of two core components that work together: a global representation component and a local representation component, forming a two-stage recognition process of "pre-screening and then screening".
[0044] Global Representation Component: This component extracts global representation vectors from the input sequence that represent the overall semantics / structure, and uses these vectors to quickly assess the global similarity between sequences. Preferably, this component employs an encoder-decoder architecture based on the Transformer architecture (an encoder-decoder neural network architecture with self-attention as its core). It is important to note that the term "tag" refers to the component used to discretize continuous biological sequences into units that the model can process. Although in Figure 1 The document illustrates a "segmentation" operation, but for biological sequences such as DNA, RNA, or proteins, the marker is specifically configured to process the sequence into k-mer fragments or single-residue units. This is because biological sequences do not have natural whitespace delimiters. Therefore, the "marker" in this application encompasses all segmentation processing methods before converting biological macromolecular sequences into vectorized input. The specific process for global representation component recognition is as follows: First, the original sequence is preprocessed and marked, with special markers such as [BOS] (sequence start), [E] (end), and occlusion marker [M] added. A "derived sequence" is generated through a dynamic destruction strategy to construct a denoising reconstruction task. Subsequently, the segmented embedding and the learnable position embedding are added together and input into the encoder. The encoder consists of L stacked units, each layer containing multi-head self-attention, a feedforward network, and a stabilization path of "residual addition + layer normalization + random dropout". On the decoder side, the target sequence is shifted one position to the right (teacher-forced), and after self-attention and cross-attention to the encoder output, a wiring layer and softmax generate a reconstruction probability distribution. During training, sequence reconstruction is achieved by minimizing cross-entropy, thereby enabling the model to learn robust global dependencies. In the inference phase, the encoder's [BOS] position vector is used as the global representation. After L2 normalization, cosine similarity / dot product can be used for high-speed pre-screening of a large-scale candidate library. Compared to recurrent neural networks (RNNs) / convolutional neural networks (CNNs), the parallel attention of the Transformer architecture can more effectively capture long-distance dependencies and alleviate gradient vanishing on long sequences, thus obtaining a more stable global representation, making it suitable for large-scale, low-latency first-round screening tasks.
[0045] Unlike the classic Transformer architecture, this invention employs a separate global representation tag, with the global representation encoding the embedding vector. At the model level, corresponding to Figure 1The specific BOS vector in the "memory layer" output by the encoder. That is, the position vector corresponding to [BOS] serves as the global representation. To ensure that [BOS] can fully learn and compress the information of the entire sequence during training, this invention adopts a "cross-attention mechanism that relies solely on [BOS]" in the encoder-decoder interaction stage: in the encoder-decoder interaction, the encoder output (memory) at each position is not used as the key / value pair; only [BOS] is used to generate the K / V, thus ensuring that all information in the cross-attention is carried by a single global vector. Cross-attention does not introduce the entire memory layer, but uses only the [BOS] vector output by the encoder as the unique key (K) and value (V): In key / value (K / V) construction, let the global representation encoding embedding vector output by the encoder be... For each attention head :
[0046]
[0047] in and It is a learnable linear projection tensor.
[0048] In query (Q) pairing, the decoder performs word segmentation. The hidden state is The query is:
[0049] In the calculation of single-bond cross-attention scores, due to each attention head Only one key The score is:
[0050] Using softmax, the weights are always 1 after normalization; therefore, temperature gating is preferred to preserve conditionality.
[0051] The final cross-attention output is:
[0052] By concatenating multiple heads and linearly mapping them, we obtain:
[0053] This design forces the decoder to rely on only one global carrier when generating each target tag. .like If the information of the entire sequence is not sufficiently compressed, the decoder cannot accurately reconstruct it. The reconstruction loss (cross-entropy) during training will directly drive the learning of a more complete and discriminative global semantics.
[0054] The computational complexity is reduced compared to the conventional approach, significantly decreasing the dependence on the encoding length; with only one key / value path, gradients flow back to [BOS] more concentratedly, stably facilitating the learning of "single vector global representation" and forming a closed loop where "the encoder is responsible for compression and the decoder is responsible for reconstruction".
[0055] Local representation component: used for precise comparison of candidate pairs obtained through global screening, focusing on characterizing fine-grained differences. Preferably, this component includes: a block feature extractor, a local similarity tensor extractor, a local similarity gradient tensor extractor, a weighted aggregation and pooling module, and a second loss function (contrastive learning). In this application, the block feature extractor is used to extract fine-grained features of local parts of the sequence. Although Figure 1 The example shown illustrates a preferred implementation of this extractor using convolution, but those skilled in the art should understand that the block feature extractor is not limited to convolutional neural networks. In other embodiments, the block feature extractor can also be implemented using recurrent neural networks, long short-term memory networks, or local attention windows based on the Transformer architecture, as long as they can extract local block features of the sequence. In a preferred embodiment of the invention, one-dimensional convolution is used as the block feature extractor to effectively capture specific sequences in biological sequences. Simultaneously, the weighted aggregation and pooling module aims to fuse local similarity information. In a preferred specific embodiment, this module employs a "multi-head self-attention mechanism" to implement weighted aggregation. The weighted aggregation and pooling module of this application encompasses self-attention mechanisms and other structures capable of weighted summation of features based on gradient or similarity weights.
[0056] The specific process for identifying local representation components is as follows: a) Block feature extraction: The two sequences to be compared are divided into overlapping block tensors with a fixed length and stride. After passing through one-dimensional convolution / activation / normalization and random dropout, block tensors sensitive to local patterns (such as short motifs / phrase fragments) are obtained. b) Similarity tensor calculation: Perform pairwise matching (such as normalized dot product / correlation coefficient) on the two sets of block tensors to obtain local similarity tensors; and further calculate their first-order difference or Sobel-like gradient along the row / column direction to form a "local similarity gradient tensor" to enhance the response at the boundary and mismatch. c) Weighted attention and layer normalization: The local similarity tensor and its corresponding local similarity gradient tensor are multiplied element-wise, and then the residuals are added through a weighted attention / gating mechanism and layer normalization to obtain a more robust matching response to shifts and missing values. d) Row / column normalization and pooling: Perform row / column normalization and max / average pooling on the tensor, and use pyramid-style (multi-scale) aggregation when necessary to accommodate local alignment of different spans; e) Contrastive learning objective: Construct positive and negative sequences (e.g., positive sequences derived from real neighboring segments and randomly sampled negative sequences), train with a second loss function, maximize the score of positive sequences and suppress the score of negative sequences, thereby obtaining a generalizable local similarity measure.
[0057] Preferably, the global representation component is pre-trained using a denoising and reconstruction task, and then the local representation component is trained while keeping its parameters frozen or semi-frozen. Alternatively, end-to-end fine-tuning can be performed to enable the global and local representation components to be collaboratively optimized on the same objective. During inference, the global representation component is first used to quickly recall data from a massive database, and then the local representation component is used to further filter and rank candidate pairs, ultimately outputting a sequence similarity evaluation result that combines speed and accuracy. Through this structure, the present invention can simultaneously ensure stable modeling of long-range dependencies and high-sensitivity detection of local differences, significantly improving the accuracy and throughput efficiency of sequence recognition.
[0058] 3. Train the global representation component The goal of this stage is to enable the model to learn the global features of the sequence. The specific training process is as follows: First, in each training iteration, the reference sequence is input into the preprocessor, and a random dynamic disruption operation is performed to obtain the derived sequence. This operation simulates sequencing errors or biological variations by randomly inserting, replacing, or deleting several bases at different positions in the reference sequence. The intensity of the dynamic disruption can be adjusted, for example, by mixing different modes such as "2 replacements + 1 insertion + 1 deletion" or "8 replacements + 1 insertion + 1 deletion" to improve the stability of the model. To realistically simulate various mutation modes (such as insertion, deletion, and replacement) in biologically meaningful sequences, a mixed approach of randomly inserting, replacing, or deleting several bases is adopted. Considering the different frequencies and functional effects of different mutation modes in real biological sequences, the preset ratios of replacement / insertion / deletion are not entirely equal.
[0059] The derived sequence is then fed into a tagger for segmentation, and a special global representation tag is added. The embedding layer then maps these tags to initial embedding vectors. The encoder receives these embedding vectors and encodes them to obtain the encoded embedding vectors of the derived sequence and the encoded embedding vectors of the global representation. The decoder receives the encoded global representation vectors and the initial embedding vectors of the derived sequence, and reconstructs and decodes the derived sequence. The output layer outputs the predicted sequence based on the decoding results.
[0060] Finally, by comparing the predicted sequence with the original reference sequence, the error is calculated using the first loss function (preferably the cross-entropy function in this application), and backpropagation is used to update all parameters of the global representation component. This process is repeated until the model can accurately reconstruct the original sequence from the corrupted sequence, at which point the trained global representation component is obtained.
[0061] 4. Training local representation components After the global representation component is trained, the goal of this stage is to enable the model to learn to distinguish subtle differences between sequences. This is because, after the initial screening by the global representation component, the candidate sequences entering the second stage already exhibit high similarity. However, the model training objective and learning information of the global representation component mainly revolve around the compressed representation of the global and overall sequence, while finer-grained information such as local structural domains and epitopes are not specifically optimized for learning. Therefore, traditional training methods are no longer effective in distinguishing them. This invention creatively employs a strategy of comparing differences between different sequences at this stage, focusing attention on the representation of finer-grained information such as structural domains and epitopes, thereby achieving higher resolution in distinguishing local differences in allele or clonal identity. This is crucial for achieving high-precision final identification. The specific training process is as follows: In each training iteration, a reference sequence is randomly selected from the current batch as the anchor sequence, i.e., the anchor sample in the contrastive learning. Slightly perturbed sequences generated by randomly discarding the anchor sequence are considered positive sequences, i.e., positive samples in the contrastive learning, while other reference sequences in the same batch are considered negative sequences, i.e., negative samples in the contrastive learning.
[0062] First, the anchor sequence and negative sequence are fed into the model's labeler and embedding layer, respectively, to obtain their respective embedding vectors. Then, the block feature extractor divides the anchor sequence embedding vector into blocks, splitting them into overlapping block tensors. These blocks are then processed by one-dimensional convolution to obtain the anchor sequence block tensor. A dropout operation is then applied to the anchor sequence block tensor to generate the corresponding positive sequence block tensor. Simultaneously, each negative sequence is also processed by the block feature extractor to obtain its corresponding negative sequence block tensor.
[0063] Subsequently, the local similarity tensor extractor calculates the local similarity tensors between the anchor sequence block tensor, the positive sequence block tensor, and each negative sequence block tensor. The local similarity gradient tensor extractor further calculates the gradient tensor of each local similarity tensor.
[0064] Finally, the positive local similarity tensor is element-wise multiplied with its corresponding positive gradient tensor, and the negative local similarity tensor is element-wise multiplied with its corresponding negative gradient tensor. These results are then fed into the weighted aggregation and pooling module to obtain the local similarity score of the positive sequence. ) and the local similarity score of each negative sequence ( Using a second loss function (such as the contrastive loss function, which is calculated as follows:) ,in The parameters of the local representation component are updated based on the difference in similarity scores between the positive and negative sequences (for the set temperature parameters).
[0065] This process optimizes the model's ability to represent local detail differences by maximizing the similarity of positive sequence pairs and minimizing the similarity of negative sequence pairs, ultimately resulting in a trained local representation component.
[0066] After the above training, the trained global representation components and local representation components can be combined to form the final trained sequence recognition model.
[0067] II. Sequence Recognition Methods This invention also provides a sequence recognition method. Using the model trained above, unknown input sequences can be identified. This recognition method employs a global-local filtering strategy, significantly improving the accuracy of sequence recognition while ensuring computational efficiency and meeting the requirements of high sensitivity and high precision. The recognition method includes: 1. Prepare reference sequence representations: Provide a set of reference sequences for the target recognition task and the corresponding label for each reference sequence.
[0068] For example, in HLA genotyping tasks, the reference sequence can be any known HLA allele sequence, with the label being the corresponding HLA type; in KIR genotyping tasks, the reference sequence is any KIR gene sequence, with the label being the corresponding gene name; and in TCR cloning detection tasks, the reference sequence can be any known TCR sequence and its label.
[0069] 2. Reference sequence representation: Each reference sequence is input into the global representation component of the trained sequence recognition model to obtain the corresponding global representation vector of the reference sequence, and this vector is associated with the label of the reference sequence and stored for later use.
[0070] 3. Global Input Sequence Filtering: Obtain the input sequence to be identified. Input the input sequence into the global representation component of the trained model to obtain the global representation vector of the input sequence. Calculate the global similarity metric between the input sequence and the global representation vectors of each reference sequence. Based on the similarity metric result, determine whether the input sequence belongs to the label type corresponding to a certain reference sequence. If the global similarity between a reference sequence and the input sequence is higher than a predetermined threshold, it is determined that the input sequence initially matches the reference label, and candidate reference sequences and their corresponding labels are selected. A pre-filtered sequence set is obtained.
[0071] 4. Local Similarity Re-screening: For each candidate reference sequence in the pre-screened sequence set, a sequence pair is formed with the input sequence and input together into the local representation component of the model. The local similarity metric of the input sequence relative to the reference sequence is calculated. Based on this local similarity metric, it is further determined whether the input sequence belongs to the label type of the reference sequence: if the local similarity metric also meets the threshold requirement, the input sequence is confirmed to belong to the reference label; otherwise, the candidate is removed. Through local similarity re-screening, misjudgments in the global similarity stage can be filtered out, resulting in the final re-screened sequence, thus achieving accurate identification of the input sequence. For practical applications, the above global pre-screening and local re-screening processes can be performed on a batch of input sequences to simultaneously identify all target sequence types present in the sample.
[0072] III. Sequence Recognition Model Training and Recognition System and Hardware Equipment To put the above method into practice, this invention further discloses a training and recognition system for a sequence recognition model and corresponding hardware implementation equipment: 1. A sequence recognition model training system, which is the specific implementation of the above training method, including: Data building module: responsible for loading, preprocessing and partitioning the reference dataset, which includes several reference sequences and is divided into multiple batches for training.
[0073] Model building module: Used to build sequence recognition models, specifically including global representation components and local representation components. The global representation components include a preprocessor, a tagger, an embedding layer, an encoder, a decoder, and an output layer, with each part functioning as described above; the local representation components include a block feature extractor, a local similarity tensor extractor, a local similarity gradient tensor extractor, and a weighted aggregation and pooling module.
[0074] Model training module: used to train the global representation component and local representation component according to the above training method, including loss calculation and parameter update.
[0075] Model storage module: Used to store the trained sequence recognition model, which consists of trained global representation components and local representation components.
[0076] 2. A sequence recognition model recognition system, which is the specific implementation of the above recognition method, including: Reference sequence building module: Constructs reference sequences and labels; Reference sequence representation module: Used to acquire and store the global representation vector of the reference sequence.
[0077] Pre-screening module: Used to perform preliminary screening of input sequences based on a global similarity metric.
[0078] The re-filtering module is used to further filter pre-screened candidate sequences based on local similarity metrics and output the results.
[0079] 3. Hardware devices, including electronic devices and computer-readable storage media, wherein the methods and systems described in this invention can be implemented on general-purpose or dedicated computing hardware, specifically including: Electronic devices, such as servers, workstations, or embedded systems, contain at least a processor and memory. The memory stores program instructions that implement sequence recognition model training methods or recognition methods. The processor is responsible for executing these instructions, thereby completing all the computational steps for model training or sequence recognition.
[0080] Computer-readable storage media, such as hard disks, solid-state drives (SSDs), USB flash drives, and optical discs, store program instructions. When these instructions are loaded and executed by a processor, they enable the entire functionality of a sequence recognition model training system or a recognition system.
[0081] Example 1 This embodiment will specifically introduce the training and recognition of the KIR genotyping sequence recognition model. Taking KIR genotyping as an example, it will explain how to use the method of the present invention to train the sequence recognition model and recognize KIR sequences in actual samples.
[0082] KIR typing sequence recognition model training method: 1. Construct a KIR genotyping reference dataset by collecting pre-sequencing KIR gene reference sequences and corresponding KIR gene name tags. Divide the reference dataset into several batches for training purposes. The KIR reference sequences can be derived from the full-length sequences of each KIR allele in public databases (such as the IPD / KIR database), resulting in a total of 111,647 sequences. 2. Construct a sequence recognition model, including global representation components and local representation components and their internal modules.
[0083] 3. For example Figure 3The global representation component is trained by inputting the KIR reference sequence into it. Through a pre-training task involving dynamic destruction and reconstruction, the parameters of the global representation component are optimized until it can output a reliable global representation vector of the KIR sequence.
[0084] 4. Train the local representation components. After the global representation components are trained, perform comparative learning training on the KIR reference sequence until the model can effectively distinguish the subtle differences between the KIR sequences.
[0085] KIR typing sequence identification method: 1. Using the trained model, generate and store the global representation vectors of all known KIR gene sequences (such as KIR2DL1, KIR2DL2, etc.) in the IPD / KIR database as a comparison benchmark.
[0086] 2. Sequencing reads from the sample to be analyzed, such as RNA-seq or other RNA sequencing reads, are input one by one into the model's global representation component. This yields a global representation vector for each input sequence, which is then compared to vectors in a benchmark library to calculate similarity and filter out candidate KIR sequence tags with high global similarity metrics. For example, if an input sequence has the highest global vector similarity to the "KIR3DL1" gene sequence in the reference database and exceeds a preset threshold, then that input sequence is identified as a candidate matching sequence for KIR3DL1. This process can be performed in parallel on a large number of reads to initially locate the possible KIR types in the sample.
[0087] 3. Local Re-screening: For each candidate KIR match that passes the global screening, its corresponding reference KIR sequence is taken and fed into the model's local representation component for fine-grained comparison along with the input sequence. The local similarity metric is calculated. If the local similarity is also significantly high and meets the judgment criteria, the input sequence is confirmed to belong to that KIR gene; otherwise, if the local similarity is low, it indicates that the previous global similarity may be accidental, and the match is rejected. Through local re-screening, a final list of KIR genes identified in the sample is output. For the aforementioned example, if the input sequence is confirmed as a KIR3DL1 sequence in the local comparison, the KIR3DL1 type is determined to exist in the sample. Repeating the above process can identify all existing KIR sequence types in the sample.
[0088] like Figure 2As shown, based on the gold standard clinical test SSP results, the model of this invention can correctly identify the vast majority of KIR genotypes (a total of 15 KIR subtypes; excluding 3DL3, all other 14 KIR subtypes were correctly identified, with an accuracy rate as high as 93.33%), while the traditional sequence alignment (SA) method showed misidentification in some samples (the accuracy rate of traditional sequence alignment was 66.67%), and the technology of this invention is significantly superior to traditional sequence alignment. This proves that the model of this invention has higher accuracy and reliability in KIR sequence detection.
[0089] Example 2 This embodiment will specifically introduce the training and recognition of the HLA genotyping sequence recognition model. Taking human leukocyte antigen (HLA) genotyping as an example, it illustrates how to use the method of this invention to train the sequence recognition model and identify HLA genotypes in actual samples. The reference dataset consists of known HLA allele sequences and their genotyping labels. The training process is similar to that in Embodiment 1, including: HLA typing sequence recognition model training method: 1. Construct an HLA typing reference dataset, collecting known HLA allele sequences (including class I and class II) and corresponding HLA type tags, such as "HLA-A", from the IPD-IMGT / HLA database. At 01:01, the dataset was divided into batches for later use, resulting in a total of 2,547,000 sequences.
[0090] 2. Construct a sequence recognition model with the same structure as in the aforementioned Implementation Example 1, with the same configuration for the global representation component and the local representation component.
[0091] 3. For example Figure 5 The global representation component is trained by inputting the HLA reference sequence and using a pre-training task (dynamic disruption + reconstruction) to train the model to learn the global features of the HLA sequence. Due to the extremely high polymorphism of HLA sequences, sufficient pre-training allows the model to master common variation patterns and improve its generalization ability to different alleles.
[0092] 4. Train the local representation component by performing contrastive learning training on the HLA sequence. The specific steps are as described in Example 1. By constructing anchor sequences (a certain HLA sequence) and positive and negative sequence pairs, the model learns to distinguish subtle differences between highly similar allele sequences.
[0093] HLA typing sequence identification method: 1. Establish an HLA reference library: Prepare a complete set of HLA allele reference sequences and their type tags (e.g., all allele sequences at HLA-A, B, and C loci). Calculate and store the global representation vectors for the complete set of HLA allele reference sequences.
[0094] 2. Global Initial Screening: Read sequences from the sample RNA-seq data are input into the model's global representation component to obtain their global representation vectors. The cosine similarity or other similarity measures between this vector and sequence vectors in the HLA reference library are calculated, and the group of candidate HLA alleles with the highest similarity is selected. 3. Local fine screening: Each candidate HLA allele sequence and the corresponding sample read sequence are input into the local representation component of the model. The final confirmation is made by local similarity comparison to determine the HLA typing results of each locus in the sample.
[0095] like Figure 4 As shown, in RNA sequencing data from 8 blood samples, based on the gold standard clinical test SBT results, the model of this invention correctly identified all actual HLA alleles (100% accuracy), while traditional comparison methods misidentified at least one allele in 5 of the samples. The detection accuracy of the model of this invention for each HLA allele is also higher than that of classical methods, which fully demonstrates the superior performance of the model of this invention in HLA genotyping applications.
[0096] Example 3 This embodiment will specifically introduce the training and clonal detection of the TCR sequence recognition model. Taking the TCRβ chain sequence, which contributes to the main antigen recognition function, as an example, the identification and clonal abundance detection of T cell receptor (TCR) sequences will be explained. The training process includes: Training methods for TCR sequence recognition models: 1. Construct a TCR sequence reference dataset, collecting gene sequences of the variable region (V), diversity region (D), connection region (J), and constant region (C) of the TCR β chain, as well as known rearrangement sequences, to serve as a reference sequence library. Assign each sequence a corresponding identifier label (e.g., V gene name or specific clone ID). Divide the reference dataset into batches for later use.
[0097] 2. Construct a sequence recognition model with the same structure as in Example 1, and configure global and local representation components.
[0098] 3. For example Figure 7 The global representation component is trained by inputting a TCR reference sequence into the model's global representation component. Through dynamic disruption and reconstruction pre-training, the model learns global patterns of TCR sequences. Examples include differences between genes in different TCRV regions and patterns of insertions / deletions of varying lengths. This pre-training enables the model to initially recognize TCR sequences.
[0099] 4. Train the local representation components using contrastive learning with anchor-positive-negative sequence pairs to train the model's ability to finely distinguish between homologous and non-homologous TCR sequences. The anchor sequence can be a real-world TCRβ sequence, the positive sequence is a variant of that sequence with randomly introduced noise, and the negative sequence is another TCRβ sequence from a different source. Through training, the model learns to distinguish homologous TCR sequences from non-homologous sequences, resulting in a TCR recognition model.
[0100] TCR clone identification method: 1. Constructing a TCR reference library: Input all target TCR reference sequences into the model's global representation component to calculate the global vector and establish a reference sequence database. The reference sequences can include all possible TCRβV(D)J composition sequences, derived from the dedicated TCR sequence database IMGT, resulting in a total of 100,227 sequences.
[0101] 2. Sample Sequence Pre-screening: Input the read sequences from the sample RNA-seq into the global representation component of the model to obtain a global representation vector. Calculate its similarity with sequences in the TCR reference library, and mark reads with high similarity exceeding a threshold as candidate TCR sequences.
[0102] 3. Local Sequence Re-screening: For each candidate TCR read, a globally matching reference TCR sequence is selected. The local similarity between the two sequences is calculated using the model's local representation component to confirm whether the read originates from the corresponding TCR clone. If the local similarity is low, a false match is excluded.
[0103] 4. Clonal Abundance Statistics: All identified TCR read sequences are grouped and counted according to their matching reference TCR tags to determine the abundance of each TCR clone in the sample. Clonal abundance can be represented by the number of identified reads, thus allowing for the estimation of the relative abundance of the corresponding T cell clone in the sample.
[0104] like Figure 6 As shown, the model of this invention can reliably reconstruct TCR clonal profiles from non-specific RNA sequencing data for TCR sequence detection. Compared with traditional tools MiXCR and TRUST4, the model of this invention can identify many additional low-abundance clones, improving the comprehensiveness of the detection. In tests on 8 blood samples, based on the gold standard clinical test (TCR-seq) results, the overlap between the TCR clones identified by the model of this invention and the gold standard results was significantly higher than that of MiXCR and TRUST4, demonstrating that this invention can more sensitively capture TCR sequence information from transcriptome data, providing a powerful tool for the analysis of immune receptor repositories.
[0105] Example 4 This embodiment will specifically introduce the training and recognition of the gene fusion sequence recognition model. Taking gene fusion as an example, it illustrates how to use the method of this invention to train the sequence recognition model and identify gene fusions in actual samples. The reference dataset consists of coding genes and their exons from the known human reference genome. The training process is similar to that in Embodiment 1, including: Training methods for gene fusion sequence recognition models: 1. A gene fusion training set was constructed by collecting coding genes and their exon sequences from known human reference genomes in the NCBI database. Complete transcripts for each gene were extracted. Using a fixed sliding window of multiple preset sequence fragment lengths and a preset step size, the complete transcripts were continuously cut and randomly sampled. The resulting set of cut sequence fragments was used as the training set, and the dataset was divided into batches for later use. A total of 60,097,404 sequence fragments were obtained from 19,906 genes and 206,716 exons through cutting and sampling.
[0106] 2. Construct a sequence recognition model with the same structure as in the aforementioned Implementation Example 1, with the same configuration for the global representation component and the local representation component.
[0107] 3. For example Figure 9 The global representation component is trained by inputting sequence fragments from the training set into it and using a pre-training task (dynamic destruction + reconstruction) to train the model to learn the global features of each gene sequence fragment. Since gene fusion occurs when each gene fragment is relatively short and of varying lengths, sufficient pre-training allows the model to master the patterns of each gene fragment, improving its ability to represent different gene fragments.
[0108] 4. Train the local representation components and perform contrastive learning training on the sequence segments. The specific steps are as described in Example 1. By constructing anchor sequences (a certain sequence segment) and positive and negative sequence pairs, the model learns to distinguish subtle differences between highly similar sequence segments.
[0109] Gene fusion sequence identification methods: 1. Establish a gene sequence fragment reference library: Prepare randomly sampled gene sequence fragments and their gene mappings as a gene sequence fragment reference library. Calculate and store the global representation vectors of the gene sequence fragments.
[0110] 2. Global Initial Screening: The read sequences in the sample RNA-seq data are segmented from the middle. The resulting segmented read sequences are input into the global representation component of the model to obtain their global representation vectors. The cosine similarity or other similarity measures between this vector and the sequence vectors in the reference library are calculated, and the group of candidate genes with the highest similarity is selected.
[0111] 3. Local fine screening: Each candidate gene and the corresponding read subsequence after segmentation of the sample read sequence are input into the local representation component of the model. The final confirmation is made by local similarity comparison to determine the gene corresponding to each read subsequence in the sample. The correspondence of read subsequences is obtained according to the read sequence segmentation. The gene pair obtained after splicing and restoring is the identified gene fusion.
[0112] To evaluate the performance of the sequence model in identifying gene fusions, a total of 10 randomly synthesized test sets were used. Each time, 20,000 read sequences of known gene fusions were obtained by randomly sampling, segmenting, and splicing coding genes and their exon sequences from a known human reference genome. The model of this invention was used to identify gene fusions, and the identification results were compared with the known gene fusions in the corresponding synthesized test sets. If the two identified genes in the fusion completely matched the two known genes, it was considered correct; otherwise, it was considered incorrect. Figure 8 The accuracy was calculated for 10 synthetic test sets (the average accuracy was greater than 95%), which fully demonstrates the superior performance of the model of this invention in gene fusion recognition applications.
[0113] In summary, the technical solution of this invention creatively constructs a new algorithmic model for sequence representation and recognition, and proposes corresponding training and recognition methods for the model. Implementation and application of specific embodiments in multiple different scenarios have achieved comparable or even superior technical results, demonstrating outstanding novelty and inventiveness, and possessing high industrial application transformation value. 1) The global and local representation components constructed in this invention can complete sequence similarity representation without relying on traditional sequence alignment algorithms. Through the identification method of "global fast pre-screening + local precise re-screening" and the training method of global "dynamic destruction-recovery" and local intra-batch comparison learning, it can simultaneously capture and represent the overall information and local subtle differences of the sequence. It can be used not only for information compression and similarity representation of sequence information, but also for different multi-tasks such as sequence recognition and classification.
[0114] 2) Experimental results using the method of this invention show that this invention not only demonstrates higher accuracy and sensitivity compared to existing methods in HLA typing and TCR clone identification tasks, achieving superior technical results, but can also be effectively applied to KIR typing tasks where there are no mature analysis methods, filling the technical gap in this field for analyzing sequencing data, and has significant scientific research and clinical application value.
[0115] It should be noted that the above embodiments illustrate KIR typing, HLA typing, and TCR clone detection, but the model and method of this invention are not limited to the specific application scenarios described above. By appropriately adjusting the reference dataset and labels, the sequence recognition model of this invention is also applicable to other biological sequence recognition tasks, including but not limited to gene variation detection and antigen receptor sequence analysis. Without departing from the purpose of this invention, the details of the model structure and training / recognition methods can be modified and optimized according to actual needs. For example, the network structure of the global representation component can adopt other variations of the Transformer architecture; the feature extraction method of the local representation component can also use convolutional neural networks, etc. These equivalent variations should all fall within the scope of protection claimed by this invention.
[0116] The above specific embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to examples, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for training a biological sequence recognition model, wherein the training method is used to process biological sequences generated by high-throughput sequencing to determine the type of the biological sequence, characterized in that, The training method includes: constructing a reference dataset of biological sequences, wherein the reference dataset includes at least one reference biological sequence and is divided into at least one batch; Construct a biological sequence recognition model, which includes a global representation component and a local representation component, wherein: The global representation component includes a preprocessor, a tagger, an embedding layer, an encoder, a decoder, and an output layer, used to obtain the global representation vector of biological sequences and calculate the global similarity measure between biological sequences; The local characterization component includes a block feature extractor, a local similarity tensor extractor, a local similarity gradient tensor extractor, and a weighted aggregation and pooling module, used to obtain a measure of local similarity between biological sequences; The reference biological sequence is input into the global representation component, and the parameters of the global representation component are iteratively trained using the first loss function to obtain the trained global representation component. The reference biological sequence is input into the local representation component, and the parameters of the local representation component are iteratively trained using the second loss function to obtain the trained local representation component. The trained global representation component and the trained local representation component are combined to form a trained biological sequence recognition model. The step of training the global representation component further includes: In each training iteration, the reference biological sequence is input into the preprocessor within the global representation component. Dynamic disruption is achieved through random insertion, replacement, or deletion operations to simulate biological sequencing errors or gene mutations, thereby obtaining derived biological sequences. The marker process segments the derived biological sequence to obtain derived biological sequence markers and adds global characterization markers; The embedding layer maps the derived biological sequence markers and global representation markers to the derived biological sequence initial embedding vector and the global representation initial embedding vector; The encoder encodes the initial embedding vector of the derived biological sequence and the initial embedding vector of the global representation to obtain the derived biological sequence encoded embedding vector and the global representation encoded embedding vector; The decoder reconstructs and decodes the global representation encoded embedding vector and the initial embedding vector of the derived biological sequence, and the output layer outputs the predicted biological sequence based on the decoding result. The interaction phase between the encoder and the decoder employs a cross-attention mechanism that relies solely on the global representation encoding embedding vector. The first loss function calculates a loss value based on the difference between the predicted biological sequence and the reference biological sequence, and is used to update the parameters of the global characterization component; The step of training the local representation component further includes: in each iteration of training, a reference biological sequence is randomly selected from a batch as the anchor biological sequence, the slightly perturbed biological sequence generated by randomly discarding the anchor biological sequence is used as the positive biological sequence, and the remaining reference biological sequences are used as the negative biological sequences. After inputting the anchor biological sequence and the negative biological sequence into the marker and embedding layer of the global representation component in the biological sequence recognition model, the anchor biological sequence embedding vector and the negative biological sequence embedding vector are obtained respectively. The block feature extractor divides the block into overlapping block tensors based on the anchor biological sequence embedding vector and the negative biological sequence embedding vector, and then performs one-dimensional convolution processing to obtain the anchor biological sequence block tensor and the negative biological sequence block tensor, respectively. After randomly discarding the anchor biological sequence block tensor, the positive biological sequence block tensor is obtained. The local similarity tensor extractor calculates the positive local similarity tensor between the anchor biological sequence block tensor and the positive biological sequence block tensor, and the negative local similarity tensor between the anchor biological sequence block tensor and the negative biological sequence block tensor, respectively. The local similarity gradient tensor extractor calculates the gradient tensors corresponding to the positive local similarity tensor and the negative local similarity tensor, respectively. The similarity tensor and its corresponding gradient tensor are input into the weighted aggregation and pooling module to calculate the positive local similarity measure and the negative local similarity measure, respectively. The second loss function calculates the loss value based on the positive local similarity measure and the negative local similarity measure, and is used to update the parameters of the local representation component.
2. The biological sequence recognition model training method according to claim 1, characterized in that, The steps of inputting the similarity tensor and its corresponding gradient tensor into the weighted aggregation and pooling module to calculate the positive local similarity measure and the negative local similarity measure respectively include: performing element-wise multiplication of the similarity tensor and its corresponding gradient tensor into the weighted aggregation and pooling module to calculate the positive local similarity measure and the negative local similarity measure respectively.
3. The biological sequence recognition model training method according to claim 1, characterized in that, The dynamic destruction refers to randomly performing a set proportion of mixed destruction at different positions in each reference biological sequence. The set proportion of mixed destruction includes a mixed destruction with a ratio of 2 replacements, 1 insertion, and 1 deletion, or a mixed destruction with a ratio of 8 replacements, 1 insertion, and 1 deletion.
4. A method for training a biological sequence recognition model according to claim 1 or 2, characterized in that, The first loss function is the cross-entropy function, and the second loss function is calculated as follows: ,in This represents the positive local similarity measure. This represents the negative local similarity measure. To set the temperature.
5. A biological sequence identification method, wherein the identification method is used to process biological sequences generated by high-throughput sequencing to determine the type of the biological sequence, characterized in that, The identification method includes: using a trained biological sequence identification model obtained by the training method described in any one of claims 1 to 4; The global representation component of the trained biological sequence recognition model is used to process the reference biological sequence to obtain and store the global representation vector of each reference biological sequence. The input biological sequence to be identified is obtained, and the global representation component is used to calculate the global representation vector of the input biological sequence; By calculating the global similarity measure between the global representation vector of the input biological sequence and the global representation vectors of each stored reference biological sequence, the input biological sequence is pre-screened to obtain one or more candidate reference biological sequences, forming a pre-screened biological sequence set. For each candidate reference biological sequence in the pre-screened biological sequence set, the input biological sequence and the candidate reference biological sequence are input into the local representation component of the trained biological sequence recognition model, the local similarity measure between them is calculated, and the input biological sequence is further screened based on the local similarity measure to determine its recognition result.
6. A biological sequence recognition model training system, the system being used to process biological sequences generated by high-throughput sequencing to determine the type of the biological sequence, characterized in that, The training system includes: a data construction module for building a reference dataset of biological sequences; The model building module is used to build a biological sequence recognition model. The biological sequence recognition model includes a global representation component and a local representation component. The global representation component includes a preprocessor, a tagger, an embedding layer, an encoder, a decoder, and an output layer. The local representation component includes a block feature extractor, a local similarity tensor extractor, a local similarity gradient tensor extractor, and a weighted aggregation and pooling module. The model training module is used to train the biological sequence recognition model according to any one of claims 1 to 4, using a first loss function to iteratively train the global representation component and a second loss function to iteratively train the local representation component, so as to obtain the trained global representation component and the trained local representation component. The model storage module is used to store the biological sequence recognition model trained by the model training module.
7. A biological sequence identification system, the system being used to process biological sequences generated by high-throughput sequencing to determine the type of the biological sequence, characterized in that, The identification system includes: a reference biological sequence construction module, used to construct reference biological sequences and their tags; The reference biological sequence characterization module uses a trained biological sequence recognition model obtained by the biological sequence recognition model training method described in any one of claims 1 to 4, which is used to obtain and store the global characterization vector of the reference biological sequence from the global characterization component of the trained biological sequence recognition model. The pre-screening module is used to acquire the input biological sequence to be identified and to calculate the global representation vector of the input biological sequence using the global representation component of the trained biological sequence recognition model. By calculating the global similarity measure between the global representation vector of the input biological sequence and the global representation vectors of each stored reference biological sequence, a pre-screened biological sequence set is obtained. The re-screening module is used to input the input biological sequence and the candidate reference biological sequence into the local representation component of the trained biological sequence recognition model for each candidate reference biological sequence in the pre-screened biological sequence set, so as to calculate the local similarity measure between the two, and output the final recognition result based on the measure.
8. An electronic device, characterized in that, The electronic device includes: a memory and a processor; The memory is used to store program instructions, and the processor is used to execute the program instructions to implement the biological sequence recognition model training method according to any one of claims 1 to 4.
9. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the function of the biological sequence recognition model training system as described in claim 6.
10. An electronic device, characterized in that, The electronic device includes: a memory and a processor; The memory is used to store program instructions; the processor is used to execute the program instructions to implement the biological sequence identification method according to claim 5.
11. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the functions of the biological sequence identification system as described in claim 7.
Citation Information
Patent Citations
Heuristic biological sequence clustering method based on semi-global comparison
CN120299521A
Algorithm model training method and device, algorithm model matching method and device, electronic equipment and medium
CN116894191A
Multi-modal attention deep learning method for enhancing virus recognition in metagenome data
CN118918954A