T cell receptor sequence design method based on discrete diffusion model

By using discrete diffusion models and gradient-guided sampling techniques, the problems of high cost, long cycle time, and limited target coverage of traditional TCR discovery methods have been solved, generating TCR sequences with strong biological rationality and high epitope specificity, thus promoting the development of immunotherapy.

CN121545587APending Publication Date: 2026-02-17HARBIN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511579154.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Traditional TCR discovery methods rely on experimental screening, which are costly, time-consuming, and have limited target coverage. Furthermore, existing computational biology methods are insufficient in terms of biological rationality, binding specificity, and generalization ability, and cannot meet the needs of personalized immunotherapy.

Method used

A TCR sequence design method based on a discrete diffusion model is adopted. By constructing the core framework of the discrete diffusion model, the forward noise addition and backward denoising processes are defined. The natural mutation of TCR is simulated by combining the transition matrix strategy. The denoising network is used to predict the TCR sequence, and the predictor gradient is introduced to guide sampling to optimize the generation of epitope-specific TCR sequences.

Benefits of technology

It enables the efficient and precise generation of TCR sequences with strong biological rationality and high epitope specificity, supports new epitope adaptation, and promotes the development of immunotherapy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121545587A_ABST
    Figure CN121545587A_ABST
Patent Text Reader

Abstract

The invention discloses a T cell receptor sequence design method based on a discrete diffusion model, and relates to a T cell receptor sequence design method. The invention aims to solve the problems that the traditional TCR discovery method depends on experimental screening and has high cost, long period and limited target coverage. According to the method, it is ensured that the generated sequence conforms to the TCR natural evolution law through a BLOSUM transfer matrix, the epitope binding specificity is improved by means of EPredactor gradient guidance, and through experimental verification, the AUC value of the generated sequence on prediction tools such as PISTE reaches 0.925 or above, the KL divergence of bit-score distribution and the real TCR is smaller than or equal to 0.006, the average value of the accessible surface area change (delta SASA) of a binding interface solvent is higher than that of the real TCR, and the method has the advantages that the method is simple and convenient to implement, and the method is suitable for popularization and application. The TCR sequence meeting the immunotherapy application requirement can be efficiently generated, and a key technical support is provided for personalized immunotherapy target development. The invention belongs to the technical field of bioinformatics, computational biology and immunotherapy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for designing T-cell receptor sequences, belonging to the fields of bioinformatics, computational biology, and immunotherapy. Background Technology

[0002] T cells, as a core component of the adaptive immune system, initiate an immune response by specifically recognizing the peptide-major histocompatibility complex (pMHC) on the surface of antigen-presenting cells (APCs) through their T cell receptors (TCRs). The antigen recognition specificity of the TCR is primarily determined by complementarity-determining region 3 (CDR3), while the V(D)J gene recombination mechanism can theoretically generate… Different TCR sequences provide the basis for the diversity of immune responses.

[0003] In the field of cancer immunotherapy, TCR-T cell therapy, as an important branch of adoptive cell therapy (ACT), faces a core bottleneck in the design of efficient and specific TCR sequences. Traditional TCR discovery methods rely on experimental screening, which suffers from high costs, long cycles, and limited target coverage. Furthermore, tumor immune escape mechanisms further restrict the clinical application of existing therapies. To overcome these limitations, computational biology methods have gradually become a key tool for TCR design, but current technologies have significant shortcomings: Lack of biological rationality: TCR language models such as TCR-BERT and TAPIR often simplify TCR sequences into natural language sentences, ignoring their unique biological mutation patterns and evolutionary constraints, resulting in insufficient biological rationality of the generated sequences; Insufficient binding specificity: Translation-based generative models such as TCR-TRANSLATE treat epitope-specific TCR generation as a "sequence-to-sequence" translation task, which cannot effectively integrate the functional constraints of TCR-epitope binding, and the binding specificity and diversity of generated sequences need to be improved. Limited generalization ability: Traditional Gaussian diffusion models have limitations on discrete protein sequences (such as TCRs), cannot directly preserve the discrete characteristics of the sequence, and are difficult to simulate the biological laws of amino acid mutations. They also have poor adaptability to unseen new epitopes (pMHCs not appearing in the training set) and cannot meet the needs of personalized immunotherapy.

[0004] Therefore, developing a TCR generation method that can mimic the natural mutation process of TCRs, integrate functional constraints, and support the adaptation of new epitopes is of great significance for promoting the development of immunotherapy. Summary of the Invention

[0005] To address the problems of high cost, long cycle, and limited target coverage associated with traditional TCR discovery methods that rely on experimental screening, this invention proposes a T-cell receptor sequence design method based on a discrete diffusion model.

[0006] The technical solution adopted by the present invention to solve the above problems is as follows: The steps of the present invention include: Step 1: Extract TCR-pMHC data from public databases, combine the data, construct and partition the dataset; Step 2: Define the core framework of the discrete diffusion model and clarify the mathematical logic of the forward noise addition process and the reverse noise reduction process; Step 3: Design two transition matrix strategies to simulate the biological laws of natural TCR mutation and control the noise addition process of the forward sequence; Step 4: Construct a combined guided denoising network, based on the TCR-epitope combined prediction model, to predict the original TCR sequence; Step 5: Following the TCR-epitope combined prediction model architecture in Step 4, additionally train the combined predictor and optimize the predictor performance to ensure the reliability and effectiveness of the gradient signal. Step 6: Introduce a predictor gradient-guided sampling mechanism to incorporate the predictor gradient into the inverse denoising process; Step 7: Set the model training objectives and procedures, and iteratively optimize the model parameters; Step 8: Develop a TCR sequence generation process. Based on the trained model and gradient guidance strategy, generate epitope-specific TCR sequences step by step from random sequences. Step 9: Design a multi-dimensional sequence generation verification scheme to verify the quality and rationality of the generated TCR sequences.

[0007] Furthermore, step 1 specifically includes: Step 101: Screening data sources: Collect experimentally validated TCR-pMHC binding pairs from public databases to ensure data authenticity and diversity. Specific sources include: core validation database and supplementary datasets. Step 102: Data preprocessing: Standardize the collected raw data to remove noise and redundant information, ensuring it meets the model input requirements; specifically including: Sequence focusing: Only the TCR β chain CDR3 sequence and the MHC pseudo-sequence are retained; Species filtering: Exclude TCR-pMHC data from non-human sources to avoid interference from species-specific differences in model training; Standardized format and length filtering: All sequences are converted to the standard amino acid single-letter encoding format, and abnormal length data are discarded to ensure the consistency and biological rationality of the input sequences; Step 103, Dataset Partitioning Rules: Divide the data according to the two core uses of "training-testing" to avoid data cross-leakage and ensure the objectivity of the evaluation results; Training set: Contains 330K TCR-pMHC pairs, covering all data in the MIRA dataset and pMHC pairs that appear less frequently in non-MIRA datasets, used for iterative optimization of model parameters; Test set: Contains 68K TCR-pMHC pairs. Only the 20 most frequent pMHC pairs are selected from the non-MIRA dataset. It is ensured that the epitopes in the test set are not seen during training. This set is used to evaluate the model's generalization ability to new epitopes. Predictor-specific validation set: 10% of the data is allocated from the training set for performance validation of the additionally trained TCR-pMHC predictor. This set is strictly isolated from the DTCR model training data to avoid evaluation bias caused by data leakage.

