Skip to Content
MoleculesMolecules
  • Article
  • Open Access

4 December 2026

15 Pages

FlexMHC-Net: A Hybrid LSTM–Transformer Framework with Local Convolution for MHC-I Binding Prediction

,
,
,
,
,
and
1
Laboratory of Human Virology and Oncology, Shantou University Medical College, Shantou 515041, China
2
Joint Shantou International Eye Center, Shantou University and the Chinese University of Hong Kong, Shantou, 515041, China
3
Department of Electronic Engineering, College of Engineering, Shantou University, Shantou 515063, China
4
Department of Gynecologic Oncology, Cancer Hospital of Shantou University Medical College, Shantou 515031, China

Abstract

Predicting peptide binding to major histocompatibility complex class I (MHC-I) molecules is important for cancer vaccine design and immunotherapy. However, prediction across peptide lengths, particularly for longer peptides, remains challenging. We propose FlexMHC-Net, a deep learning framework integrating dynamic convolution, Transformer-based self-attention, and bidirectional long short-term memory (BiLSTM) modules to capture local features and contextual dependencies. On the Independent Test Set, FlexMHC-Net achieved an area under the receiver operating characteristic curve (AUC)of 0.978, accuracy of 0.931, and Matthews correlation coefficient (MCC) of 0.861. On the External Set, it achieved an AUC of 0.955, accuracy of 0.885, and MCC of 0.774. For 13-mer peptides, AUCs reached 0.910 and 0.793, respectively. Ablation experiments further supported the contributions of all three modules.

1. Introduction

The major histocompatibility complex (MHC) represents one of the most functionally significant genomic regions in vertebrates, encoding cell surface glycoproteins that are indispensable for T cell-mediated adaptive immunity [1]. These molecules mediate the presentation of endogenous or exogenous peptide epitopes to T-cell receptors (TCRs), thereby initiating immune recognition and subsequent activation. In humans, MHC-encoded products are designated as human leukocyte antigens (HLAs), which are distinguished by extraordinary allelic polymorphism and compact genomic organization. Based on distinct structural features and functional roles, HLA molecules are categorized into two principal classes: MHC class I (MHC-I) and MHC class II (MHC-II) [1]. MHC-II molecules are constitutively expressed on professional antigen-presenting cells and primarily present exogenous peptides to CD4+ helper T cells, whereas MHC-I molecules, composed of a polymorphic heavy α chain non-covalently associated with an invariant β2-microglobulin light chain, are ubiquitously expressed on all nucleated cells and present intracellular peptides, typically of cytosolic origin, to CD8+ cytotoxic T cells [2]. MHC-I molecules typically present peptides of 8–10 amino acids, although longer peptides can also bind within the peptide-binding groove by adopting bulged conformations. Peptide binding is stabilized by allele-specific anchor residues, and the conformation of the bound peptide can influence T-cell receptor (TCR) recognition [3,4]. Recent studies have shown the immunological relevance of longer peptides, especially in cancer neoantigen contexts. However, public peptide–MHC binding datasets are heavily biased toward canonical 9-mer peptides, limiting the representational power of computational models trained on such data [5]. Early experimental approaches, such as positional scanning combinatorial peptide libraries, were used to characterize MHC-I binding motifs and identify primary and secondary anchor residues [6].
With the advancement of bioinformatics methods, a number of models capable of handling peptides of varying lengths have been developed, achieving progress in both feature extraction and generalization performance. Notable examples include DeepAttentionPan [7], TransPHLA [8], and DeepMHCI [9]. DeepAttentionPan introduces a position-based attention mechanism based on convolutional neural networks, allowing the model to automatically learn the relative importance of different peptide positions, thus improving its interpretability and generalization across HLA alleles. TransPHLA is the first to incorporate a Transformer architecture into the pMHC-I prediction task, using self-attention to jointly encode the contextual relationships between peptide and HLA sequences, along with positional embeddings to address varying peptide lengths, significantly improving performance. Meanwhile, DeepMHCI leverages an anchor position-aware design to enhance feature modeling at critical binding sites. Recent studies have further explored MHC-I ligand prediction across different alleles and species using MixMHCpred3.0 [10], Transformer-based peptide–MHC-I binding prediction using TransBindpMHCI [11], and peptide–HLA binding prediction using heterogeneous Siamese neural networks in PHLA-SiNet [12].
Although existing methods have achieved progress in prediction accuracy, predicting non-9-mer peptides, especially those longer than 9 amino acids, remains challenging. This challenge is partly related to the imbalanced length distribution in existing datasets, which may limit the generalizability of current models across diverse binding scenarios [13]. To address these challenges, we introduce FlexMHC-Net, a deep learning framework combining multi-scale conditional convolution with parallel Transformer-based self-attention and BiLSTM branches. Peptide sequences are padded to a fixed length of 26 residues to standardize the input dimensions. Three parallel convolutional branches with kernel sizes of 1, 3, and 5 extract local sequence features at different scales, while the Transformer and BiLSTM branches capture global contextual information and dependencies among convolutional features, respectively. Their outputs are concatenated to form a unified feature representation for MHC-I binding classification. The model was evaluated using four-fold cross-validation on the Train Set, followed by independent testing and external validation. On the Independent Test Set, FlexMHC-Net achieved an AUC of 0.978, an accuracy of 0.931, and an MCC of 0.861. On the External Set, the corresponding values were 0.955, 0.885, and 0.774, respectively. For 13-mer peptides, the AUC reached 0.910 and 0.793 on the Independent Test Set and External Set, respectively. These results indicate that FlexMHC-Net provides a competitive approach for MHC-I binding prediction across different peptide lengths, including longer peptides relevant to cancer neoantigens and viral variants [14].

