Abstract
This study addresses the challenge of DNA sequence similarity analysis by combining deep learning with DNABERT embeddings. Traditional alignment methods based on direct pairwise comparisons often fail to detect deeper biological relationships beyond nucleotide matching. However, DNABERT, a large transformer-based language model, captures contextual and functional patterns within genomic data. We initially used a dataset of 20 human DNA sequences and later expanded it to 70 sequences to enhance statistical reliability. The results showed that DNABERT recovered functional similarities even between sequences with low identity percentages, revealing previously overlooked structural relationships that were hidden by traditional alignments. Quantitative evaluation using precision, recall, and F1 score confirmed the robustness and consistency of the DNABERT-based approach. Overall, this study demonstrates that combining traditional and deep learning-based methods yields a more accurate and interpretable framework for DNA sequence alignment, thereby paving the way for enhanced genomic analysis.
1. Introduction
One of the most significant tasks in bioinformatics is DNA matching, a crucial tool for identifying regions of sequences that are similar. This similarity can be the same function or structure, or sequences may differ due to evolution. By matching different sequences, we can determine the patterns that comprise inversions, repeats, and rearrangements. These data are widely applied in biological fields, such as the exploration of gene mutations, the search for the evolutionary origin of species, and the revision of genome annotations. Accurate matching of nucleotide pairs is crucial for identifying similar sequences in genomic databases, a key step in genome assembly. However, poor sequence alignment accuracy can lead to biologically unreliable results. For example, inaccurate sequence alignment is a significant cause of misinformation in evolutionary biology [1]. Although traditional alignment tools, such as ClustalW, MUSCLE, and BLAST, are widely used and are renowned for their reliability and speed, they face challenges when dealing with large amounts of data or highly diverse genomic sequences. As biological data have become more complex, the need to develop more accurate alignment methods has become urgent.
In recent years, significant advances have been made in deep learning techniques, particularly in the field of natural language processing, resulting in the emergence of models capable of learning complex patterns from DNA sequence data. With this clear development, large language models (LLMs) based on transformers, such as BERT and its DNA-focused variants, have been developed and show impressive performance in capturing contextual representations of nucleotide sequences. By leveraging their ability to encode semantic and structural information from raw DNA inputs, these models offer a path to overcome the limitations of traditional alignment algorithms.
Recent developments have introduced several large language models (LLMs) with genomic applications, such as DNABERT-2, HyenaDNA, and the Nucleotide Transformer, which extend transformer architectures to longer genomic contexts. While this study focuses on DNABERT, future work will benchmark it against these emerging models.
This paper focuses on combining deep learning techniques and traditional methods, specifically DNABERT, to improve the efficiency and accuracy of DNA sequence alignment. The proposed methodology involves analyzing pairwise similarities by extracting embeddings using pretrained transformer models, performing traditional alignments for benchmarking, and trimming raw sequences to a uniform length. An evolutionary tree is also constructed to illustrate the phylogenetic relationships among the sequences.
2. Related Works
This section highlights past research in the field of deep learning for DNA sequence alignment, focusing on how traditional methods have evolved, the challenges they have encountered, and the role of modern artificial intelligence (AI) models in enhancing the efficiency and accuracy of alignments. Comparing these with the most contemporary models, we analyze their performance in relation to traditional methods.
- Deep learning: A type of AI that uses deep neural networks to mimic the human brain’s learning and analysis of data. It can identify patterns and features from complex data without human intervention. The key to deep learning is creating a hierarchy of feature representations across multiple layers of neural nodes, allowing it to learn more complex features as it progresses deeper.
- Transformers: These models utilize a self-attention mechanism to process sequential data in a soft manner, such as text and genetic sequences. They enable the system to view the full context in parallel. Hence, recurrent neural networks are much faster and more precise, and are the foundation of more advanced models, such as BERT, GPT, and DNABERT, which are often used in language processing as well as genome analysis [2,3].
- BERT: This model was designed to analyze DNA sequences, not text. Employing wide-ranging genomic data for training, it identifies biological patterns and genetic relationships [4].
- DNABERT: While BERT handles all human languages, DNABERT processes A, T, C, and G sequences and uses short, paired DNA sequences called k-mers, rather than words, as input and provides significantly improved comprehension of DNA, mirroring BERT’s deep understanding of text, finding meaningful recurring patterns in genetic sequences [5].
- DNABERT transformers model: A deep neural network that uses a self-attention mechanism to process genomic data efficiently [2,5].
- K-mer algorithm: This is a computational method in computational biology and bioinformatics for analyzing DNA or protein sequences by dividing the biological sequence into fragments.
2.1. Transformer Models for DNA Sequence Alignment and Similarity
The DNABERT-S model was developed to classify biological species through DNA sequences [6]. The model addresses the challenge of classifying species based on matching with known genomes, which is hindered by the lack of genetic references. Previous models struggled to extract DNA representations and required classified data, which are not readily available in medical and environmental contexts. The study utilizes species-aware representations to distinguish between species accurately. The model was trained using Manifold Instance Mixup (MI-Mix) and Curriculum Contrastive Learning (C2b). The DNABERT-S model performed better at classifying with few samples and at distinguishing species without relying on numerous genetic references [6]. Ozan developed deep learning models based on recurrent neural networks to understand the prolonged and short-range interactions between nucleotides within a DNA sequence, predicting the depth of the sequence [7]. The study also investigated methods for classifying DNA sequences and utilized data regularization algorithms, such as Brotli and Gzip, which provide resource-efficient alternatives to traditional machine learning techniques. K-mer counting techniques were employed to break down DNA sequences into smaller pieces, enabling the classification of genetic data with high accuracy. This approach focused on distinguishing between species and identifying patterns within them. Machine learning algorithms were used to classify genetic data, including those based on criteria such as spatial density and unique features [7].
Zhang et al. analyzed DNA using the K-mers method, which involves dividing long DNA sequences into fragments to facilitate the classification process [8]. This method effectively classified different species based on genetic sequences. The researchers developed a model based on compression algorithms (compressors), such as Gzip, Brotli, and LZMA, to classify DNA sequences. They used compression to determine the similarity between sequences. The accuracy was 96% using the Brotli algorithm. Deep learning models, such as DNAGPT, were utilized to develop a model that leverages prior learning to analyze sequences in multiple ways and integrate numerical data with DNA sequence data. The model demonstrated high performance in predicting critical genomic regions and generating synthetic gene sequences. It was highly effective in identifying genomic signals across various species, thereby facilitating the estimation of mRNA gene expression levels. However, the researchers faced challenges, including processing massive datasets and integrating multimodal data, such as genetic images with DNA sequences [3].
Transformer models, including DNABERT and GenSLM, were developed to classify gene sequences and genetic elements, such as promoters [4]. However, the alignment performance was limited due to the high computational cost of these models. Traditional methods, such as Smith–Waterman and BWA-MEM, accelerate the search and reduce costs, but struggle with processing large and complex datasets. AI and representation learning techniques were combined to create accurate representations of genetic sequences. Self-supervised learning techniques were used to reduce the gap between traditional and new models. DNA-ESA models share a common representation of genetic sequences and references, facilitating easier alignment [9].
Zhang et al. used high-throughput targeted sequencing to analyze DNA sequences and use them as digital storage [10]. Deep learning models were developed to predict the next-generation sequencing of DNA strands. A deep, directed neural network with repetitive units was employed to investigate the long-distance interactions between nucleotides in DNA. The researchers utilized the thermodynamic properties and partial hybridization syntheses to comprehend the impact of the DNA strands. The performance of the model was evaluated using three types of sequencing panels: one targeting human polymorphisms, another analyzing long non-coding RNA, and a third targeting synthetic sequences [10].
The applicability of transformer-based language models in nucleotide sequence analysis was reviewed in [11]. The researchers demonstrated that the similarity between nucleotide sequences and natural language enables the use of natural language processing techniques in bioinformatics. For example, the innovative adapter models presented included BERT-Promoter, miProBERT, DNABERT-2, and ViBE, covering a wide range of functions, including predicting promoters and enhancers, identifying methylation sites, classifying genome-wide reads, predicting cluster associations, and identifying translation start sites or genetic evolution. The paper also highlighted the challenges arising from the computational resource requirements of the transformer system, the difficulty in interpreting results, the need to customize models according to the genome type or chemical environment, and the necessity of incorporating additional data, such as physicochemical and sequencing results. The research also highlights the promising future of adapter models in sequence analysis [11].
SpeciesLM is a DNA language model based on transformers that are aware of species [7]. It is designed to examine regulatory elements and their evolution in various organisms. SpeciesLM differs from other models because it uses species identity during training to make embeddings that are specific to each organism. This method facilitates the identification of conserved regulatory elements and the prediction of variant effects, particularly in evolutionary comparative genomics. SpeciesLM also does better than regular transformer models at classifying species across species, which suggests that species-aware embedding helps to extract biological signals [12].
The Embed, Search, and Align (ESA) framework uses a reference-free DNA-embedding model to align short DNA sequences to a large genome [13]. The model outperformed six previous models, demonstrating alignment accuracy of over 99% on reads of up to 250 bases. The model could generalize across different types of genomes, making it a powerful tool for aligning DNA across multiple species [13].
2.2. Sequence Representation and Tokenization in Transformer Models
DNABERT-2 is a new model designed to address computational issues affecting older models, such as K-mer tokenization, which is slow to run due to fragmentation [11]. The model aims to reduce sequence length, improve efficiency, and prevent information leakage. It was trained on multiple types of genomes, including human genomes, and its computational architecture was enhanced by utilizing ALiBi for processing long sequences and FlashAttention for memory reduction. The model outperformed DNABERT in 23 out of 28 tests and excelled at processing long sequences despite being trained on short sequences [11].
Bawankar et al. used supervised learning algorithms to classify DNA sequences from various datasets, including human, dog, and chimpanzee data [9]. The random forest algorithm achieved an accuracy of 92.92% in classifying human DNA sequences. Combining neural networks with genetic algorithms, ant colonies, and progressive boosting further improved classification performance. Optimization strategies, such as grid search and hill climbing techniques, were employed to fine-tune the parameters. Techniques, including unary encoding and K-mer counting, were also used to convert genetic transcripts into digital representations, thereby enhancing feature extraction and classification accuracy [9].
The Nucleotide Transformer is a novel model trained on over 3200 human genomes across 850 species [14]. This model outperformed traditional supervised learning models, such as BPNet, demonstrating its high level of specificity. The model recognizes genetic elements, including coding and non-coding regions. The model’s performance was evaluated across 18 genomic tasks using cross-validation strategies. The study highlighted the importance of data diversity across different species. It demonstrated that these models can predict the effects of genetic mutations using pretrained representations, even in organisms lacking annotated data [14].
The Nucleotide Transformer is a system that uses one-dimensional convolution and self-warping to analyze and predict DNA sequences [14]. The system has been used to explore various types of interactions, including those involving E. coli and non-E. coli. sequences, human sequences, TATA sequences, and non-TATA sequences. This system has been used with deep learning algorithms, such as DeepSEA, Viraminer, and Bert-enhancer, on diverse datasets and relies on natural language processing techniques to analyze genetic data [14].
Another study investigated the impact of transformer models’ performance on DNA sequences using segmentation strategies [15]. While techniques such as byte-pair encoding are successfully used in natural language processing, they may not be suitable for genome analysis due to the different biological structures of DNA sequences. As an alternative, the study proposed the use of biologically aware codon-based encoding. This approach is a crucial factor in the performance of transformer models, facilitating the handling of sequence classification and gene function prediction tasks. Furthermore, smaller vocabulary sizes and better computational efficiency can be achieved with this approach. The study proposed the use of segmentation strategies that leverage the biological features of the genome to enhance the accuracy and efficiency of models for various genomic tasks [15].
2.3. Applications of Transformers in Genomic Function Prediction
Honig et al. addressed the challenge of predicting genes from genomic sequences because of the influence of distant elements, such as enhancers and repressors [16]. To overcome the limited ability of current models to handle long genomic sequences and long-range regulatory interactions, the researchers proposed a method for aligning genomic sequence codes using Genomic Tokenized Alignment (GTA) with large pretrained language models. The model was trained on lymphoblastoid cell data and tested on Geuvadis Consortium data. GTA outperformed previous models, such as the transformer and Basenji models, achieving a Spearman correlation of 0.65 [16].
Nguyen et al. used foundational models in genomics to analyze unlabeled DNA data [17]. Classification and prediction of gene functions were improved using deep learning. The analysis of prolonged DNA interactions was improved by overcoming the limitations of attention-based models (transformers). The researchers used HyenaDNA models, which rely on long-range convolutions instead of traditional attention, allowing for analysis of contexts of up to a million nucleotides. They used HyenaDNA because it outperforms other models, achieving up to 20% higher accuracy in some selections, such as gene enhancer classification. Compared to state-of-the-art models, such as the Nucleotide Transformer, HyenaDNA achieved remarkable performance with fewer parameters and less training data. The study paved the way for the development of HyenaDNA as a more efficient model for analyzing long-range DNA sequences [17].
Hamed et al. developed a new model for classifying DNA sequences using machine learning techniques and pattern-matching algorithms [18]. It compared the performance of different algorithms, including Support Vector Machine (SVM), Naive Bayes, decision trees, and random forests. The SVM linear algorithm achieved an accuracy of 0.963 and the best F1 score of 0.97, surpassing the Fuzzy Logic-based Prediction Model (FLPM) and Probabilistic Association Pattern Mining (PAPM) algorithms. The researchers recommended expanding the research to large datasets and experimenting with deep learning techniques [18].
Enformer is a deep learning model equipped with a transformer that can predict gene expression and chromatin orientations from raw DNA sequences [19]. Unlike previous models, Enformer integrates long-range genomic interactions up to 100 kb to improve prediction accuracy. The model was more effective than earlier models in predicting transcription start-site activity, histone modifications, transcription factor binding, and chromatin accessibility. Enformer outperformed traditional methods in accurately predicting novel phenomena, such as those related to cell-type-specific promoters, the effect of inactivation on gene expression, and mutational effects. To confirm the predictive ability and feasibility of the new method, CRISPR datasets and parallel reporter assays were utilized, revealing the model’s capacity to detect occasional non-coding variants and tissue-specific regulatory logic [19].
Another study used the Transformer–Mamba2 hybrid base to construct HybriDNA, a new DNA base model [20]. This model can perform genomics at single-nucleotide resolution across both short and long ranges. The transformer model uses precise positioning and Mamba2 to generate long-range sequences, enabling sequences up to 131,000 base pairs in length. Among the new features is a two-step core training method, including echo, designed for data generation. HybriDNA outperforms the DNABERT-2 base model, HyenaDNA, and the Nucleotide Transformer on 33 benchmarks across the GUE, BEND, and LRB datasets. The model operates on a range of 300 million to 7 billion base pairs and is characterized by training on a larger GPU [20].
Another study analyzed the power of transformer-based models in analyzing a wide range of genomic datasets [14]. These frameworks can detect DNA sequences, single-cell gene expression, and spatial transcription. The researchers focused on developing a framework that would work with all these datasets, utilizing a single transformer-based model, which would aid in regional classification, cell type identification, and gene expression prediction. The combination of biological concepts with deep learning methods led to significant improvements in the accuracy and effectiveness of various genomic models [14].
Adaptor models can be adapted to use genomic sequences, enhancing their ability to capture biological patterns [21]. Adaptor models can be used to analyze genomic functions, including promoter prediction, methylation detection, genomic read classification, protein binding site identification, and translation start-site detection. Challenges include high computational costs, poor model interpretation, species- and genus-specific models, and the need for multiple datasets containing DNA sequences [21].
However, most of these studies focused on classification or motif prediction tasks rather than direct sequence alignment. Therefore, this research bridges that gap by applying DNABERT embeddings for pairwise and contextual DNA sequence similarity analysis.
3. Proposed Framework for Deep Learning-Based DNA Sequence Similarity Analysis
A real-world dataset of human DNA sequences associated with blood genes was used. Two subsets supported both comparative and quantitative analyses.
- Set 1 (20 sequences): Used for the initial comparative evaluation between traditional pairwise alignment (Biopython’s globalxx) and DNABERT-based cosine similarity.
- Set 2 (70 sequences): Used for extended quantitative analysis to ensure statistical robustness and to validate the generalization ability of the DNABERT model.
All sequences were designed using FASTA and standardized at 300 bases to ensure consistency. This step was essential for maintaining compatibility with the alignment algorithms and deep learning models used.
Pairwise alignments were performed using the globalxx algorithm from Biopython, and similarity between DNABERT embeddings was measured using cosine similarity. Additional quantitative metrics, including mean, standard deviation, and correlation coefficients between traditional and deep learning methods, were calculated to assess the consistency of performance.
Figure 1 shows the proposed architectural structure followed in this study, which aims to align DNA using an LLM and compare the alignment using traditional methods and deep learning. It also clarifies each component in the system, including the inputs, processes, and outputs associated with it.
Figure 1.
Architecture of the proposed DNA similarity analysis pipeline.
3.1. Pipeline Overview
- DNA Sequences (FASTA format)
- Input: DNA sequences (FASTA format);
- Output: Data forwarded to both analysis pipelines (traditional and deep learning).
- Traditional Alignment Path
- (a)
- Pairwise Alignment (Biopython–globalxx)
- Input: Raw DNA sequences;
- Processing: Align sequences using the globalxx algorithm without gap penalties;
- Output: Aligned sequence pairs.
- (b)
- Identity Percentage Calculation
- Input: Aligned sequence pairs;
- Processing: Calculate the match ratio between nucleotides;
- Output: Identity percentage per pair.
- (c)
- Identity Matrix Construction
- Input: Identity percentages for all sequence pairs;
- Processing: Organize into a square matrix;
- Output: Identity percentage matrix.
- Deep Learning Path (LLM-based/DNABERT)
- (a)
- 6-mer Tokenization
- Input: Raw DNA sequences;
- Processing: Break each sequence into overlapping 6-mers;
- Output: Tokenized k-mer sequences.
- (b)
- LLM Embedding Extraction (DNABERT)
- Input: 6-mer tokens;
- Processing: Use the DNABERT model to extract high-dimensional embedding vectors;
- Output: Sequence embeddings.
- (c)
- Cosine Similarity Calculation
- Input: Embedding vectors;
- Processing: Compare each pair of vectors using cosine similarity;
- Output: Cosine similarity scores for each sequence pair.
- (d)
- Cosine Similarity Matrix Construction
- Input: All pairwise similarity scores;
- Processing: Organize into a square matrix;
- Output: Cosine similarity matrix.
- Comparative Analysis Block
- Input: Identity matrix + cosine similarity matrix;
- Processing: Compare patterns of both matrices; highlight mismatches and consistencies;
- Output: Analytical report on alignment vs. semantic similarity.
- Interpretation and Evaluation
- Input: Comparison results + matrices;
- Processing: Interpret functional relationships, structural similarity, and evolutionary signals;
- Output: Insights into sequence similarity behavior.
- Final Output Outputs include:
- Cosine similarity matrix;
- Identity percentage matrix;
- Phylogenetic tree (via neighbor-joining algorithm.)
To ensure the architectural design was implemented practically, each module described above was translated into a concrete step within the research methodology. The following section outlines the application of this system, including data preparation, algorithm selection, and matrix generation. These operational steps follow the same pathway shown in the architecture (Figure 1), ensuring consistency between the conceptual model and the experimental execution.
Pairwise alignments were then performed using the pairwise2 module, a traditional method from the Biopython library [22], using the globalxx algorithm. This process calculated the matching percentages between paired sequences by considering only matches, excluding gaps and mismatches. This served as a benchmark for measuring the accuracy of traditional alignments.
3.2. Identity Percentage Equation
After alignment, the similarity percentage between each pair was calculated by:
The percentage for each pair of sequences was printed in text reports.
To ensure the presence of conserved regions across all sequences, multiple sequence alignments were performed using ClustalW and saved as an .aln file. These sequences were used as the input for the analysis. Simultaneously, the sequences were partitioned into overlapping 6-mers using the DNABERT model, a pretrained LLM designed explicitly for genomic data and available on HuggingFace [23]. The hidden states, which were the model’s output, were then combined to obtain a consistent sequence size for each sequence. In the pairwise similarity assessment, this similarity was measured by calculating the cosine similarity matrix using PyTorch and scikit-learn (version 2.10.0+cpu) [24,25,26].
All stages of the methodology, including data preprocessing, traditional alignments, multiple sequence alignments, embedding extraction, and similarity computation, were successfully implemented.
Additionally, a quantitative evaluation step was designed to assess the reliability and consistency of the proposed framework using metrics such as precision, recall, and F1 score. The detailed results and analysis of this evaluation will be presented and discussed in the following sections.
3.3. Methodological Steps
Table 1 provides a concise summary of the main methodological steps used in the proposed framework.
Table 1.
Key methodological steps in DNA sequence similarity analysis.
4. Results
This section presents the results of the proposed framework, including traditional alignment, DNABERT-based similarity analysis, and quantitative evaluation of the model’s performance across two DNA subsets.
The comparative evaluation on the 20-sequence subset demonstrated that DNABERT achieved significantly higher similarity consistency than traditional pairwise alignment, maintaining high cosine similarity values even when identity percentages were low.
When the dataset was expanded to 70 sequences, the overall trend remained consistent. DNABERT preserved a stable cosine similarity average of approximately 99.4%, despite the increased diversity among the sequences.
Meanwhile, the traditional alignment results showed greater variability, with identity percentages displaying higher deviation as sequence diversity increased.
These results confirm that DNABERT generalizes effectively across larger genomic datasets, maintaining robustness and contextual accuracy where conventional alignment methods become less reliable.
As shown in Table 2, identity % is the traditional method and is calculated based on the number of identical nucleotides between two sequences. Cosine similarity is a modern method that relies on representing sequences as numerical points using a deep learning model, DNABERT, and then calculating the angle between these points to determine their similarity.
Table 2.
Statistical summary of identity and cosine similarity scores after dataset expansion.
The DNABERT model was used, and the sequence was divided into 6-mer segments. The cosine similarity was then calculated for each pair. Some comparisons between the traditional method and the DNABERT model showed high matching rates in traditional alignments between some pairs, but the matching was very weak. This demonstrates that the DNABERT model is not limited to direct comparisons but rather captures deep functional relationships between sequences, even if they are invisible in traditional alignments. This analysis is crucial for identifying sequences that may perform the same functions or participate in the same biological pathways, despite their apparent differences in nucleotide sequences. These results are consistent with the findings of the DNA-ESA study, which demonstrated that representations derived from transformer-based embedding experiments can accurately represent relationships between sequences in the presence of noise or genetic variation [9]. DNABERT-S, which uses deep learning to extract meaningful information that traditional matrices cannot comprehend, also supports our work [11].
In the next step, we demonstrate that species embeddings can classify organisms with sparsely labeled data, thereby enhancing the success of deep learning in extracting meaningful functions beyond precise matching and explicit references. In future steps, this work will be expanded to include practical biological validation using real data or live samples, in order to link the computationally discovered similarities to actual gene functions, enhancing the reliability of the model and confirming its accuracy in interpreting biological relationships. We compared our observations with those shown in HyenaDNA [17]. The high similarity of vectors despite low identity resulted from non-local patterns and distance mapping. This finding is consistent with our results, which indicate the effectiveness of deep models in handling long genomic contexts and identifying non-local relationships.
As shown in Figure 2, the Hamming distance identity matrix represents a collection of 20 human DNA sequences. The figure shows that similarity among samples is limited and appears as weak clustering, indicating that conventional identity-based methods capture only superficial nucleotide-level similarities and fail to reflect deeper functional or contextual relationships.
Figure 2.
Confusion matrix for human DNA sequences.
As shown in Figure 3, the cosine similarity matrix derived from the DNABERT model for the same set of 20 sequences demonstrates increased cluster density compared to Figure 2. This highlights the model’s ability to capture deeper similarities between sequences, even at low identity percentages, reflecting its understanding of contextual relationships among genes.
Figure 3.
Confusion matrix for chimpanzee DNA sequences.
As shown in Figure 4, the graph illustrates the correlation between identity percentage and cosine similarity for a set of 20 sequences. Some pairs exhibiting low identity (approximately 40–50%) demonstrate high cosine similarity (exceeding 98%), thereby affirming that DNABERT can identify functional similarities that conventional methods fail to recognize.
Figure 4.
Scatterplot of identity vs. cosine similarity for 20 DNA sequences.
As shown in Figure 5, the identity matrix for the augmented set of 70 DNA sequences reveals increasingly diverse and scattered similarity patterns across the samples. Only limited regions exhibit strong similarity, indicating that traditional identity-based methods capture mainly surface-level relationships and struggle to reflect deeper connections as the dataset size increases.
Figure 5.
Identity matrix (Hamming distance) for 70 DNA sequences.
Table 3 summarizes the characteristics of the DNA sequence datasets used in this study, highlighting the increase in the number of sequences from 20 to 70 for extended quantitative evaluation. This expansion supports the observed increase in pattern diversity and enhances the robustness of the analysis.
Table 3.
Summary of DNA sequence datasets used in this study.
As shown in Figure 6, the cosine similarity matrix for the same set of 70 sequences demonstrates consistent stability with high similarity despite sequence diversity. This affirms that DNABERT maintains reliable performance as data volume increases. The figure also reveals dense clusters of similarity, illustrating the model’s ability to capture contextual patterns across distant genomic regions.
Figure 6.
Cosine similarity matrix (DNABERT–6-mers) for 70 DNA sequences.
As shown in Figure 7, the graph indicates that the average cosine similarity persisted at a high level (99.4%) despite a decrease in identity percentages for certain pairs. This signifies that DNABERT possesses robust generalization abilities and effectively manages varied sequences, showcasing its capacity to discern functional relationships that are not evident through conventional methods.
Figure 7.
Scatter plot of identity vs. cosine similarity for 70 DNA sequences.
The extended dataset (70 sequences) reinforces the quantitative findings. While identity scores became more variable, cosine similarity maintained consistency, demonstrating DNABERT’s robustness and ability to detect contextual relationships even in larger and more diverse datasets.
Table 4 summarizes the datasets used for the quantitative analysis. The smaller set (20 sequences) was used for initial evaluation, while the expanded set (70 sequences) provided a more statistically reliable baseline.
Table 4.
Dataset overview.
Table 5 compares the traditional identity percentages and DNABERT-based cosine similarities. While the identity values vary widely across sequences, the cosine similarity remains consistently high, showing DNABERT’s ability to capture contextual similarities beyond direct base pair matches.
Table 5.
Average identity and cosine similarity scores.
Table 6 shows that although there is a positive correlation between the two methods, DNABERT identifies deeper contextual patterns not reflected in simple identity matching.
Table 6.
Correlation between traditional and deep learning methods.
To evaluate quantitative robustness, precision, recall, F1 score, and ROC-AUC metrics were computed based on the similarity classification between DNABERT predictions and traditional alignment results. High scores across both datasets indicated the model’s consistency and scalability.
Table 7 presents the classification metrics that evaluate the quantitative robustness of the DNABERT similarity predictions. The high scores across both datasets indicate strong consistency, scalability, and generalization.
Table 7.
Classification-based evaluation metrics.
5. Discussion
In this section, the results from both traditional and deep learning methods will be discussed and analyzed. The results confirmed that DNABERT maintained high cosine similarity scores even with low matching rates. This suggests that the model recognizes meaningful biological relationships that traditional algorithms overlook. Visualization of the cosine similarity matrices further supported this observation, revealing consistent clustering patterns among functionally related sequences.
Expanding the dataset from 20 to 70 DNA sequences provided stronger evidence of the model’s stability and generalizability. Despite the increased sequence diversity, DNABERT achieved consistent similarity distributions, maintaining an average cosine similarity of approximately 99.4%. This demonstrates its robustness in handling larger and more complex genomic datasets.
These results are consistent with recent research on large genomic language models [4,6,9], which has demonstrated their ability to capture long-range dependencies and contextual information. However, DNABERT’s reliance on fixed k-mer fragmentation may limit its flexibility for specific applications. Future improvements could explore adaptive k-mer strategies or hybrid architectures that combine DNABERT with models such as DNABERT-2, HyenaDNA, or Nucleotide Transformer.
In summary, combining deep learning-based models with traditional alignment techniques provides a more comprehensive framework for understanding the relationships between DNA sequences. This approach enhances interpretability, improves accuracy, and opens up new avenues for genomic analysis by linking computational results to biological function. Future work will focus on experimental validation and expanding the scope of analysis to include non-coding genomic regions associated with disease.
6. Conclusions
This study compared the performance of the deep learning-based DNABERT model with traditional alignment techniques on a DNA sequence comparison task, examining its ability to handle low-identity sequences. The results demonstrate that DNABERT, a nucleotide large language model (LLM), not only captures semantic relationships but also functional and contextual patterns that traditional alignment methods fail to detect in low-identity regions. This clearly demonstrates the valuable role of LLM-based semantic embeddings in genomic analysis. The research also showed that combining deep learning with traditional alignment methods resulted in a more accurate and comprehensive approach to DNA sequence analysis. A quantitative evaluation was performed, covering classification metrics such as precision, recall, and F1 score, and testing models for size and diversity.
Expanding the dataset from 20 to 70 sequences strengthened the statistical validity of the results. The findings demonstrated that DNABERT not only performed consistently on small datasets but also scaled effectively to larger ones, preserving accuracy and revealing functional relationships beyond sequence-level similarity. This confirms the potential of transformer-based models for genomic similarity analysis and future large-scale bioinformatics applications.
Author Contributions
S.A. and M.T.B.O. contributed equally. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Data are contained within this article.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Wong, K.M.; Suchard, M.A.; Huelsenbeck, J.P. Alignment uncertainty and genomic analysis. Science 2008, 319, 473–476. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is All You Need. In Advances in Neural Information Processing Systems; MIT Press: Cambridge, MA, USA, 2017; Volume 30. [Google Scholar]
- Lipton, Z.C.; Berkowitz, J.; Elkan, C. A Critical Review of Recurrent Neural Networks for Sequence Learning. arXiv 2015, arXiv:1506.00019. [Google Scholar] [CrossRef] [Scilit]
- Devlin, J.; Chang, M.-W.; Lee, K.; Toutanova, K. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the NAACL-HLT 2019, Minneapolis, MN, USA, 2–7 June 2019; pp. 4171–4186. [Google Scholar]
- Ji, Y.; Zhou, Z.; Liu, H.; Davuluri, R.V. DNABERT: Pre-trained Bidirectional Encoder Representations from Transformers Model for DNA-Language in Genome. Bioinformatics 2021, 37, 2112–2120. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Zhou, Z.; Wu, W.; Ho, H.; Wang, J.; Shi, L.; Davuluri, R.V.; Wang, Z.; Liu, H. DNABERT-S: Pioneering Species Differentiation with Species-Aware DNA Embeddings. Bioinformatics 2024, 41, i255–i264. [Google Scholar] [CrossRef] [Scilit]
- Ozan, Ş. DNA Sequence Classification with Compressors. arXiv 2024, arXiv:2401.14025. [Google Scholar] [CrossRef] [Scilit]
- Zhang, D.; Zhang, W.; Zhao, Y.; Zhang, J.; He, B.; Qin, C.; Yao, J. DNAGPT: A Generalized Pre-Trained Tool for Versatile DNA Sequence Analysis Tasks. arXiv 2023, arXiv:2307.05628. [Google Scholar] [CrossRef] [Scilit]
- Bawankar, B. Analysis of Machine Learning Approaches for DNA Sequencing and Classification. Commun. Appl. Nonlinear Anal. 2024, 31, 436–453. [Google Scholar] [CrossRef] [Scilit]
- Zhang, J.X.; Yordanov, B.; Gaunt, A.; Wang, M.X.; Dai, P.; Chen, Y.J.; Zhang, K.; Fang, J.Z.; Dalchau, N.; Li, J.; et al. A deep learning model for predicting next-generation sequencing depth from DNA sequence. Nat. Commun. 2021, 12, 4387. [Google Scholar] [CrossRef] [Scilit]
- Zhou, Z.; Ji, Y.; Li, W.; Dutta, P.; Davuluri, R.; Liu, H. DNABERT-2: Efficient Foundation Model and Benchmark For Multi-Species Genome. arXiv 2023, arXiv:2306.15006. [Google Scholar]
- Karollus, A.; Hingerl, J.; Gankin, D.; Grosshauser, M.; Klemon, K.; Gagneur, J. Species-aware DNA language models capture regulatory elements and their evolution. bioRxiv 2023. 2023.01.26.525670. [Google Scholar] [CrossRef] [Scilit]
- Holur, P.; Enevoldsen, K.C.; Rajesh, S.; Mboning, L.; Georgiou, T.; Bouchard, L.-S.; Pellegrini, M.; Roychowdhury, V. Embed-Search-Align: DNA Sequence Alignment Using Transformer Models. Bioinformatics 2025, 41, btaf041. [Google Scholar] [CrossRef] [Scilit]
- Dalla-Torre, H.; Gonzalez, L.; Mendoza-Revilla, J.; Carranza, N.P.; Grzywaczewski, A.H.; Oteri, F.; Dallago, C.; Trop, E.; de Almeida, B.P.; Sirelkhatim, H.; et al. The Nucleotide Transformer: Building and Evaluating Robust Foundation Models for Human Genomics. bioRxiv 2023. 01.11.523679. [Google Scholar] [CrossRef] [Scilit]
- Fallahpour, A.; Gureghian, V.; Filion, G.J.; Lindner, A.B.; Pandi, A. CodonTransformer: A Multispecies Codon Optimizer Using Context-Aware Neural Networks. Nat. Commun. 2025, 16, 3205. [Google Scholar] [CrossRef] [Scilit]
- Honig, E.; Zhan, H.; Wu, Y.N.; Zhang, Z.F. Long-range Gene Expression Prediction with Token Alignment of LLMs (GTA). arXiv 2024, arXiv:2410.01858. [Google Scholar]
- Nguyen, E.; Poli, M.; Faizi, M.; Thomas, A.W.; Sykes, C.B.; Wornow, M.; Patel, A.; Rabideau, C.; Massaroli, S.; Bengio, Y.; et al. HyenaDNA: Long-Range Genomic Sequence Modeling at Single Nucleotide Resolution. arXiv 2023, arXiv:2306.15794. [Google Scholar]
- Hamed, B.A.; Ibrahim, O.A.S.; Abd El-Hafeez, T. Optimizing Classification Efficiency with ML Techniques for Pattern Matching. J. Big Data 2023, 10, 124. [Google Scholar] [CrossRef] [Scilit]
- Kelley, D.R. Effective gene expression prediction from sequence by integrating long-range interactions. Nature Methods 2021, 18, 1196–1201. [Google Scholar] [CrossRef] [Scilit]
- Ma, M.; Liu, G.; Cao, C.; Deng, P.; Dao, T.; Gu, A.; Jin, P.; Yang, Z.; Xia, Y.; Luo, R.; et al. HybriDNA: A Hybrid Transformer-Mamba2 Model for Long-Range DNA Modeling. arXiv 2024, arXiv:2502.10807. [Google Scholar]
- Zhan, H.; Wu, Y.N.; Zhang, Z. Efficient and Scalable Fine-Tune of Language Models for Genome Understanding. arXiv 2024, arXiv:2402.08075. [Google Scholar] [CrossRef] [Scilit]
- Cock, P.J.; Antao, T.; Chang, J.T.; Chapman, B.A.; Cox, C.J.; Dalke, A.; Friedberg, I.; Hamelryck, T.; Kauff, F.; Wilczynski, B.; et al. Biopython: Freely available Python tools for computational molecular biology and bioinformatics. Bioinformatics 2009, 25, 1422–1423. [Google Scholar] [CrossRef] [Scilit]
- Wolf, T.; Debut, L.; Sanh, V.; Chaumond, J.; Delangue, C.; Moi, A.; Cistac, P.; Rault, T.; Louf, R.; Funtowicz, M.; et al. Transformers: State-of-the-Art Natural Language Processing. In Proceedings of the 2020 EMNLP: System Demonstrations, Online, 16–20 November 2020; pp. 38–45. [Google Scholar] [CrossRef] [Scilit]
- Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, G.; Chintala, S. PyTorch: An Imperative Style, High-Performance Deep Learning Library. In Advances in Neural Information Processing Systems 32 (NeurIPS 2019); ACM: New York, NY, USA, 2019. [Google Scholar]
- Pedregosa, F.; Varoquaux, G.; Gramfort, A.; Michel, V.; Thirion, B.; Grisel, O.; Blondel, M.; Müller, A.; Nothman, J.; Louppe, G.; et al. Scikit-Learn: Machine Learning in Python. J. Mach. Learn. Res. 2011, 12, 2825–2830. [Google Scholar]
- National Center for Biotechnology Information (NCBI). Nucleotide Database. 2025. Available online: https://www.ncbi.nlm.nih.gov/nuccore (accessed on 7 October 2025).
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. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).