[0008] Furthermore, step 2 specifically includes: Step 201, Core Principle of the Model: The discrete diffusion model generates the TCR sequence through a two-way process of "forward noise addition - backward noise reduction," with the specific logic as follows: Forward noise addition process: using the original true TCR sequence, denoted as... Using this as the initial input, biologically-compliant "mutation noise" is gradually introduced through a discrete Markov chain, causing the sequence to change over time. , Gradually deviating from the original state, it eventually transforms into a completely random amino acid sequence at time step T, denoted as... This process mimics the natural accumulation of mutations in TCRs in vivo; Reverse denoising process: Train a parameterized denoising network, with model parameters denoted as... , with random sequence Starting with the target pMHC information, the forward noise-adding process is gradually reversed to correct "noise mutations" in the sequence, ultimately recovering a biologically plausible and epitope-specific TCR sequence. ; Step 202, Key Mathematical Definitions: To clarify the computational logic of each step in the model, the following core mathematical formulas are defined to ensure that the process is quantifiable and reproducible; Forward transition probability: describes the time step Time series from Transform into The probability is represented by a class distribution, and the transition process is determined by the transition matrix. control: , in, for Dimensional matrix , representing 20 common amino acids, matrix elements Indicates time step amino acids Mutation into amino acids The probability of , and the sum of the elements in each row is 1; Marginal distribution: time step Time series Relative to the original sequence The conditional distribution is equal to the previous one. The cumulative product of the step transition matrices reflects the cumulative effect of progressively adding noise to the sequence: , , in, , Indicates from arrive The chain multiplication of the transition matrices, This indicates element-wise multiplication. Predicted by a denoising network, It is the original sequence The predicted distribution; Inverse denoising probability: derived based on Bayes' theorem, describing the probability from the current sequence Restore the previous time step sequence The probability needs to be combined with the original sequence distribution predicted by the denoising network: , in, The original sequence output by the denoising network The probability distribution, For the forward process generate and The joint probability.

[0009] Furthermore, step 3 involves two transition matrix strategies: a stochastic transition matrix and a BLOSUM transition matrix. The stochastic transition matrix is ​​adapted to the model variant DTCR-R, while the BLOSUM transition matrix is ​​adapted to the core model DTCR. random transition matrix Matrix definition: Based on the assumption of uniform random mutation, and considering both the "unchanged" and "randomly mutated" states of amino acids, the formula is as follows:

[0010] Where I is identity matrix for A matrix of all ones. For time steps The noise intensity parameter varies with Increasing monotonically, adopting The linear scheduling method results in a completely random sequence; Key features: It simulates the random mutation process of TCR sequences, generating high sequence diversity, but does not consider the evolutionary relationships between amino acids. It is suitable for basic diversity generation scenarios and can be used as a control strategy to verify the necessity of evolutionary constraints. BLOSUM transition matrix Matrix construction process: Based on the BLOSUM62 matrix, a transition matrix with evolutionary constraints is constructed in three steps; Rating Transformation: Perform a Softmax operation on each element of the BLOSUM62 matrix to convert the original evolutionary ratings into initial probabilities, using the following formula: , Double randomization: The Sinkhorn-Knopp algorithm is used to normalize the rows and columns of the initial probability matrix to ensure that the final matrix satisfies the double randomness property, that is, the sum of the elements in each row and each column is 1, which meets the probability distribution requirements; Intensity scheduling: An exponential scheduling method is used to ensure time steps The mutation probability is approximately 0.5, simulating the dynamic process of "low-intensity mutation accumulation" in natural evolution; Key features: Integrating amino acid evolutionary constraints makes the mutation process more consistent with the natural variation of TCRs in vivo, significantly improving the biological rationality of the generated sequences, which is the strategy adopted by the core model.

[0011] Furthermore, the core function of the denoising network in step 4 is based on the current noisy sequence. Predict the original TCR sequence using target pMHC information. The distribution of TCRs and key binding patterns with epitopes were captured. The specific construction scheme is as follows: Step 401: Select the basic model. The physics-inspired sliding Transformer model is selected as the basic architecture of the denoising network, which is highly compatible with the TCR generation task. Replacing the traditional data-driven attention mechanism with a physical-driven dynamic process can more accurately capture the interaction patterns between TCR and epitopes. It natively supports using MHC pseudo-sequences as input features and directly incorporates pMHC specificity constraints without requiring additional modification to the input structure, which meets the core requirement of "generating specific TCRs based on target pMHC". Step 402: Network structure adaptation and adjustment. In view of the special characteristics of the TCR sequence generation task, the PISTE model is modified as follows to optimize the sequence prediction accuracy. Feature encoder projection direction adjustment: The original PISTE model projects the TCR and epitope sequences onto the MHC pseudo-sequence backbone; this is changed to project the MHC pseudo-sequence and epitope sequences onto the TCR sequence, resulting in an output dimension of [missing dimension]. TCR-pMHC joint feature representation , The length of the TCR sequence. As a feature dimension, it strengthens the core position of TCR sequences; Multi-layer self-attention module: After the joint feature output, a multi-layer self-attention module is added to further capture the long-range dependencies within the TCR sequence and improve the overall consistency of the sequence; MLP prediction layer: Employs a two-layer fully connected network to map the features output by the self-attention module to... probability matrix The probability vector at each position corresponds to the class distribution of the amino acid at that position, i.e. The final output is used for subsequent sequence sampling; Step 403: During the training and inference process of the denoising network, pMHC is always used as the conditional input to ensure the epitope specificity of the generated sequence. Training phase: The pMHC sequence is compared with the noisy sequence. After splicing, input into the network, only for The corresponding features are updated with gradients. The pMHC sequence is used as a fixed condition feature and does not participate in gradient calculation to avoid the condition information being modified. Inference phase: Keep the pMHC sequence input unchanged, and only process the noisy sequence. Iterative denoising is performed to ensure that each denoising step revolves around the target pMHC, and the generated sequence is always specific to that pMHC.

[0012] Furthermore, step 5 specifically includes: Step 501: Define the core objectives and input / output of the predictor; The additionally trained TCR-pMHC combined predictor is denoted as The core objective is to output a combination probability score based on the input TCR sequence and the target pMHC sequence, providing a reliable functional constraint signal for gradient-guided sampling. The specific definition is as follows: Input structure: The input format is a combination of "TCRβ chain CDR3 sequence + epitope sequence + MHC sequence". The sequence format and length requirements are the same as those in the preprocessing results in step 1. Output format: The single-channel probability value is output through the Sigmoid activation function, with a value range of [0,1]. The higher the score, the stronger the binding specificity. At the same time, the prediction confidence is output. The variance is calculated through 5 Dropout samplings. The smaller the variance, the higher the confidence, which is used to filter low reliability gradient signals. Step 502: Predictor network architecture design; Based on the basic architecture of the denoising network in step 4, The design of "shared feature encoder + dedicated prediction head" is adopted to ensure compatibility with the denoising network. The dedicated prediction head is structured as follows: it combines the output of the two fully connected network and the Sigmoid layer with the probability. At the same time, it calculates the prediction variance through Dropout sampling to evaluate the confidence level and ensure the reliability of the prediction results. Step 503: Predictor training data and loss function; Training data source: 10K TCR-pMHC binding pairs were extracted from the predictor-specific validation set divided in step 1. Positive samples are validated binding pairs, and negative samples are generated through "reference TCR negative sampling" to ensure a balanced distribution of positive and negative samples. Loss function design: A composite loss function of "cross-entropy loss + confidence-weighted loss" is adopted, as shown in the following formula:

[0013] in, For the sample size, The true label is 0 / 1. To predict the binding probability, To predict variance, The confidence weighting coefficient can increase the loss on low-confidence samples, constrain its gradient calculation, make the predictor's error smaller on high-confidence samples, and suppress the interference of low-confidence samples. Step 504: Predictor training and performance verification; Training parameter settings: The optimizer used is AdamW, the batch size is 64, the number of training epochs is 50, and an early stopping strategy is adopted to avoid overfitting; Performance validation metrics: AUC, precision, recall and F1 score are used as core metrics. The requirement is that AUC ≥ 0.9 on independent test subsets to ensure that the accuracy of the predictor is sufficient to provide reliable gradient signals. Gradient validity verification: 100 real TCR-pMHC binding pairs were randomly selected, and single-amino acid perturbations were applied to the TCR sequences to verify the validity. The change in the output binding probability—the probability decrease caused by the perturbation in the antigen contact area must be significantly greater than that in the non-contact area to ensure that the gradient direction conforms to biological laws.

[0014] Furthermore, in step 6, based on the core idea of ​​"guiding the generation process through discriminator gradients to balance sequence naturalness and functional objectives," The gradient signal is incorporated into the inverse denoising process of DTCR to achieve closed-loop optimization of "generation-evaluation-correction"; Step 601: The core logic and mathematical expression of gradient guidance; The core of gradient-guided denoising is: in each step of inverse denoising, by calculating... The output is the gradient of the hidden state of the denoising network, which is used to adjust the direction of the hidden state to optimize the generated TCR sequence towards a direction with higher binding probability. Simultaneously, KL divergence constraints are used to ensure the biological naturalness of the sequence. Let the hidden state at step t in the reverse denoising process be... The target pMHC sequence is Then the gradient-guided objective function is defined as: , in: This is the initial hidden state for this denoising step. Based on TCR sequence predicted distribution, Let KL divergence be the KL divergence. The naturalness constraint coefficient ensures that the guided sequence still conforms to the natural distribution of TCR; The gradient-guided strength coefficient controls the priority of the combined optimization. Step 602: Gradient calculation and hidden state update process; Combining the Langevin dynamics sampling approach, gradient guidance is embedded in each step of the inverse denoising process. The specific workflow is as follows: Initial hidden state acquisition: The noisy sequence at step t. Input the denoising network encoder to obtain the initial hidden state. ; Gradient calculation: With target pMHC enter Calculated using automatic differentiation tools Output pair gradient ; Langevin gradient update: for conduct The next iteration update uses the following formula:

[0015] Where k is the number of iterations. , Step size, Add a small Gaussian noise to the noise temperature setting. To avoid getting trapped in local optima; Post-update state verification: Calculate the hidden state after the update. Corresponding TCR sequence prediction distribution ; Step 603: The collaborative mechanism between gradient guidance and denoising; designing a progressive collaborative constraint strategy: Timing control: In the first 1 / 3 of the reverse denoising steps Only basic denoising is performed, prioritizing the restoration of the sequence's natural structure; in the subsequent 2 / 3 steps... Gradient guidance is gradually introduced, and It increases linearly as t decreases, thus achieving a progressive guidance that prioritizes naturalness before optimizing functionality. Epitope conditions are fixed: throughout the gradient-guided process, the target pMHC The input features remain fixed to ensure that the guidance direction is always aimed at a specific table position, thus avoiding guidance deviation caused by distortion of table position information; Confidence filtering: If For the present The confidence level of the corresponding predicted sequence Below the threshold of 10, i.e. If the gradient guidance step is not performed, then only basic denoising is performed to avoid introducing erroneous guidance signals by low-confidence gradients.

[0016] Furthermore, step 7 specifically includes: Step 701: Train the objective function, with the core training objective being to optimize the variational upper bound of the negative log-likelihood. The objective function formula is as follows: Core VLB loss The formula for measuring the consistency between the forward noise addition process and the backward noise reduction process is:

[0017] in, Let KL divergence be the KL divergence. For the expectation, The prior distribution is a random sequence; Step 702, Training Iteration Process, including: Step 7021, Data Loading: Randomly sample a batch of TCR-pMHC pairs from the training set, denoted as... ; Step 7022, Time step sampling: From , A time step t is randomly selected within the range to generate the noisy sequence for the current batch; Step 7023, Forward Noise Addition: Based on the selected transition matrix, through... Generate noisy sequences ; Step 7024, Gradient Guidance and Network Prediction: ... Input the denoising network and obtain the hidden state. ;based on Output the original sequence Predicted distribution ; Step 7025, Loss Calculation and Parameter Update: Based on Calculate the loss value for the current batch and update the denoising network using the backpropagation algorithm; Step 7026, Convergence Judgment: Repeat steps 7021 to 7025 for 100 epochs. When the validation set... If there is no decrease for 10 consecutive epochs, stop training and save the current model parameters.

[0018] Furthermore, in step 8, based on the trained discrete diffusion model and gradient-guided strategy, epitope-specific TCR sequences are generated step by step from the random sequence. The specific steps are as follows: Step 801, Initialize generation parameters: Determine the target pMHC information and fix the input model; Generate a random amino acid sequence of length L. The amino acids at each location were uniformly sampled from 20 common amino acids; Set the total number of diffusion steps. Current time step Gradient guiding strength coefficient Initial value: 0.05; Step 802, Basic Iterative Denoising: In the first 1 / 3 steps of reverse denoising Only basic denoising is performed, prioritizing the restoration of the sequence's natural structure; step : Set the current sequence The time step t and the target p are input to the MHC denoising network to obtain the hidden state. ; Sequence sampling: based on Corresponding prediction distribution A multinomial sampling strategy was used to obtain ; Parameter update: Let Return to the above steps and continue iterating until... ; Step 803: Gradient-guided iterative denoising: Gradient guidance is gradually introduced in the subsequent 2 / 3 steps, and It increases linearly as t decreases, thus achieving a progressive guidance that prioritizes naturalness before optimizing functionality. step : Set the current sequence The initial hidden state is obtained by inputting the target pMHC denoising network at time step t and time step t. ; Gradient calculation and hidden state update: call ,enter and Calculate the gradient and perform Langevin update to obtain the guided hidden state. ; Sequence sampling: based on Corresponding prediction distribution A multinomial sampling strategy was used to obtain ; Parameter update: Let , Return to the above steps and continue iterating until... ; Step 804, Final Sequence Generation and Filtering: when At this point, the final denoising and sampling are completed, yielding the initially generated TCR sequence. ; Basic filtration: Discard sequences that lack cysteine ​​at the N-terminus or phenylalanine / tryptophan at the C-terminus; Specificity verification: passed Evaluate and The binding probability and retention probability of sequences ≥ 0.8 were used to obtain epitope-specific TCR sequences. .