2. Results and Discussion

2.1. Comparison with Existing Methods

To further evaluate the predictive performance and generalization ability of FlexMHC-Net, comparative experiments were conducted with three existing methods, including DeepMHCI, TransPHLA, and DeepAttentionPan. The Test Set was used to evaluate the performance of each model on unseen samples that were not involved in model training. The models obtained through four-fold cross-validation were evaluated on the entire Independent Set, and the results are summarized in Figure 1.
Figure 1. Comparison of generalization performance between FlexMHC Net and three advanced algorithms in the Test Set.
As shown in Figure 1, FlexMHC-Net achieved the highest AUC of 0.978, outperforming DeepMHCI (0.974), TransPHLA (0.976), and DeepAttentionPan (0.959). In terms of MCC, FlexMHC-Net obtained 0.861, compared with 0.846, 0.852, and 0.795 for the three baseline models, respectively. Furthermore, its F1-score reached 0.931, exceeding DeepMHCI (0.923), TransPHLA (0.927), and DeepAttentionPan (0.898). These results indicate that FlexMHC-Net maintains favorable classification performance on independent samples, demonstrating its ability to generalize beyond the training data.
To further investigate the generalization ability of the proposed method under different data distributions, additional experiments were conducted on the External Set. Unlike the Independent Set, the External Set was collected from an independent data source and was not involved in the training process. The performance of the four models was evaluated using five metrics, including AUC, Accuracy, MCC, Recall, and F1-score. The results are presented in Table 1.
Table 1. Performance comparison of FlexMHC-Net and baseline models on the External Set.
As shown in Table 1, FlexMHC-Net achieved the highest AUC of 0.955, exceeding DeepMHCI, TransPHLA, and DeepAttentionPan by 0.011, 0.005, and 0.027, respectively. Its Accuracy and MCC also reached 0.885 and 0.774, respectively, outperforming all three baseline models. Regarding Recall, FlexMHC-Net achieved 0.833, slightly lower than TransPHLA (0.841), but higher than DeepMHCI (0.815) and DeepAttentionPan (0.799). In addition, FlexMHC-Net obtained the highest F1-score of 0.879, indicating a favorable balance between Precision and Recall.
Overall, the results on both the Independent Set and External Set demonstrate that FlexMHC-Net maintains competitive predictive performance on unseen samples from both the same and different data sources. In particular, its consistent performance in AUC, MCC, and F1-score supports the generalization ability of the proposed method for peptide–MHC-I binding prediction.

2.2. Comparison Across Peptide Lengths on Test Set

To further investigate the predictive performance of FlexMHC-Net for peptides of different lengths, comparative experiments were conducted on the Independent Set using DeepMHCI and TransPHLA as baseline methods. DeepAttentionPan was not included in this analysis because of its relatively poor performance on medium- and long-length peptides (11–14 residues). Peptides ranging from 8 to 14 amino acids were evaluated using four metrics: AUC, MCC, Recall, and F1-score. The results are presented in Figure 2.
Figure 2. Comparison of FlexMHC-Net, DeepMHCI, and TransPHLA across peptide lengths (8–14 residues) on the Independent Set using AUC, MCC, Recall, and F1-score.
Overall, the performance of all models decreased with increasing peptide length. However, FlexMHC-Net maintained relatively stable performance and generally outperformed the two baseline methods. It achieved the highest AUC across all peptide lengths, reaching 0.982 for 9-mer and 0.910 for 13-mer peptides. Its MCC also remained the highest, reaching 0.658 and 0.548 for 13-mer and 14-mer peptides, respectively. In addition, FlexMHC-Net achieved a Recall of 0.788 and an F1-score of 0.777 for 14-mer peptides, indicating its relatively stable performance on longer peptides. These results demonstrate the effectiveness of FlexMHC-Net across different peptide lengths, particularly for medium- and long-length peptides.

2.3. Comparison Across Peptide Lengths on External Set

To further evaluate the generalization ability of FlexMHC-Net under different data distributions, additional experiments were conducted on the External Set. Similar to the Independent Set, peptides were divided into seven groups according to their lengths, ranging from 8 to 14 amino acids. FlexMHC-Net was compared with DeepMHCI and TransPHLA using AUC, MCC, Recall, and F1-score. The results are shown in Figure 3.
Figure 3. Comparison of FlexMHC-Net, DeepMHCI, and TransPHLA across peptide lengths (8–14 residues) on the External Set using AUC, MCC, Recall, and F1-score.
As shown in Figure 3, all three models exhibited a clear decline in predictive performance as peptide length increased, with a more pronounced decrease than that observed on the Independent Set. Nevertheless, FlexMHC-Net maintained the highest AUC across all peptide lengths, achieving 0.974 and 0.960 for 8-mer and 9-mer peptides, respectively. For longer peptides, its AUC reached 0.866, 0.793, and 0.702 for 12-mer, 13-mer, and 14-mer peptides, respectively. In terms of MCC, FlexMHC-Net also achieved the highest values for 11-mer to 13-mer peptides, reaching 0.734, 0.586, and 0.444, respectively. However, for 14-mer peptides, its MCC decreased to 0.289, slightly below DeepMHCI (0.304).
For Recall, FlexMHC-Net showed performance comparable to the baseline methods for short peptides (8–10 residues), while maintaining relatively stable results for medium-length peptides. Its Recall reached 0.619 and 0.462 for 12-mer and 13-mer peptides, respectively, remaining comparable to DeepMHCI and higher than TransPHLA. Regarding F1-score, FlexMHC-Net achieved 0.854 and 0.736 for 11-mer and 12-mer peptides, respectively, outperforming both baseline methods. Its F1-scores for 13-mer and 14-mer peptides were 0.603 and 0.480, respectively. Overall, FlexMHC-Net maintained competitive performance across different peptide lengths on the External Set, although its advantages varied across evaluation metrics. These findings also highlight the remaining challenges in predicting long peptide–MHC-I binding under different data distributions.

2.4. Amino Acid Positional Preference and Sequence Motif Analysis

To examine the amino acid distribution patterns in the dataset, frequency distributions at different peptide positions were analyzed for all samples, binding peptides, and non-binding peptides. As shown in Figure 4, the overall amino acid distributions were relatively uniform, without clear position-specific preferences. In contrast, binding peptides exhibited distinct amino acid enrichment at the second position (P2) and the C-terminal position, which are important anchor sites for interactions with the MHC-I binding groove [15].
Figure 4. Heatmaps of amino acid frequency distributions at different peptide positions. The left, middle, and right panels represent all samples, binding peptides, and non-binding peptides, respectively.
Compared with binding peptides, non-binding peptides showed more uniform amino acid distributions across different positions, lacking obvious positional enrichment. The negative samples showed different amino acid frequency distributions from the positive samples, although these differences should be interpreted in the context of the negative-sample construction strategy. These results provide a descriptive comparison of amino acid distributions between binding and non-binding samples, rather than a direct interpretation of the features learned by FlexMHC-Net.
Furthermore, Seq2Logo analysis was performed on 12–14-mer peptides based on the predictions of FlexMHC-Net, as shown in Figure 5. The central region (P4–P10) exhibited relatively high amino acid diversity, suggesting weaker sequence constraints at these positions. This observation is consistent with the bulged conformation adopted by long peptides within the MHC binding groove [16]. In contrast, distinct amino acid preferences were observed near the terminal positions, particularly P12–P14, where hydrophobic residues such as leucine (L), phenylalanine (F), and valine (V) were enriched. Positional enrichment of charged residues, including lysine (K) and arginine (R), was also observed at certain positions.
Figure 5. Sequence motifs of 12–14-mer peptides.
Overall, these analyses demonstrate that FlexMHC-Net can capture position-specific amino acid preferences in conventional peptides and sequence motifs in long peptides. The identified patterns are consistent with known MHC-I binding characteristics, further supporting the effectiveness of the proposed model in characterizing peptide–MHC-I interactions.

2.5. Ablation Study