[0019] Furthermore, in step 9, a comprehensive validation scheme is designed from three core dimensions: specificity, biological rationality, and structural stability, to evaluate the quality of the generated TCR sequence and ensure that it meets the requirements for immunotherapy applications. Step 901: Specificity Validation. Five mainstream TCR-epitope binding prediction tools were used to verify the binding specificity of the generated sequences from different model perspectives: Evaluation method: Input the generated TCR sequence and target epitope into each prediction tool and output the binding probability; use the real binding TCR sequence in the test set as the positive control and the randomly generated non-binding TCR sequence as the negative control, plot the ROC curve and calculate the AUC value; Step 902: Biocompatibility Verification. Verify whether the generated sequence conforms to the biological characteristics of a real TCR, avoiding deviation from the natural immune lineage. Sequence homology verification: The generated sequences are compared with the reference library using the BLAST tool, and the bit-score is calculated. It is required that 90% of the generated sequences have a bit-score in the range of 28-33. Generation probability verification: Use the OLGA tool to calculate the natural occurrence probability of the generated sequence in vivo, requiring the probability to fall within the range of 1 / 2. interval; Distribution consistency verification: Calculate the Kullback-Leibler divergence between the generated sequence and the real TCR sequence in terms of bit-score and OLGA probability. The requirement that the KL divergence ≤ 0.1 indicates that the two have high distribution consistency. Step 903: Structural stability verification. The structural stability of the generated TCR-target pMHC complex is evaluated using structural prediction tools to verify the physical rationality of the binding. Combined with interface analysis: The TCRdock tool was used to predict the complex structure and calculate the change in solvent-accessible surface area ΔSASA of the CDR3 region before and after binding. The larger the ΔSASA value, the larger the binding interface and the stronger the specificity. The mean ΔSASA value should be higher than the average level of the real TCR. Binding affinity score: The binding interface score of the complex was calculated using the RosettaDock-5.0 tool. The smaller the score, the stronger the binding affinity. The average score should be lower than the average score of the real TCR to ensure better structural stability.

[0020] The beneficial effects of this invention are: This invention simulates the natural mutation of TCR by defining a discrete sequence noise-adding process, constructs a denoising network by combining a TCR-epitope combination prediction model, and innovatively introduces an additional trained TCR-epitope predictor gradient-guided sampling, ultimately achieving accurate and controllable generation of epitope-specific TCR sequences; This invention provides a TCR generation method that can simulate the natural mutation process of TCR, integrate and bind functional constraints, and support the adaptation of new epitopes, which is of great significance for promoting the development of immunotherapy. Attached Figure Description