To evaluate the contributions of different components in FlexMHC-Net, three model variants were constructed by separately removing the dynamic convolution module, self-attention module, and BiLSTM module. Specifically, w/o Conv removes the dynamic convolution structure, w/o Self-Attn removes the self-attention module, and w/o BiLSTM removes the BiLSTM module. All model variants were retrained under the same experimental settings and evaluated using five metrics: AUC, Accuracy, MCC, F1-score, and Recall. The ablation results on the Test Set are presented in Table 2.
Table 2. Ablation study of FlexMHC-Net on the Test Set.
The full model achieved the best performance across all five metrics, with an AUC of 0.978, Accuracy of 0.931, MCC of 0.861, F1-score of 0.931, and Recall of 0.935. Removing the self-attention module resulted in a notable performance decrease, with AUC and MCC dropping to 0.974 and 0.851, respectively. Removing the BiLSTM module also reduced Recall from 0.935 to 0.922. These results suggest that the self-attention and BiLSTM modules provide complementary contributions to the overall classification performance. However, the current experiments do not directly establish their specific contributions to individual peptide lengths. The w/o Conv variant removes the entire dynamic convolution module. Therefore, this experiment evaluates the overall contribution of the module rather than independently isolating the effect of MHC-conditioned kernel generation.
Further evaluation on the External Set is presented in Table 3. The full model again achieved the highest performance across all five metrics, with an AUC of 0.955, Accuracy of 0.885, MCC of 0.774, F1-score of 0.879, and Recall of 0.833. Removing the self-attention module resulted in the largest performance decline, with AUC, MCC, and Recall decreasing to 0.942, 0.758, and 0.813, respectively. Although removing BiLSTM caused relatively smaller changes in overall performance, its Recall (0.814) remained lower than that of the full model (0.833), further demonstrating its contribution to binding peptide recognition.
Table 3. Ablation study of FlexMHC-Net on the External Set.
Overall, the ablation results suggest that the three components contribute to the predictive performance of FlexMHC-Net, although the magnitude of their contributions varies across evaluation metrics and datasets. The dynamic convolution module extracts local sequence features, self-attention captures global dependencies, and BiLSTM provides additional contextual information. Their combination enables the full model to achieve better predictive performance and generalization across different datasets.

2.6. Discussion

Despite the progress made in this study, some limitations remain. The datasets used in this work are dominated by 9-mer peptides, while longer peptides are relatively underrepresented. In addition, although the External Set provides an independent evaluation, it covers only five HLA-I alleles, some of which may also be present in the training set. Therefore, further validation is needed to assess the performance of FlexMHC-Net across a wider range of HLA alleles, particularly those not included in the training data.
Furthermore, the current sequence analysis provides only a preliminary understanding of the amino acid patterns associated with MHC-I binding and does not fully explain the features learned by the model. The individual contributions of different network components, particularly their roles in predicting longer peptides, also deserve further investigation. Future work will focus on expanding the datasets with more diverse HLA alleles and longer peptides, exploring additional model-based interpretation methods, and further investigating the interactions between peptide sequences and MHC-I molecules.

3. Materials and Methods

This study aims to develop a binary classification model to predict the binding status between a peptide sequence (denoted as P, with a length ranging from 8 to 14 amino acids) and an MHC-I molecule (denoted as M). To represent the sequence features of MHC-I molecules, the model adopts a 34-residue pseudo-sequence introduced in NetMHCpan-3.0 [17]. This pseudo-sequence is constructed by selecting key residues from the MHC-I protein sequence that are closely associated with peptide binding. It captures important structural features of the peptide-binding groove and has been successfully used in prediction models such as DeepMHCI and TransPHLA.

3.1. Datasets

The datasets used in this study were curated by Chu et al. [8] for TransPHLA, integrating pMHC-I binding data from several public resources, including IEDB, SYFPEITHI, EPIMHC, and MHCBN [18,19,20,21], together with HLA ligands identified by mass spectrometry. Positive samples represent peptide–MHC-I pairs with known binding ability, whereas negative samples were generated according to the original dataset construction protocols by randomly sampling peptide segments from proteins associated with IEDB immunopeptidomic data. For external evaluation, an additional dataset compiled by Mei et al. [22] for Anthem was included. This dataset consists of experimentally validated data collected independently of the TransPHLA datasets.
For model development and evaluation, the TransPHLA data comprise a Train Set and an Independent Test Set. The Train Set contains 718,332 samples, including 359,166 binders and 359,166 non-binders, covering 112 HLA-I alleles. It was used for model training and four-fold cross-validation. The Independent Set contains 171,438 samples, comprising 85,876 binders and 85,562 non-binders, and covers the same 112 HLA-I alleles. It was reserved exclusively for independent testing and was not involved in model training or cross-validation. To further evaluate the generalization capability of the proposed method, the External Set was also included. It contains 103,865 samples, including 51,984 binders and 51,881 non-binders, covering five HLA-I alleles, namely HLA-B08:01, HLA-B18:01, HLA-A02:01, HLA-A01:01, and HLA-A*24:02. Compared with the Train Set and Independent Set, the External Set differs in data source, allele composition, and peptide-length distribution. It was therefore used to assess model performance on independently collected data with a different distribution. However, this evaluation does not constitute an unseen-allele benchmark, as these five alleles may also be present in the training data.
All three datasets contain peptides ranging from 8 to 14 amino acids. The peptide-length distributions are presented in Table 4. The Train Set is dominated by 9-mer peptides, with 480,312 samples, whereas 13-mer and 14-mer peptides account for only 11,094 and 6228 samples, respectively. A similar distribution is observed in the Independent Set. In contrast, the External Set contains a higher proportion of 8-mer peptides, with 32,231 samples, compared with 46,331 9-mer peptides. Although the three datasets have approximately equal numbers of binders and non-binders, their peptide-length distributions differ considerably.
Table 4. Peptide-length distributions in the three datasets.

3.2. Overview of Our FlexMHC-Net Model

This study proposes FlexMHC-Net, a deep learning model designed to predict the binding status between MHC-I molecules and peptides of varying lengths. As illustrated in Figure 6, the overall architecture consists of five core modules: (i) Independent encoders are employed to separately process the peptide and the MHC-I pseudo-sequence, thereby preserving the heterogeneity of their respective feature spaces. (ii) Interaction-specific convolutional kernels dynamically generated based on the MHC sequence are introduced to model allele-dependent peptide–MHC interactions. (iii) A dual-branch structure is designed, where the BiLSTM branch models dependencies among convolutional features, while the Transformer branch captures global interactions across distant sequence regions. (iv) The features extracted from the BiLSTM and self-attention branches are concatenated and then fed into a multilayer perceptron (MLP) for binary classification. (v) Finally, the model outputs a binding probability between the peptide and the MHC-I molecule. FlexMHC-Net combines local interaction modeling with contextual feature extraction for peptide–MHC-I binding prediction.
Figure 6. The overall architecture of FlexMHC-Net. The model consists of input encoding, a transformer-based encoder, convolutional kernel generation via tensor dot products, and a Bi-LSTM decoder followed by dense layers for binding prediction.

3.3. Label Encoding and Embedding

To enable the model to effectively process amino acid sequences, FlexMHC-Net first encodes the peptide sequence and MHC-I sequence. The original amino acid sequences are represented as sequences of characters. Denote the peptide sequence as p = ( p 1 , … , p L p ) , and the MHC-I sequence as h = h 1 , … , h L h , where pi and hi represent amino acid residues. To unify the input dimension, sequence p is padded to a fixed length L p max (padding symbol is ‘_’). Then, using a predefined vocabulary, each character in the sequence is mapped to an integer index and further embedded into a continuous vector space through an embedding layer, resulting in the representation e ( p ) ∈ R L p max × d and e ( h ) ∈ R L h × d , where d = 16 is the embedding dimension. In addition, to preserve the positional information of each token in the sequence, we incorporate sinusoidal positional encodings. The positional encoding for dimension d is defined as
P E t , 2 i = sin t 1000 0 2 i / d P E t , 2 i + 1 = cos t 1000 0 2 i / d
The final sequence output is obtained by summing the word embeddings and their corresponding positional encodings, followed by a layer normalization,
z ( p ) = LayerNorm e ( p ) + PE z ( h ) = LayerNorm e ( h ) + PE
Although the original peptide lengths range from 8 to 14 amino acids, the peptide sequences are padded to a fixed length of 26 to maintain consistent input dimensions for the subsequent convolutional and classification layers. The MHC-I pseudo-sequences contain 34 residues and are encoded separately.

3.4. Encoder

FlexMHC-Net employs a Transformer Encoder architecture to model sequence data, aiming to fully capture the dependencies between amino acid residues in the peptide and MHC-I sequences. This module takes the embedded sequence representations as input and applies a multi-head self-attention mechanism followed by feed-forward neural networks for feature extraction and information integration. The input matrix is denoted as X = x 1 , … , x T ∈ R T × d , where T is the sequence length and d is the embedding dimension. To capture interactions among different positions, the encoder incorporates multi-head self-attention. FlexMHC-Net sets the number of attention heads to 2. For input features X, the query Q, key K, and value V matrices are constructed as
Q = X W Q , K = X W K , V = X W V W Q , W K , W V ∈ R d × n h d head
Each attention head computes the scaled dot-product attention as
Attention ( Q , K , V ) = Softmax QK ⊤ 2 d V
where dhead = 2d, and outputs from all attention heads are concatenated, followed by a residual connection and layer normalization
Z = LayerNorm ( MultiHead ( Q , K , V ) + X )
Then a position-wise feed-forward network is independently applied to each position, which is formulated as follows:
FFN ( x ) = W 2 ⋅ GELU W 1 x + b 1 + b 2
where GELU is the Gaussian Error Linear Unit activation function. The output is again given by
H = FFN ( Z )
During attention computation, padding masks are applied to filter out the influence of invalid padding positions, ensuring the model focuses on valid amino acid residues. FlexMHC-Net employs only one Transformer encoder layer to maintain model expressiveness while minimizing parameter size and overfitting. The outputs of the peptide_encoder and MHC_encoder are denoted as h ( p ) ∈ R L p max × d and h ( h ) ∈ R L h max × d , respectively.

3.5. Generate Convolution Kernels and Convolution