[0021] Figure 1 This is a schematic diagram illustrating the evaluation of the binding specificity of the generated sequence using multiple discriminators; Figure 1 (a) and Figure 1 (b) Shows the performance of all models under the reference TCR negative sampling strategy; Figure 1 (c) and Figure 1 (d) shows the performance of all models under the unified table position negative sampling strategy; Figure 2This is a schematic diagram illustrating the consistency between the generated T cell receptor (TCR) and the real binding TCR in terms of BLAST bit score and generation probability distribution. Figure 2 (a) is a comparison of the BLAST bit value distribution of different models across all epitopes; Figure 2 (b) is a comparison of the BLAST bit value distribution of different models for a specific epitope; Figure 2 (c) is a comparison of the OLGA generation probability distributions of different models across all epitopes; Figure 2 (d) is a comparison of the OLGA generation probability distributions of different models for a specific epitope; Figure 3 This is a schematic diagram of the cumulative distribution function (CDF) analysis showing the consistency between the generated T cell receptor (TCR) and the real binding TCR; Figure 3 (a) is a comparison of the cumulative distribution functions of BLAST bit scores for all epitopes for different models; Figure 3 (b) is a comparison of the cumulative distribution functions of BLAST bit values ​​for a specific epitope using different models; Figure 3 (c) is a comparison of the cumulative distribution functions of OLGA generation probabilities for different models across all epitopes; Figure 3 (d) is a comparison of the cumulative distribution function of the OLGA generation probability for a specific epitope for different models; Figure 4 This is a schematic diagram illustrating the structural analysis and binding affinity assessment of T cell receptors (TCRs) generated by DTCR (a discrete diffusion model-based T cell receptor sequence design method). Figure 4 (a) represents the change in solvent accessible surface area (ΔSASA) for 100 TCR-generating epitopes corresponding to the four epitopes; Figure 4 (b) is the distribution of the binding interface score between the generated TCR and the peptide-major histocompatibility complex (pMHC) calculated using RosettaDock-5.0; Figure 4 (c) is a visualization of the interaction between the generated TCR and a specific epitope; Figure 5 This is a flowchart of a T-cell receptor sequence design method based on a discrete diffusion model; Figure 6This is an overview of T cell receptor sequence design methods based on discrete diffusion models; Figure 6 (a) is the specific binding of T cells to antigen-presenting cells (APCs): T cell receptors (TCRs) on the surface of T cells can specifically recognize and bind to peptide-major histocompatibility complex (pMHC) presented on the surface of APCs. This interaction is crucial for initiating T cell activation and subsequent immune responses. Figure 6 (b) is the design of the TCR complementarity-determining region (CDR) sequence: the design focuses on the hypervariable region CDR3 of the TCR β chain (a key region for antigen recognition); due to the vast TCR sequence combinatorial space (approximately... to Traditional methods face challenges in generating sequences that combine diversity and specificity; DTCR solves this problem by using evolutionary and functional constraints to guide sequence generation. Figure 6 (c) is an overview of the DTCR process for generating CDR sequences using a diffusion model: This model defines a discrete Markov forward process for sequence corruption through two different transition matrix strategies (one based on random transitions and the other using BLOSUM matrices). These transition matrices control the changes in amino acid types, simulating the protein sequence mutation mechanism. By integrating an advanced TCR-epitope binding prediction model, DTCR constructs a denoising neural network to predict the state changes at each time step. Finally, DTCR can generate new epitope-specific TCR sequences from random amino acid sequences, conditioned on pMHC, through a reverse denoising process. Detailed Implementation

[0022] Specific Implementation Method 1: A method for designing T-cell receptor sequences based on a discrete diffusion model, comprising the following steps: Step 1: Experimental environment setup; Hardware environment Computational core: The GPU is an NVIDIA A100 80GB (supporting large-scale matrix operations and mixed-precision training, meeting the iteration requirements of discrete diffusion models); the CPU is an Intel Xeon 8375C (32 cores and 64 threads, used for data preprocessing and model parameter loading); the memory configuration is 256GB DDR4 (ensuring that the 100K-level TCR-pMHC dataset can be loaded at once, avoiding data IO bottlenecks); Storage device: 2TB NVMe solid-state drive (used to store training datasets, pre-trained model weights and generated sequence results, with read and write speeds ≥3500MB / s, improving data access efficiency); Software environment Basic dependencies: Python 3.9, PyTorch (deep learning framework, supporting automatic differentiation and GPU acceleration), CUDA 12.0 (optimized matrix operation efficiency). Bioinformatics tools: Biopython (for format conversion and basic analysis of TCR and epitope sequences), OLGA (for calculating the in vivo natural occurrence probability of generated sequences), TCRdock (based on the AlphaFold2 derived model, for predicting the structure of TCR-pMHC complexes), RosettaDock 5.0 (for calculating complex binding interface scores and assessing structural stability). Model training tool: WandB (real-time monitoring of training loss, generated sequence quality, and other metrics, facilitating parameter tuning); Dataset preparation Data source and preprocessing: 398K human TCR-pMHC pair data were extracted from VDJdb, IEDB, and McPAS-TCR public databases. After screening, 330K training set data (including MIRA supplementary dataset) and 68K test set data (including 20 high-frequency pMHCs not seen in the training set) were retained. The specific screening rules and preprocessing operations are as described in step 1 of "IV. Summary of the Invention". Data format: All TCR β chain CDR3 sequences, epitope sequences, and MHC sequences are converted into single-letter codes for amino acids and stored in CSV format. The fields include “TCR_CDR3β”, “Epitope”, “MHC_Pseudo”, and “Label” (1 indicates binding, 0 indicates non-binding). Reference library configuration: Download 11 million real human TCR β chain CDR3 sequences to build a reference library (used for generating sequence homology verification), store in FASTA format, and build an index using BLAST+ 2.14.0 to improve alignment efficiency; Step 2: Core parameter settings; Discrete diffusion model parameters Diffusion steps: Total time steps (Balancing generation efficiency with sequence quality, as verified by experiments) This can lead to insufficient diversity in the generated sequences. This will significantly increase training time. Transition matrix parameters: BLOSUM transition matrix (core model DTCR): constructed based on the BLOSUM62 matrix and calculated using an exponential scheduling strategy. , , ,make sure The mutation probability is approximately 0.5. Stochastic transition matrix (comparison model DTCR-R): employing a linear scheduling strategy. When t=100 ; Noise Scheduling: Cosine noise scheduling is used in the forward noise addition process. , To prevent the sequence from falling into a random state too early; Denoising network parameters Basic architecture: Transformer layers = 3, attention heads = 9, hidden layer dimension = 512, word embedding dimension = 64 (amino acid embeddings use a learnable matrix); Prediction Head: The MLP prediction layer contains two hidden layers with dimensions of 1024 and 512 respectively, and the output layer has a dimension of... (L is the TCR sequence length, 20 corresponds to 20 amino acids), and the output probability distribution is activated using Softmax. Additional training predictor ( )parameter Training parameters: Optimizer is AdamW, learning rate = 1e-4, weight decay = 1e-5, batch size = 64, training epochs = 50, early stopping patience = 10 (training stops if the validation set AUC does not improve for 10 consecutive epochs). Training and generating parameters Training configuration: The optimizer is AdamW, the initial learning rate is 1e-4, and a linear warm-up is used (increasing from 1e-6 to 1e-4 in the first 1000 steps, then cosine decay to 1e-6); the batch size is 64, the maximum number of training epochs is 100, and the gradient clipping threshold is 1.0 (to prevent gradient explosion). Generation configuration: The sampling strategy is multinomial sampling, generating 2000 sequences per target pMHC, with sequence lengths ranging from 8 to 30 (consistent with the length distribution of the real TCR β chain CDR3); gradient guidance steps. Langzhi Wanbu Chang Noise temperature ; Step 3, Model Training Implementation Steps: Data preprocessing execution Data download and filtering: Download the VDJdb, IEDB and McPAS-TCR datasets from the official websites of each database, use Biopython to filter out samples of human origin and with sequence lengths that meet the requirements, and finally obtain 398K raw data. Dataset partitioning: The data was partitioned into a training set (330K records), a test set (68K records), and a predictor validation set (10K records, independently partitioned from the training set) using stratified sampling (stratified by the frequency of pMHC occurrences). Feature encoding: The TCR β chain CDR3 sequence, epitope sequence, and MHC pseudo-sequence are converted into single-letter codes and encoded into vectors through a learnable embedding matrix (dimension 256). The initial values ​​of the embedding matrix are initialized using a normal distribution. Denoising Network Training Model initialization: Load the PISTE basic model architecture, modify the projection direction and add attention modules and prediction heads, initialize model weights, and set the transition matrix to the BLOSUM transition matrix; Training iteration: Optimizing VLB loss ( Every 5 rounds, the sequence recovery accuracy is evaluated on the validation set (the accuracy of the predicted sequence is calculated based on the real TCR sequence), and the model weights are saved every 5 rounds. The weights with the smallest loss on the validation set are selected as the final model. Training monitoring: The training loss, learning rate changes, and validation set sequence recovery accuracy are recorded using WandB. Early stopping is triggered when the validation set loss does not decrease for 10 consecutive rounds. EPredictor Training Data preparation: Extract 10K TCR-pMHC pairs from the predictor validation set and construct positive and negative samples in a 1:1 ratio (positive samples are true binding pairs, and negative samples are generated by "reference TCR negative sampling" (randomly selecting sequences from the non-binding TCR library that are different from the positive sample TCR sequences, labeled 0)). Training execution: Load and freeze the feature encoding layer shared with the denoising network, initialize the prediction head parameters, and apply a composite loss function ( Training, batch size = 64, training epochs = 50, AUC and F1 score are evaluated in each epoch; Performance validation: After training, validate on 2K independent test samples, requiring AUC≥0.92 and F1≥0.85. Otherwise, adjust the learning rate (e.g., reduce to 5e-5) and retrain until the performance requirements are met. Step 4: TCR sequence generation implementation steps; Taking the target epitope "LLLDRLNQL" (MHC allele: HLA-A*02:01, SARS-CoV-2 related epitope) as an example, the TCR sequence generation process is explained in detail: Preparation before generation Target pMHC determination: Extract the pMHC pair from the test set and confirm that it does not appear in the training set (to ensure evaluation of generalization ability), and obtain the epitope sequence "LLLDRLNQL" and the MHC pseudo-sequence "YFAMYGEKVAHTHVDTLYVRYHYYTWAVLAYTWY"; Model loading: Load the trained DTCR model (BLOSUM transition matrix) and Set generation parameters , Linearly increasing, sample size = 2000); Initial sequence generation: Generates random amino acid sequences of length 8-30. Each location was sampled uniformly from 20 amino acids; Iterative Denoising and Gradient Guidance Time step iteration (t=100→t=1): t=100→t=67 (first 1 / 3 steps): Only perform basic noise reduction, Input denoising network with target pMHC and t, predict The distribution of the sequence is sampled, and the natural structure of the sequence is restored first. t=66→t=1 (last 2 / 3 steps): Gradient guidance is introduced, first obtained through a denoising network. ,enter Calculate the gradient and perform 5 Langevin updates to obtain Based on sampling ; Gradient validity control: After each generation step, calculate The prediction confidence of the current sequence, if If so, skip the gradient guidance step and only perform basic denoising; Sequence filtering: At t=1, 2000 initial generated sequences are obtained. Sequences without C at the N end and without F / W at the C end are filtered out, and 1985 valid sequences are retained. Generate sequence evaluation Specificity assessment: such as Figure 1As shown, 1985 sequences were input into five combination prediction tools, including PISTE and ERGO, and the AUC value was calculated. The results showed that the AUC on PISTE was 0.925 (higher than the 0.860 of the contrast model TCR-TRANSLATE), which met the specificity requirements. Biological rationale assessment: such as Figure 2 and Figure 3 As shown, BLAST alignment with the reference library revealed that 92% of the sequences had a bit score between 28 and 33 (consistent with the true TCR distribution); OLGA calculations showed that the probability of the sequences occurring naturally fell within the range of... The KL divergence is 0.006 (high consistency with the true TCR distribution). Structural stability assessment: such as Figure 4 As shown, the TCRdock predicted the complex structure with a mean ΔSASA of 430.3 (higher than the 329.2 of the real TCR); the RosettaDock calculated the interface score with a mean of -4.66 (lower than the -4.37 of the real TCR, indicating stronger affinity), meeting the structural stability requirements. Step 5: Result Comparison and Analysis; Performance comparison with mainstream models On the test set of 20 pMHCs, DTCR was compared with TCR-TRANSLATE and GRATCR (the current mainstream TCR generative model). The results are shown in the table below: Table 1

[0023] Key conclusions Specific advantages: The AUC value of the DTCR generated sequence is close to that of the real TCR and is significantly higher than that of the comparison model, indicating that the gradient guidance mechanism effectively improves the epitope binding specificity; Biological rationale: The bit-score and OLGA probability distribution of the DTCR generated sequence are highly consistent with the real TCR, proving that the natural mutation process simulated by the BLOSUM transition matrix conforms to the evolutionary law of TCR; Structural stability: The larger ΔSASA and lower binding interface score of the DTCR generated sequence indicate that its binding interface with the target pMHC is superior and its affinity is stronger, meeting the requirements for TCR structural stability in immunotherapy applications. Step 6, Precautions and Optimization Suggestions; Data leakage prevention: Ensure that the pMHC of the training set, test set, and predictor training-validation set does not overlap, and use independent scripts to partition the data during preprocessing to avoid data leakage; Batch generation efficiency: If multiple pMHC sequences need to be generated in batches, multi-GPU distributed generation can be used (e.g., two A100 GPUs can process different pMHCs simultaneously). Sequence diversity enhancement: If the generated sequence diversity is insufficient (e.g., bit-score distribution is too concentrated), the Langevin noise temperature can be increased. Up to 0.005, or use non-uniform sampling (based on real TCR amino acid frequency sampling) during initial sequence generation.

[0024] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent substitutions, and improvements made to the above embodiments without departing from the scope of the present invention, based on the technical essence of the present invention and within the spirit and principles of the present invention, shall still fall within the protection scope of the present invention.

Claims

1. A method for designing T-cell receptor sequences based on a discrete diffusion model, characterized in that, The specific steps include: Step 1: Extract TCR-pMHC data from public databases, combine the data, construct and partition the dataset; Step 2: Define the core framework of the discrete diffusion model and clarify the mathematical logic of the forward noise addition process and the reverse noise reduction process; Step 3: Design two transition matrix strategies to simulate the biological laws of natural TCR mutation and control the noise addition process of the forward sequence; Step 4: Construct a combined guided denoising network, based on the TCR-epitope combined prediction model, to predict the original TCR sequence; Step 5: Following the TCR-epitope combined prediction model architecture in Step 4, additionally train the combined predictor and optimize the predictor performance to ensure the reliability and effectiveness of the gradient signal. Step 6: Introduce a predictor gradient-guided sampling mechanism to incorporate the predictor gradient into the inverse denoising process; Step 7: Set the model training objectives and procedures, and iteratively optimize the model parameters; Step 8: Develop a TCR sequence generation process. Based on the trained model and gradient guidance strategy, generate epitope-specific TCR sequences step by step from random sequences. Step 9: Design a multi-dimensional sequence generation verification scheme to verify the quality and rationality of the generated TCR sequences.

2. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, Step 1 specifically includes: Step 101: Screening data sources: Collect experimentally validated TCR-pMHC binding pairs from public databases to ensure data authenticity and diversity. Specific sources include: core validation database and supplementary datasets. Step 102: Data preprocessing: Standardize the collected raw data to remove noise and redundant information, ensuring it meets the model input requirements; specifically including: Sequence focusing: Only the TCR β chain CDR3 sequence and the MHC pseudo-sequence are retained; Species filtering: Exclude TCR-pMHC data from non-human sources to avoid interference from species-specific differences in model training; Standardized format and length filtering: All sequences are converted to the standard amino acid single-letter encoding format, and abnormal length data are discarded to ensure the consistency and biological rationality of the input sequences; Step 103, Dataset Partitioning Rules: Divide the data according to the two core uses of "training" and "testing" to avoid data cross-leakage and ensure the objectivity of the evaluation results; Training set: Contains 330K TCR-pMHC pairs, covering all data in the MIRA dataset and pMHC pairs that appear less frequently in non-MIRA datasets, used for iterative optimization of model parameters; Test set: Contains 68K TCR-pMHC pairs. Only the 20 most frequent pMHC pairs are selected from the non-MIRA dataset. It is ensured that the epitopes in the test set are not seen during training. This set is used to evaluate the model's generalization ability to new epitopes. Predictor-specific validation set: 10% of the data is allocated from the training set for performance validation of the additionally trained TCR-pMHC predictor. This set is strictly isolated from the DTCR model training data to avoid evaluation bias caused by data leakage.

3. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, Step 2 specifically includes: Step 201, Core Principle of the Model: The discrete diffusion model generates the TCR sequence through a two-way process of "forward noise addition - backward noise reduction," with the specific logic as follows: Forward noise addition process: using the original true TCR sequence, denoted as... Using this as the initial input, biologically-compliant "mutation noise" is gradually introduced through a discrete Markov chain, causing the sequence to change over time. , Gradually deviating from the original state, it eventually transforms into a completely random amino acid sequence at time step T, denoted as... This process mimics the natural accumulation of mutations in TCRs in vivo; Reverse denoising process: Train a parameterized denoising network, with model parameters denoted as... , with random sequence Starting with the target pMHC information, the forward noise-adding process is gradually reversed to correct "noise mutations" in the sequence, ultimately recovering a biologically plausible and epitope-specific TCR sequence. ; Step 202, Key Mathematical Definitions: To clarify the computational logic of each step in the model, the following core mathematical formulas are defined to ensure that the process is quantifiable and reproducible; Forward transition probability: describes the time step Time series from Transform into The probability is represented by a class distribution, and the transition process is determined by the transition matrix. control: , in, for Dimensional matrix , representing 20 common amino acids, matrix elements Indicates time step amino acids Mutation into amino acids The probability of , and the sum of the elements in each row is 1; Marginal distribution: time step Time series Relative to the original sequence The conditional distribution is equal to the previous one. The cumulative product of the step transition matrices reflects the cumulative effect of progressively adding noise to the sequence: , , in, , Indicates from arrive The chain multiplication of the transition matrices, This indicates element-wise multiplication. Predicted by a denoising network, It is the original sequence The predicted distribution; Inverse denoising probability: derived based on Bayes' theorem, describing the probability from the current sequence Restore the previous time step sequence The probability needs to be combined with the original sequence distribution predicted by the denoising network: , in, The original sequence output by the denoising network The probability distribution, For the forward process generate and The joint probability.

4. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, Step 3: Two transition matrix strategies are used, including stochastic transition matrix and BLOSUM transition matrix. The stochastic transition matrix is ​​adapted to the model variant DTCR-R, and the BLOSUM transition matrix is ​​adapted to the core model DTCR. random transition matrix Matrix definition: Based on the assumption of uniform random mutation, and considering both the "unchanged" and "randomly mutated" states of amino acids, the formula is as follows: Where I is identity matrix for A matrix of all ones. For time steps The noise intensity parameter varies with Increasing monotonically, adopting The linear scheduling method results in a completely random sequence; Key features: It simulates the random mutation process of TCR sequences, generating high sequence diversity, but does not consider the evolutionary relationships between amino acids. It is suitable for basic diversity generation scenarios and can be used as a control strategy to verify the necessity of evolutionary constraints. BLOSUM transition matrix Matrix construction process: Based on the BLOSUM62 matrix, a transition matrix with evolutionary constraints is constructed in three steps; Rating Transformation: Perform a Softmax operation on each element of the BLOSUM62 matrix to convert the original evolutionary ratings into initial probabilities, using the following formula: , Double randomization: The Sinkhorn-Knopp algorithm is used to normalize the rows and columns of the initial probability matrix to ensure that the final matrix satisfies the double randomness property, that is, the sum of the elements in each row and each column is 1, which meets the probability distribution requirements; Intensity scheduling: An exponential scheduling method is used to ensure time steps The mutation probability is approximately 0.5, simulating the dynamic process of "low-intensity mutation accumulation" in natural evolution; Key features: Integrating amino acid evolutionary constraints makes the mutation process more consistent with the natural variation of TCRs in vivo, significantly improving the biological rationality of the generated sequences, which is the strategy adopted by the core model.

5. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, The core function of the denoising network in step 4 is based on the current noisy sequence. Predict the original TCR sequence using target pMHC information. The distribution of TCRs and key binding patterns with epitopes were captured. The specific construction scheme is as follows: Step 401: Select the basic model. The physics-inspired sliding Transformer model is selected as the basic architecture of the denoising network, which is highly compatible with the TCR generation task. Replacing the traditional data-driven attention mechanism with a physical-driven dynamic process can more accurately capture the interaction patterns between TCR and epitopes. It natively supports using MHC pseudo-sequences as input features and directly incorporates pMHC specificity constraints without requiring additional modification to the input structure, which meets the core requirement of "generating specific TCRs based on target pMHC". Step 402: Network structure adaptation and adjustment. In view of the special characteristics of the TCR sequence generation task, the PISTE model is modified as follows to optimize the sequence prediction accuracy. Feature encoder projection direction adjustment: The original PISTE model projects the TCR and epitope sequences onto the MHC pseudo-sequence backbone; this is changed to project the MHC pseudo-sequence and epitope sequences onto the TCR sequence, resulting in an output dimension of [missing dimension]. TCR-pMHC joint feature representation , The length of the TCR sequence. As a feature dimension, it strengthens the core position of TCR sequences; Multi-layer self-attention module: After the joint feature output, a multi-layer self-attention module is added to further capture the long-range dependencies within the TCR sequence and improve the overall consistency of the sequence; MLP prediction layer: Employs a two-layer fully connected network to map the features output by the self-attention module to... probability matrix The probability vector at each position corresponds to the class distribution of the amino acid at that position, i.e. The final output is used for subsequent sequence sampling; Step 403: During the training and inference process of the denoising network, pMHC is always used as the conditional input to ensure the epitope specificity of the generated sequence. Training phase: The pMHC sequence is compared with the noisy sequence. After splicing, input into the network, only for The corresponding features are updated with gradients. The pMHC sequence is used as a fixed condition feature and does not participate in gradient calculation to avoid the condition information being modified. Inference phase: Keep the pMHC sequence input unchanged, and only process the noisy sequence. Iterative denoising is performed to ensure that each denoising step revolves around the target pMHC, and the generated sequence is always specific to that pMHC.

6. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, Step 5 specifically includes: Step 501: Define the core objectives and input / output of the predictor; The additionally trained TCR-pMHC combined predictor is denoted as The core objective is to output a combination probability score based on the input TCR sequence and the target pMHC sequence, providing a reliable functional constraint signal for gradient-guided sampling. The specific definition is as follows: Input structure: The input format is a combination of "TCRβ chain CDR3 sequence + epitope sequence + MHC sequence". The sequence format and length requirements are the same as those in the preprocessing results in step 1. Output format: The single-channel probability value is output through the Sigmoid activation function, with a value range of [0,1]. The higher the score, the stronger the binding specificity. At the same time, the prediction confidence is output. The variance is calculated through 5 Dropout samplings. The smaller the variance, the higher the confidence, which is used to filter low reliability gradient signals. Step 502: Predictor network architecture design; Based on the basic architecture of the denoising network in step 4, The design of "shared feature encoder + dedicated prediction head" is adopted to ensure compatibility with the denoising network. The dedicated prediction head is structured as follows: it combines the output of the two fully connected network and the Sigmoid layer with the probability. At the same time, it calculates the prediction variance through Dropout sampling to evaluate the confidence level and ensure the reliability of the prediction results. Step 503: Predictor training data and loss function; Training data source: 10K TCR-pMHC binding pairs were extracted from the predictor-specific validation set divided in step 1. Positive samples are validated binding pairs, and negative samples are generated through "reference TCR negative sampling" to ensure a balanced distribution of positive and negative samples. Loss function design: A composite loss function of "cross-entropy loss + confidence-weighted loss" is adopted, as shown in the following formula: in, For the sample size, The true label is 0 / 1. To predict the binding probability, To predict variance, The confidence weighting coefficient can increase the loss on low-confidence samples, constrain its gradient calculation, make the predictor's error smaller on high-confidence samples, and suppress the interference of low-confidence samples. Step 504: Predictor training and performance verification; Training parameter settings: The optimizer used is AdamW, the batch size is 64, the number of training epochs is 50, and an early stopping strategy is adopted to avoid overfitting; Performance validation metrics: AUC, precision, recall and F1 score are used as core metrics. The requirement is that AUC ≥ 0.9 on independent test subsets to ensure that the accuracy of the predictor is sufficient to provide reliable gradient signals. Gradient validity verification: 100 real TCR-pMHC binding pairs were randomly selected, and single-amino acid perturbations were applied to the TCR sequences to verify the validity. The change in the output binding probability—the probability decrease caused by the perturbation in the antigen contact area must be significantly greater than that in the non-contact area to ensure that the gradient direction conforms to biological laws.

7. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, Step 6 is based on the core idea of ​​"guiding the generation process through discriminator gradients to balance the naturalness of the sequence with functional objectives," and will... The gradient signal is incorporated into the inverse denoising process of DTCR to achieve closed-loop optimization of "generation-evaluation-correction"; Step 601: The core logic and mathematical expression of gradient guidance; The core of gradient-guided denoising is: in each step of inverse denoising, by calculating... The output is the gradient of the hidden state of the denoising network, and the direction of the hidden state is adjusted to optimize the generated TCR sequence towards the direction of "higher binding probability". At the same time, the biological naturalness of the sequence is ensured by KL divergence constraint. Let the hidden state at step t in the reverse denoising process be... The target pMHC sequence is Then the gradient-guided objective function is defined as: , in: This is the initial hidden state for this denoising step. For based on TCR sequence predicted distribution, Let KL divergence be the KL divergence. The naturalness constraint coefficient ensures that the post-guided sequence still conforms to the natural distribution of TCR; The gradient-guided strength coefficient controls the priority of the combined optimization. Step 602: Gradient calculation and hidden state update process; Combining the Langevin dynamics sampling approach, gradient guidance is embedded in each step of the inverse denoising process. The specific workflow is as follows: Initial hidden state acquisition: The noisy sequence at step t. Input the denoising network encoder to obtain the initial hidden state. ; Gradient calculation: With target pMHC enter Calculated using automatic differentiation tools Output pair gradient ; Langevin gradient update: for conduct The next iteration update uses the following formula: Where k is the number of iterations. , Step size, Add a small Gaussian noise to the noise temperature setting. To avoid getting trapped in local optima; Post-update state verification: Calculate the hidden state after the update. Corresponding TCR sequence prediction distribution ; Step 603: The collaborative mechanism between gradient guidance and denoising; designing a progressive collaborative constraint strategy: Timing control: In the first 1 / 3 of the reverse denoising steps Only basic denoising is performed, prioritizing the restoration of the sequence's natural structure; in the subsequent 2 / 3 steps... Gradient guidance is gradually introduced, and It increases linearly as t decreases, thus achieving a progressive guidance of "ensuring naturalness first, then optimizing functionality"; Epitope conditions are fixed: throughout the gradient-guided process, the target pMHC The input features remain fixed to ensure that the guidance direction is always aimed at a specific table position, thus avoiding guidance deviation caused by distortion of table position information; Confidence filtering: If For the present The confidence level of the corresponding predicted sequence Below the threshold of 10, i.e. If the gradient guidance step is not performed, then only basic denoising is performed to avoid introducing erroneous guidance signals by low-confidence gradients.

8. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, Step 7 specifically includes: Step 701: Train the objective function, with the core training objective being to optimize the variational upper bound of the negative log-likelihood. The objective function formula is as follows: Core VLB loss The formula for measuring the consistency between the forward noise addition process and the backward noise reduction process is: in, Let KL divergence be the KL divergence. For the expectation, The prior distribution is a random sequence; Step 702, Training Iteration Process, including: Step 7021, Data Loading: Randomly sample a batch of TCR-pMHC pairs from the training set, denoted as... ; Step 7022, Time step sampling: From , A time step t is randomly selected within the range to generate the noisy sequence for the current batch; Step 7023, Forward Noise Addition: Based on the selected transition matrix, through... Generate noisy sequences ; Step 7024, Gradient Guidance and Network Prediction: ... Input the denoising network and obtain the hidden state. ;based on Output the original sequence Predicted distribution ; Step 7025, Loss Calculation and Parameter Update: Based on Calculate the loss value for the current batch and update the denoising network using the backpropagation algorithm; Step 7026, Convergence Judgment: Repeat steps 7021 to 7025 for 100 epochs. When the validation set... If there is no decrease for 10 consecutive epochs, stop training and save the current model parameters.

9. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, In step 8, based on the trained discrete diffusion model and gradient-guided strategy, epitope-specific TCR sequences are generated step by step from random sequences. The specific steps are as follows: Step 801, Initialize generation parameters: Determine the target pMHC information and fix the input model; Generate a random amino acid sequence of length L. The amino acids at each location were uniformly sampled from 20 common amino acids; Set the total number of diffusion steps. Current time step Gradient guidance strength coefficient Initial value: 0.05; Step 802, Basic Iterative Denoising: In the first 1 / 3 steps of reverse denoising Only basic denoising is performed, prioritizing the restoration of the sequence's natural structure; step : Set the current sequence The time step t and the target p are input to the MHC denoising network to obtain the hidden state. ; Sequence sampling: based on Corresponding prediction distribution A multinomial sampling strategy was used to obtain ; Parameter update: Let Return to the above steps and continue iterating until... ; Step 803: Gradient-guided iterative denoising: Gradient guidance is gradually introduced in the subsequent 2 / 3 steps, and It increases linearly as t decreases, thus achieving a progressive guidance of "ensuring naturalness first, then optimizing functionality"; step : Set the current sequence The initial hidden state is obtained by inputting the target pMHC denoising network at time step t and time step t. ; Gradient calculation and hidden state update: call ,enter and Calculate the gradient and perform Langevin update to obtain the guided hidden state. ; Sequence sampling: based on Corresponding prediction distribution A multinomial sampling strategy was used to obtain ; Parameter update: Let , Return to the above steps and continue iterating until... ; Step 804, Final Sequence Generation and Filtering: when At this point, the final denoising and sampling are completed, yielding the initially generated TCR sequence. ; Basic filtration: Discard sequences that lack cysteine ​​at the N-terminus or phenylalanine / tryptophan at the C-terminus; Specificity verification: passed Evaluate and The binding probability and retention probability of sequences ≥ 0.8 were used to obtain epitope-specific TCR sequences. .

10. The method for designing T-cell receptor sequences based on a discrete diffusion model according to claim 1, characterized in that, In step 9, a comprehensive validation scheme is designed from three core dimensions: specificity, biological rationality, and structural stability, to evaluate the quality of the generated TCR sequence and ensure that it meets the requirements for immunotherapy applications. Step 901: Specificity Validation. Five mainstream TCR-epitope binding prediction tools were used to verify the binding specificity of the generated sequences from different model perspectives: Evaluation method: Input the generated TCR sequence and target epitope into each prediction tool, and output the binding probability; Using real binding TCR sequences from the test set as positive controls and randomly generated non-binding TCR sequences as negative controls, ROC curves were plotted and AUC values ​​were calculated. Step 902: Biocompatibility Verification. Verify whether the generated sequence conforms to the biological characteristics of a real TCR, avoiding deviation from the natural immune lineage. Sequence homology verification: The generated sequences are compared with the reference library using the BLAST tool, and the bit-score is calculated. It is required that 90% of the generated sequences have a bit-score in the range of 28-33. Generation probability verification: Use the OLGA tool to calculate the natural occurrence probability of the generated sequence in vivo, requiring the probability to fall within the range of 1 / 2. interval; Distribution consistency verification: Calculate the Kullback-Leibler divergence between the generated sequence and the real TCR sequence in terms of bit-score and OLGA probability. The requirement that the KL divergence ≤ 0.1 indicates that the two have high distribution consistency. Step 903: Structural stability verification. The structural stability of the generated TCR-target pMHC complex is evaluated using structural prediction tools to verify the physical rationality of the binding. Combined with interface analysis: The TCRdock tool was used to predict the complex structure and calculate the change in solvent-accessible surface area ΔSASA of the CDR3 region before and after binding. The larger the ΔSASA value, the larger the binding interface and the stronger the specificity. The mean ΔSASA value should be higher than the average level of the real TCR. Binding affinity score: The binding interface score of the complex was calculated using the RosettaDock-5.0 tool. The smaller the score, the stronger the binding affinity. The average score should be lower than the average score of the real TCR to ensure better structural stability.