To further model the local interactions between MHC-I molecules and peptide sequences, FlexMHC-Net introduces a conditional convolutional kernel mechanism based on MHC. Unlike standard convolution operations that share kernels across all samples, this structure dynamically generates convolution kernels from the MHC-I sequence for each sample, enabling the model to extract local features from peptides in a context-aware manner that reflects the specific MHC environment. A learnable kernel weight tensor W ∈ R C × k × L m is frst defned, where C is the number of output channels, k is the kernel size, and Lm is the length of the MHC representation. The conditional convolutional kernel W ~ ∈ R C × k × d is then generated by projecting the MHC representation M through a tensor contraction and activation,
W ~ = ReLU tensordot M , W , dim = ( 1 , 2 )
where W ~ acts as a sample-specific convolutional kernel for the peptide. Next, the peptide representation h(p) is convolved with W ~ using a sliding window operation, extracting local features from each window position,
O i = ∑ j = 0 k − 1 ∑ d ′ = 1 d W ~ j , d ′ ⋅ h i + j , d ′ ( p ) + b
where O i ∈ R C denotes the convolution output at window position i, and b ∈ R C is a bias term. After performing this operation for all positions, the results are aggregated into a tensor O ∈ R L o × C , where Lo is the number of windows. The tensor is then reshaped to a 3D tensor with the last dimension as channels, enabling sequential processing. To capture local features at multiple resolutions, FlexMHC-Net builds three parallel convolutional modules with kernel sizes of 1, 3, and 5, respectively. This design allows the model to balance between coarse- and fine-grained pattern recognition and helps regularize learning by varying receptive fields. The three convolutional modules output 128, 64, and 32 channels, respectively, followed by ReLU activation and Batch Normalization. Their outputs are aligned and concatenated to obtain a unified feature representation with 224 channels. The subsequent BiLSTM and self-attention branches produce a concatenated feature representation of size 224 × 44, which is flattened into a 9856-dimensional vector for classification. The outputs from the three convolution branches are concatenated along the channel dimension and then fused to form a unified local feature representation as F conv ∈ R L × ( 128 , 64 , 32 ) .

3.6. Decoder and Bi-LSTM

To further capture the contextual dependencies of MHC-I and peptide sequences at different levels of abstraction, FlexMHC-Net introduces a hybrid decoder structure based on a bidirectional LSTM (Bi-LSTM) and a self-attention module. This module jointly models the intra-sequence dependencies and the interactions between MHC and peptide features. To extract local contextual dependencies from the convolutional feature map F conv ∈ R L × d c , where L = 224 denotes the number of concatenated convolutional feature channels, and dc = 22 denotes the feature dimension. We first apply a single-layer Bi-LSTM to produce
H LSTM = BiLSTM F conv ∈ R L × 88
To reduce dimensionality and enhance non-linear expressiveness, we project the LSTM output into a lower-dimensional space via a two-layer feedforward network with GELU [23] activation:
H prj = W 2 ⋅ GELU W 1 ⋅ H LSTM + b 1 + b 2 ∈ R L × 22
This projection module allows the network to effectively fuse local structural patterns with global sequence context, improving its ability to model the binding preferences between MHC-I and peptides. To capture higher-level global contextual and cross-modal interactions, we incorporate a Transformer-based decoder. Among its subcomponents are a multi-head self-attention layer and a feedforward sublayer. The decoder takes as input the output of the convolutional encoder Z ∈ R L × d c , and processes it as
Z ′ = LayerNorm Z + MultiHeadAttn Z , Z , Z Z out = LayerNorm Z ′ + FFN Z ′
The final decoder output is denoted by H dec ∈ R L × d c , representing the global contextual embedding of the sequence. We then concatenate Hproj from the Bi-LSTM path with Hdec from the self-attention module to form the final fused feature,
H fusion = Concat H proj , H dec ∈ R L × 44
This fusion representation Hfusionn combines local context with global sequence-level dependencies, further enhancing the model’s capability to capture MHC-I binding dynamics and structural preferences.

3.7. Classification Output

After obtaining the fused feature representation H fusion ∈ R L × 44 , FlexMHC-Net flattens it into a one-dimensional vector z ∈ R 44 L for downstream classification. To enhance model expressiveness and mitigate overfitting, the classification head adopts a three-layer feedforward neural network as a projection head, structured as
h 1 = Dropout ReLU W z z + b 1 ∈ R 256 h 1 ′ = BatchNorm h 1 h 2 = Dropout ReLU W 1 h 1 ′ + b 2 ∈ R 64 o = W 3 h 2 + b 3 ∈ R 2
The final model output o ∈ R 2 corresponds to the logits for the binder and non-binder classes. The logits are converted into class probabilities using the softmax function
y c = exp ( o c ) ∑ j ∈ { 0 , 1 } exp ( o j ) , c ∈ { 0 , 1 }
where y1 and y0 represent the predicted probabilities of the binder and non-binder classes, respectively. The final classification label is determined by selecting the class with the highest predicted probability
c ^ = argmax c ∈ { 0 , 1 } y c
Accordingly, the model performs binary classification directly based on the predicted class probabilities.

3.8. Evaluation Metrics

To comprehensively assess the predictive performance of FlexMHC-Net, we use five commonly used evaluation metrics in binary classification tasks: area under the receiver operating characteristic curve (AUC), accuracy (ACC), Matthews correlation coefficient (MCC), F1-score, and recall. These metrics assess discrimination, overall classification performance, and the identification of binding samples.

3.9. Experimental Settings

Four-fold cross-validation was performed on the Train Set. In each fold, three subsets were used for training and the remaining subset for validation. FlexMHC-Net was implemented in PyTorch 2.1.0 [24] and trained using the Adam optimizer [25] with cross-entropy loss, a learning rate of 0.001, a batch size of 1024, and 50 epochs. The dropout rate was set to 0.4. The checkpoint with the highest arithmetic mean of validation AUC, ACC, MCC, and F1-score was selected for subsequent evaluation on the Independent Set and External Set. DeepAttentionPan, TransPHLA, and DeepMHCI were trained and evaluated using the same data partitioning and evaluation protocol. For all four models, binary predictions were obtained using the argmax of the two-class output probabilities. The selected model from each fold was independently evaluated on the Independent Test Set and External Set. The final performance was reported as the mean and standard deviation across the four fold-specific models.

4. Conclusions

In this study, we proposed FlexMHC-Net, a hybrid deep learning framework for MHC-I peptide binding prediction. By integrating dynamic convolution, Transformer-based self-attention, and BiLSTM modules, the model captures local sequence features and contextual dependencies for peptides of different lengths.
Experimental results demonstrate that FlexMHC-Net achieves an AUC of 0.978, an accuracy of 0.931, and an MCC of 0.861 on the Independent Test Set. On the External Set, it achieves an AUC of 0.955, an accuracy of 0.885, and an MCC of 0.774. For 13-mer peptides, the model achieves AUC values of 0.910 and 0.793 on the Independent Test Set and External Set, respectively. These results indicate its competitive performance, particularly in predicting medium- and long-length peptides.
Ablation experiments demonstrate that the convolutional, self-attention, and BiLSTM modules contribute to the overall performance of the model. However, the improvements vary across evaluation metrics and peptide lengths. In particular, further investigation is needed to clarify the contribution of BiLSTM to long-peptide prediction. Despite these results, the performance on longer peptides remains challenging, especially under different data distributions. Further validation using larger independent datasets, unseen HLA alleles, and additional experimental data is needed to evaluate the generalization capability of the proposed method.

Author Contributions

Methodology, P.W. and Y.L.; validation, Q.Q., Y.S. and G.Z.; investigation, P.W. and Y.L.; data curation, Y.L.; writing—original draft preparation, P.W., Y.L. and J.C.; writing—review and editing, C.W., Q.Q., Y.S. and G.Z.; visualization, C.W.; supervision, Q.Q.; funding acquisition, C.W. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported by the Guangdong Basic and Applied Basic Research Foundation (No. 2022A1515011720), Shantou Municipal Science and Technology Bureau (No. STKJ2024065) and National Natural Science Foundation of China (No. 32570197).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.

Acknowledgments

During the preparation of this manuscript/study, the author(s) used GPT-6.1 Sol for the purposes of language polishing. The authors have reviewed and edited the output and take full responsibility for the content of this publication.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Neefjes, J.; Jongsma, M.L.M.; Paul, P.; Bakke, O. Towards a systems understanding of MHC class I and MHC class II antigen presentation. Nat. Rev. Immunol. 2011, 11, 823–836. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  2. Germain, R.N. MHC-dependent antigen processing and peptide presentation: Providing ligands for T lymphocyte activation. Cell 1994, 76, 287–299. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  3. Wieczorek, M.; Abualrous, E.T.; Sticht, J.; Álvaro-Benito, M.; Stolzenberg, S.; Noé, F.; Freund, C. Major Histocompatibility Complex (MHC) Class I and MHC Class II Proteins: Conformational Plasticity in Antigen Presentation. Front. Immunol. 2017, 8, 292. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  4. E Tynan, F.; Burrows, S.R.; Buckle, A.M.; Clements, C.S.; A Borg, N.; Miles, J.J.; Beddoe, T.; Whisstock, J.C.; Wilce, M.C.; Silins, S.L.; et al. T cell receptor recognition of a ‘super-bulged’ major histocompatibility complex class I–bound peptide. Nat. Immunol. 2005, 6, 1114–1122. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  5. Mei, S.; Li, F.; Leier, A.; Marquez-Lago, T.T.; Giam, K.; Croft, N.P.; Akutsu, T.; Smith, A.I.; Li, J.; Rossjohn, J.; et al. A comprehensive review and performance evaluation of bioinformatics tools for HLA class I peptide-binding prediction. Brief. Bioinform. 2020, 21, 1119–1135. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. Sidney, J.; Assarsson, E.; Moore, C.; Ngo, S.; Pinilla, C.; Sette, A.; Peters, B. Quantitative peptide binding motifs for 19 human and mouse MHC class I molecules derived using positional scanning combinatorial peptide libraries. Immunome Res. 2008, 4, 2. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  7. Jin, J.; Liu, Z.; Nasiri, A.; Cui, Y.; Louis, S.; Zhang, A.; Zhao, Y.; Hu, J. Deep learning pan-specific model for interpretable MHC-I peptide binding prediction with improved attention mechanism. Proteins Struct. Funct. Bioinform. 2021, 89, 866–883. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  8. Chu, Y.; Zhang, Y.; Wang, Q.; Zhang, L.; Wang, X.; Wang, Y.; Salahub, D.R.; Xu, Q.; Wang, J.; Jiang, X.; et al. A transformer-based model to predict peptide–HLA class I binding and optimize mutated peptides for vaccine design. Nat. Mach. Intell. 2022, 4, 300–311. [Google Scholar] [CrossRef] [Scilit]
  9. Qu, W.; You, R.; Mamitsuka, H.; Zhu, S. DeepMHCI: An anchor position-aware deep interaction model for accurate MHC-I peptide binding affinity prediction. Bioinformatics 2023, 39. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  10. Tadros, D.M.; Racle, J.; Gfeller, D. Predicting MHC-I ligands across alleles and species: How far can we go? Genome Med. 2025, 17, 25. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  11. Xu, H.; Ni, Y.; Chai, Z.; Cui, X.; Lei, X.; Liu, L.; Shan, J.; Qian, C. TransBindpMHCI: A transformer-based model for pan-specific MHC-I peptide binding prediction. BMC Bioinform. 2026, 27, 117. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  12. Nazarloo, M.; Saadat, M.; Zare-Mirakabad, F. PHLA-SiNet: A novel peptide-HLA binding prediction model using heterogeneous Siamese neural networks. Comput. Biol. Med. 2025, 197, 111017. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  13. Andreatta, M.; Nielsen, M. Gapped sequence alignment using artificial neural networks: Application to the MHC class I system. Bioinformatics 2015, 32, 511–517. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  14. Purcell, A.W.; McCluskey, J.; Rossjohn, J. More than one reason to rethink the use of peptides in vaccine design. Nat. Rev. Drug Discov. 2007, 6, 404–414. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  15. Falk, K.; Rötzschke, O.; Stevanovié, S.; Jung, G.; Rammensee, H.-G. Allele-specific motifs revealed by sequencing of self-peptides eluted from MHC molecules. Nature 1991, 351, 290–296. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  16. Tynan, F.E.; Elhassen, D.; Purcell, A.W.; Burrows, J.M.; Borg, N.A.; Miles, J.J.; Williamson, N.A.; Green, K.J.; Tellam, J.; Kjer-Nielsen, L.; et al. The immunogenicity of a viral cytotoxic T cell epitope is controlled by its MHC-bound conformation. J. Exp. Med. 2005, 202, 1249–1260. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  17. Nielsen, M.; Andreatta, M. NetMHCpan-3.0; improved prediction of binding to MHC class I molecules integrating information from multiple receptor and peptide length datasets. Genome Med. 2016, 8, 33. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  18. Dhanda, S.K.; Mahajan, S.; Paul, S.; Yan, Z.; Kim, H.; Jespersen, M.C.; Jurtz, V.; Andreatta, M.; A Greenbaum, J.; Marcatili, P.; et al. IEDB-AR: Immune epitope database—Analysis resource in 2019. Nucleic Acids Res. 2019, 47, W502–W506. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  19. Rammensee, H.-G.; Bachmann, J.; Emmerich, N.P.N.; Bachor, O.A.; Stevanović, S. SYFPEITHI: Database for MHC ligands and peptide motifs. Immunogenetics 1999, 50, 213–219. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  20. Reche, P.A.; Zhang, H.; Glutting, J.-P.; Reinherz, E.L. EPIMHC: A curated database of MHC-binding peptides for customized computational vaccinology. Bioinformatics 2005, 21, 2140–2141. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  21. Lata, S.; Bhasin, M.; Raghava, G.P. MHCBN 4.0: A database of MHC/TAP binding peptides and T-cell epitopes. BMC Res. Notes 2009, 2, 61. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  22. Mei, S.; Li, F.; Xiang, D.; Ayala, R.; Faridi, P.; I Webb, G.; Illing, P.T.; Rossjohn, J.; Akutsu, T.; Croft, N.P.; et al. Anthem: A user customised tool for fast and accurate prediction of binding between peptides and HLA class I molecules. Brief. Bioinform. 2021, 22, bbaa415. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  23. Hendrycks, D.; Gimpel, K. Gaussian Error Linear Units (GELUs). arXiv 2016, arXiv:1606.08415. [Google Scholar]
  24. Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, T.; Killeen, T.; Lin, Z.; Gimelshein, N.; Antiga, T.; et al. PyTorch: An imperative style, high-performance deep learning library. Neural Inf. Process. Syst. 2019, 32, 8024–8035. [Google Scholar] [CrossRef] [Scilit]
  25. Kingma, D.P.; Ba, J. Adam: A method for stochastic optimization. In Proceedings of the 3rd International Conference on Learning Representations (ICLR), San Diego, CA, USA, 7–9 May 2015. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Article metric data becomes available approximately 24 hours after publication online.