Sequence alignment is a memory bound computation whose performance in modern systems is limited by the memory bandwidth bottleneck. Processing-in-memory (PIM) architectures alleviate this bottleneck by providing the memory with computing competencies. We propose Alignment-in-Memory (AIM), a framework for high-throughput sequence alignment using PIM, and evaluate it on UPMEM, the first publicly available general-purpose programmable PIM system.Our evaluation shows that a real PIM system can substantially outperform server-grade multi-threaded CPU systems running at full-scale when performing sequence alignment for a variety of algorithms, read lengths, and edit distance thresholds. We hope that our findings inspire more work on creating and accelerating bioinformatics algorithms for such real PIM systems.https://github.com/safaad/aim.Our code is available at  This step is formulated as an approximate string matching (ASM) problem . It is mathematically proven that subquadratic alignment algorithm cannot exist   and Smitot exist . Recent ot exist ,c, 2022.exact sequence alignment using existing hardware devices, such as SIMD-capable multi-core CPUs, GPUs, and FPGAs, or using to-be-manufactured devices, such as application-specific integrated circuits. One of the most recent alignment algorithms, the wavefront algorithm (WFA) (The first direction accelerates hm (WFA) ,b, indeehm (WFA) ,b, 2022,hm (WFA) , and FPGhm (WFA) . Parasaihm (WFA) , BWA-MEMhm (WFA) , and mm2hm (WFA)  all explhm (WFA)  providesThe second direction includes limiting the functionality of sequence alignment to performing only edit distance calculation, as in Edlib , or limiearly and quickly detect any two dissimilar genomic sequences, which differ by more than a user-defined edit distance threshold, and exclude them from being aligned as their alignment result is not useful. Pre-alignment filtering usually saves a significant amount of time by avoiding DP-based alignment without sacrificing alignment accuracy or limiting the algorithm functionality as demonstrated when using even basic CPU implementations  architectures alleviate the data movement bottleneck of modern computing systems by providing the memory with computing competencies . PIM hasfirst publicly available programmable PIM system in the market , a framework for PIM-based sequence alignment that targets the UPMEM system. AIM dispatches a large number of sequence pairs across different memory modules and aligns each pair using compute cores within the memory module where the pair resides. AIM supports multiple alignment algorithms including NW, SWG, GenASM, WFA, and WFA adaptive. Each algorithm has alternate implementations that manage the UPMEM memory hierarchy differently and are suitable for different read lengths.We evaluate AIM on a real UPMEM system and compare the throughput it can achieve with that achieved by server-grade multi-threaded CPU systems running at full scale. Our evaluation shows that a real PIM system can substantially outperform CPU systems for a wide variety of algorithms, read lengths, and edit distance thresholds. For example, for WFA adaptive, the state-of-the-art sequence alignment algorithm, AIM achieves a speedup of up to 2.56the time , or BWA-the time . Our resIn this section, we provide an overview of PIM and the UPMEM PIM architecture (Section 2.1). We then describe the overall workflow of our PIM-based sequence alignment framework (Section 2.2), how we manage data within the UPMEM PIM memory hierarchy (Section 2.3), and how each of the different sequence alignment algorithms are supported within our framework (Section 2.4).In a PIM system, illustrated in https://sdk.upmem.com) processing-in-DRAM architecture. An UPMEM system consists of a set of UPMEM DIMM modules plugged alongside main memory (standard DDR4 DIMMs) and acting as parallel co-processors to the host CPU. An UPMEM module is a DDR4-2400 DIMM with 16 PIM-enabled chips, where each chip consists of eight general-purpose processing PIM cores called DRAM Processing Units (DPUs). Each DPU is coupled with a 64-MB DRAM bank called main RAM (MRAM). A current UPMEM system supports up to 20 UPMEM modules, which is equivalent to 2560 DPUs and 160 GB of memory. A DPU is a 32-bit RISC processor with a proprietary Instruction Set Architecture (ISA), which can potentially run at 500 MHz. Each DPU has 24 hardware threads that share a 24-KB instruction memory (IRAM) and a 64-KB scratchpad memory which is also called a working RAM (WRAM). The threads also share the 64-MB MRAM bank coupled with the DPU. DPUs cannot communicate with other DPUs or access data outside their own MRAM bank. The host CPU transfers data between the main memory and the MRAM banks and coordinates communication and synchronization across DPUs if needed.The UPMEM PIM architecture  is the fNext, we launch the DPU kernels and have each thread in each DPU work independently to align a set of sequence pairs. This parallelization scheme avoids inter-DPU and inter-thread synchronization, which can be expensive in the UPMEM system . In StepFinally, once all DPUs finish execution, we retrieve and save the alignment results. In Step (6), we transfer the alignment score and operations of each sequence pair from the UPMEM DIMMs to main memory using parallel transfers. In Step (7), we load the results from main memory and write them to an output file on disk.One important aspect of implementing alignment algorithms on the UPMEM PIM architecture efficiently is data management. Recall from Section 2.1 that an UPMEM DPU has access to two memory spaces for data: a 64-KB WRAM and a 64-MB MRAM. WRAM is fast and is accessed via loads and stores, whereas MRAM is slow and is accessed via DMA transfers to and from WRAM. Our framework always places the full sequence pair to be aligned and the full alignment result in WRAM for fast access because these data items are small. However, the intermediate data structures used by the alignment algorithms are relatively large. For this reason, it may not be possible to fit the entire intermediate data structure for each DPU thread in WRAM while supporting a large enough number of DPU threads to efficiently utilize the DPU pipeline. In this case, the constrained WRAM capacity can act as a limiting factor to parallelism.To tackle this trade-off, we provide two alternative implementations of each alignment algorithm. This first implementation, illustrated in Another important aspect of data management is performing dynamic memory allocation efficiently. NW, SWG, and GenASM have fixed-size data structures that are allocated in WRAM or MRAM up-front. However, WFA and WFA adaptive rely on dynamic memory allocation which is performed frequently as the algorithms run. Dynamic memory allocation is needed for allocating the wavefront components, which vary in size at run time depending on the read length and similarity. The UPMEM SDK has an incremental dynamic memory allocator which allocates memory incrementally from beginning to end and then frees it all at once. However, it is not suitable for our purpose because it is shared by all threads so it requires synchronization across threads to perform allocation, which degrades performance. To overcome this issue, we provide our own per-thread custom memory allocator to perform low-overhead dynamic memory allocation in the WFA and WFA-adaptive algorithms. The allocator also ensures that allocations are properly aligned such that they can be used in DMA transfers between WRAM and MRAM.m and n are the lengths of the two aligned sequences. The data type of the DP-cells is int16. Therefore, the WRAM memory consumption per thread consists of the DP table (NW  computesSWG  resemblek) allowed while computing the alignment. In the implementation that only uses WRAM for intermediate alignment data structures, we have each DPU thread use WRAM to store the pattern bit-mask for each character in the alphabet, two status bit-vectors to hold the partial alignment between subsequences of the sequences in the pair, and four intermediate bit-vectors for each edit case . On the other hand, in the implementation that uses MRAM for intermediate alignment data structures, we store the pattern bit-mask and the two status bit-vectors in MRAM and transfer parts of them to WRAM as needed. However, the four intermediate bit vectors are still allocated in WRAM since they are small in size. In our evaluation, we set k according to the read length and error rate used.GenASM  is a recs is the alignment score. As the alignment score s increases, WFA takes longer to execute and consumes more memory because it spans more diagonals. For this reason, WFA adaptive  a dual socket Intel Xeon Silver 4215 CPU with 32 threads , 2.50 GHz frequency, 22 MB of L3 cache (11 MB/socket), and 256 GB of main memory, (ii) a dual socket Intel Xeon Gold 5120 CPU with 56 threads , 2.20 GHz frequency, 38 MB of L3 cache (19 MB/socket), and 64 GB of main memory, and (iii) a dual socket Intel Xeon E5-2697 v2 CPU with 48 threads , 2.70 GHz frequency, 60 MB of L3 cache (30 MB/socket), and 32 GB of main memory. We use execution time as the basis for comparison, which includes the wall clock time for performing data transfer, alignment, backtrace, and CIGAR string generation.We evaluate our PIM implementations on a UPMEM system with 2560 DPUs (20 UPMEM-DIMMs) running at 425 MHz. We evaluate the CPU implementations on three different https://www.ebi.ac.uk/ena/browser/view) mentioned in We use real and synthetic datasets to evaluate our proposed framework, as shown in perf. The first observation is that among the three CPU baselines, the best performing baseline in the majority of cases is the Xeon E5 CPU system. Despite not having the largest number of threads, this baseline has the largest L3 cache. This result demonstrates the memory boundedness of the sequence alignment problem, where having a larger L3 cache is favored over more having more threads.The second observation is that our framework running on the UPMEM system outperforms the CPU baselines in the majority of cases, even when data transfer time is included. The speedup achieved over the best CPU baseline is up to 4.06Here, we would like to reiterate that our CPU baselines are powerful server-grade dual-socket systems running at full scale. CPU hardware and software have been developed and optimized for decades by large teams of engineers, whereas the UPMEM PIM system has been developed over a few years by a small team. We expect that the relative advantage of PIM systems will be more pronounced as PIM hardware and software matures. We also note that in our current system, the DPUs are running at 425 MHz; however, they are expected to run at 500 MHz in future systems which would further improve performance.not included, our framework achieves a speedup over the best CPU baseline of up to 28.14The third observation is that, when the data transfer time is The fourth observation is that our framework does not outperform the best CPU baseline for NW and SWG at small read lengths. NW and SWG have more regular memory access patterns than the other alignment algorithms, and when the read lengths are small, the intermediate data structures fit into the CPU cache. The combination of these two factors makes the memory bandwidth bottleneck less pronounced, which diminishes the advantage of PIM. However, for other algorithms where the memory access pattern is less regular, and for larger read lengths where the sizes of the intermediate data structures outgrow the size of the CPU cache, the computation becomes more memory bound causing our framework to achieve large speedups over the CPU baseline.To further study the scalability of our framework, we evaluate the state-of-the-art algorithm, WFA adaptive, on large sequence lengths of 5 and 10 kb. NW and SWG have difficulty scaling to such large read lengths because their quadratic space complexity causes them to exceed the MRAM capacity even for a single alignment. However, WFA and WFA adaptive are not limited by MRAM capacity due to their linear space complexity. The execution time of WFA adaptive for large read lengths while aligning one million sequence pairs is shown in We observe that our framework executing on the UPMEM system continues to outperform all CPU baselines. The only exception is for read length 10 000 with an edit distance threshold of 5%. In this case, the WRAM capacity is only sufficient to support a single DPU thread per DPU which underutilizes the DPU pipelines. Although the algorithm is not limited by the 64-MB MRAM for storing all the wavefront components, it is limited by the 64-KB WRAM for storing the select wavefront components needed for computing a new wavefront component. Hence, our current framework executing on the current hardware cannot scale to read lengths far beyond 10 000 for WFA and WFA adaptive due to WRAM capacity constraints. In some bioinformatics applications (such as minimap2), sequence alignment is typically performed only between every two seed chains to avoid long execution time and peak memory that could result from performing sequence alignment on the complete read sequence. Thus, we believe that our framework is useful for a wide range of applications despite the sequence length limitation. However, if sequence lengths far beyond 10 000 are a concern, the current limitation can be mitigated by streaming partial wavefront components from MRAM to WRAM in order to reduce the WRAM footprint and support aligning more sequence pairs of larger length simultaneously, or by using multiple DPU threads to align a single sequence pair. These improvements are the subject of our future work. We also expect the supportable read length and the performance for large read lengths to improve in future systems as the hardware and software mature, as the clock frequency of the DPUs increases, and as future systems may have larger WRAM capacity.Recall from Section 2.3 that our framework provides two implementations of each algorithm: one that only uses WRAM for intermediate alignment data structures, and another that uses MRAM for these data structures and transfers data currently being accessed from these data structures to WRAM as needed. The first observation is that for the algorithms that use a large amount of memory for the intermediate alignment data structures (i.e. NW and SWG), the implementations that use both WRAM and MRAM scale better with the read length than those that only use WRAM. In the case of NW for small read lengths, the implementation that uses WRAM only is up to 1.70The second observation is that for the algorithm that uses a small amount of memory for the intermediate alignment data structures (i.e. GenASM), the implementation that only uses WRAM is faster , the implementations that use WRAM only are faster for shorter reads (up to 1.17The three observations presented in this section demonstrate the importance of our framework supporting both implementations of each algorithm, those that use WRAM only and those that use WRAM and MRAM for intermediate alignment data structures. In either case, our framework can automatically identify the maximum number of threads that can be used to alleviate this burden from the user.We present a framework for high-throughput pairwise sequence alignment that overcomes the memory bandwidth bottleneck by using real PIM systems. Our framework targets UPMEM, the first publicly available general-purpose programmable PIM architecture. It supports multiple alignment algorithms and includes two implementations of each algorithm that manage the UPMEM memory hierarchy differently and are suitable for different read lengths. Our evaluation shows that our framework executing on an UPMEM PIM system substantially outperforms parallel CPU implementations executing at full-scale on dual-socket server-grade CPU systems. Our results demonstrate that PIM systems provide a promising alternative for accelerating sequence alignment. We expect even larger improvements from future incarnations of PIM systems.


Parallel texts represent a very valuable resource in many applications of natural language processing. The fundamental step in creating parallel corpus is the alignment. Sentence alignment is the issue of finding correspondence between source sentences and their equivalent translations in the target text. A number of automatic sentence alignment approaches were proposed including neural networks, which can be divided into length-based, lexicon-based, and translation-based. In our study, we used five different aligners, namely Bilingual sentence aligner (BSA), Hunalign, Bleualign, Vecalign, and Bertalign. We evaluated both, the performance of the Bertalign in terms of accuracy against the up to now employed aligners as well as among each other in the language pair English-Sovak. We created our custom corpus consisting of texts collected in 2021 and 2022. Vecalign and Bertalign performed statistically significantly best and BSA the worst. Hunalign and Bleualign achieved the same performance in terms of F1 score. However, Bleualign achieved the most diverse results in terms of performance. This alignment procedure initiates at a broader scale, matching entire documents. It then progresses to a more detailed focus, aligning individual paragraphs within those matched documents. As the process continues, it becomes finer, pairing corresponding sentences and ultimately aligning individual words. The process starts at the general level of alignment and increases in granularity of alignment at subsequent level, i.e., from document alignment through paragraph to sentence and word alignments2. It consists of finding correspondences  between logical units, i.e., between mutual translations of source and target texts3. The most common alignment is 1 to 1 alignment, but there exists a significant presence of complex alignment, such as 1 to 0 or vice versa 0 to 1 and also many to many alignment, depending on the source, target languages (genre and text type) and translator competence4. For instance, Sennrich and Volk5 manually aligned a set of 1000 sentences and found that only 74% of sentence alignments were 1 to1. Depending on various levels of language granularity, the alignment can be conducted at the word, phrase, and sentence level6. Sentence alignment is considered a fundamental task in multilingual text processing, which has resulted in the proposal of many sentence alignment algorithms. They can be classified into three approaches: length-based, lexicon-based, and translation-based approaches to sentence alignment10. The first two approaches rely on the assumption that the order and length of the sentences are relatively the same in bitext . Both approaches have pros and cons, which motivated researchers (e.g. Refs.11) to combine length-based features with lexical similarities for aligning sentences13. Algorithms that are unsupervised and language independent use mainly sentence length statistics14. The length-based algorithms can achieve small error rates on literal translations, but in translations where some sentences are skipped or merged they are not robust7. Sennrich and Volk5 have presented an algorithm that can compute sentence alignment for a parallel text. This algorithm requires two sets of documents, which can be articles or paragraphs, along with their corresponding translations. The texts are separated by hard delimiters, and it is essential to choose reliable delimiters since the algorithm does not look for alignments that cross these boundaries. The algorithm is primarily designed for articles that cover multiple pages, usually containing 500 or more sentences. Although it is fast enough to process such long texts, its quadratic complexity makes it unsuitable for aligning entire text collections without the use of hard delimiters.Sentence alignment is the task of taking parallel documents, which have been split into sentences, and finding a bipartite graph which matches minimal groups of sentences that are translations of each other15. However, misaligned sentences have been shown to be much more detrimental to neural machine translation (NMT)16.Sentence-aligned bitext is used to train nearly all machine translation (MT) systems. Alignment errors have been noted as having a small effect on statistical MT performance17 demonstrate that both supervised and semi-supervised approaches outperform even the best unsupervised systems. Accurate alignment between parallel corpora is essential not only for machine translation but also for lexicography, terminology extraction, and other applications. In Digital Humanities (DH), parallel corpus alignment is used for historical language learning, version alignment of medieval texts, and more.Despite the recent success of neural machine translation (MT) models with large amounts of data, Kim et al.1. Some aligners are more general and language independent, while other aligners are specific, (in certain domain such as noisy data) and language dependent (work between given languages)11. Seničić and Fairon18 divide the sentence alignment tools into three categories: (1) statistical aligners, (2) lexical aligners, and (3) hybrid aligners. Statistical aligners use length-based algorithms  to determine equivalency between the sentences in the source and target language. They have been used in the alignment of the Europarl corpus. Lexical aligners use dictionaries or lexicons  to determine equivalency between sentences in the source and target language (e.g. Champollion). Hybrid aligner combines statistical methods with available lexical information8. Hunalign performed very well for languages with high degrees of inflection such as Slovak or Hungarian.Due to the importance of alignment tasks in natural language processing (NLP), several sentence alignment tools have been developed13.Traditional sentence alignment approaches suffer from a sparsity problem due to language ambiguity22. Neural alignment maps a source sentence into a fixed-length vector and then predicts if two sentences are aligned by their sentence vectors13. Li23 classifies neural alignment approaches into induction, unsupervised, and guided approaches. The induction approach operates on the attentional NMT models19. The unsupervised approach does not train the alignment on gold sentence/word alignment24 and the guided neural approach to alignment utilizes training data with word/sentence alignments17.As neural networks have been shown to be a powerful approach to text representation and sentence modelling, automatic sentence alignment methods using neural networks have started to gain popularity25 assessed the accuracy of the GIZA +  + alignment toolkit for the Czech-English language pair. Kruijff-Korbayová et al.26 compared automatic (GIZA + +) and manual word alignment.The Slovak language, which is the subject of our research, belongs to the Slavic language group. Specifically, it is classified as a West Slavic language, along with Polish, Czech, and partly Sorbian (Lusatian Sorbian). To our knowledge, there has not been significant attention given to sentence alignment in the context of the Slovak language compared to other Slavic languages. For example, Bojar and Prokopova27 focused on the alignment of Czech and English tectogrammatical dependency trees, comparing the t-aligner with GIZA +  + . Ngo Ho28 analyzed two statistical word alignment systems, GIZA +  + and Fastalign, for six language pairs—English with French, German, Romanian, Czech, Japanese, and Vietnamese.Similarly, Marecek et al.2 or multilingual sentence embeddings29, pre-trained multilingual language models based on the BERT architecture30, or machine translation31.In recent times, there have been several research efforts focusing on low resource languages, such as Slavic languages. These studies have aimed to propose new alignment methods, such as using deep learning networks for bilingual sentence alignment based on sentence embeddings such as Vecalign32 evaluated four alignment methods  for the Vietnamese-Lao language pair. Fernando et al.33 conducted an evaluation of sentence representations derived from LASER, XLM-R, and LaBSE with Hunalign on three language pairs: Sinhala–Tamil, Sinhala–English, and Tamil–English. Signoroni and Rychlý34 evaluated four alignment methods  for the English-Yorùbá language pair. A. K. Singh and Husain35 evaluated four alignment methods  for the English-Hindi language pair. Abdul-Rauf et al.36 evaluated five different alignment methods  on French–English and Urdu-English bitexts. Krynicki37 assessed the performance of four sentence aligners  on English-Polish bitexts.Tien et al.38 conducted research comparing the alignment of sentences in multiparallel corpora, primarily based on the Europarl corpus, using a multilingual sentence alignment algorithm. The performance of this algorithm was compared with the Hunalign algorithm. However, the set of gold alignments only included six languages, and Slovak was not among them. The evaluation considered not only the coverage of multilingual sentence alignment, but also compared these alignments using the F-score.Graen12. In the next section we offer a brief overview of the different sentence alignment tools. The third section describes a methodology and the extra steps and tools that were required in order to create a unified output from different aligners. In the fourth section we present the results with the last section summarizing the findings.In this paper, we compare different alignment approaches and present our custom algorithm for alignment evaluation against human-aligned reference, which is a typical approach for evaluation8 use scoring functions based only on the number of words or characters in each sentence and alignment algorithms based on dynamic programming (DP). DP is O time complexity . The first focuses on extraction of parallel sentences, which the system considers reliable. These extracted parallel sentences are then used as anchor points to reduce search space or to obtain better estimation tools for parallelism (unsupervised) or both. The second step relies on realignment using the information obtained from the first step. Both algorithms arise from the following assumptions: only a limited number of alignment link types exist, and these links lie around the diagonal22, depend on dictionaries or existing sentence pairs and are weak in many to many sentence alignment.Some sentence alignment models are supervised9 presents a three-step algorithm that blends techniques adapted from previous work on word and sentence alignment. Initially, the algorithm aligns the corpus by utilizing a modified version of Brown et al.’s40 sentence-length-based model. Next, Moore9 incorporates an innovative search-pruning method to efficiently identify the most probable sentence pairs without relying on anchor points or previously aligned units. He then employs the sentence pairs assigned the highest probability of alignment to train a revised edition of IBM Translation Model 1. Lastly, he realigns the corpus, augmenting the initial alignment model with IBM Model 1, to generate an alignment that is based on both sentence length and word correspondence. The search is restricted to the minimal alignment segments that were assigned a non-negligible probability based on the initial alignment model. As a result, the search space is reduced significantly, making this final alignment quicker than the initial alignment, despite the model being more computationally demanding for each segment. This method employs both sentence length and lexical correspondence to derive the final alignment. However, since the lexical correspondence is obtained automatically, no externally supplied lexicon is required.Moore10 is available, Hunalign utilizes it to combine with Gale-Church sentence-length information. However, if a dictionary is not available, it falls back to sentence-length information and creates an automatic dictionary based on the alignment. In the second pass, Hunalign uses the automatic dictionary to realign the text. It’s important to note that, similar to other sentence aligners, Hunalign cannot handle changes in sentence order and cannot generate crossing alignments where segments A and B in one language correspond to segments B’ and A’ in the other language.Hunalign is a tool that aligns text in two languages on a sentence level. It requires tokenized and sentence-segmented text as input and produces bilingual sentence pairs (bisentences) as output. In case a dictionary9 and Varga et al.’s11 approach both employ a two-pass algorithm for aligning bilingual text, where a length-based method is used in the initial alignment. The first alignment is then utilized as training data for a translation model, which is subsequently applied to a complex similarity score. The main difference between these two approaches lies in the type of translation model used. Varga et al.’s approach utilizes a dictionary-based translation model, which can be manually expanded20, while Moore’s aligner9 works with the IBM-1 translation model.Moore’s aligner5.The alignment process involves calculating a similarity score and is completed in two steps. In the first step, the algorithm searches for 1-to-1 alignments to maximize the BLEU score. The remaining sentences are then aligned using a 1-to-n approach or a length-based algorithm5, this method surpasses state-of-the-art algorithms in alignment tasks and produces better performance in statistical machine translation (SMT). The Bleualign algorithm is executed for every text segment between two hard delimiters (including the beginning and end of the file) and comprises of two stages. In the first stage, a group of anchor points is identified using the BLEU score between the translated source text and the target text. The second step involves either aligning the sentences between these anchor points using BLEU-based heuristics or applying the length-based algorithm developed by Gale and Church21.Bleualign utilizes machine translations and the BLEU score as a similarity metric to locate reliable anchor points. The gaps between these points are then filled in using BLEU-based and length-based heuristics. According to the authorsVecalign is a quick and precise method for aligning sentences, even for lengthy documents. When used alongside LASER, it can be applied to over 100 languages (i.e. 100^2 language pairs) without relying on a machine translation system or lexicon.2. This allows Vecalign to efficiently align long documents in multiple languages, without relying on a machine translation system or lexicon.Vecalign employs multilingual sentence embeddings to measure the similarity between sentences and uses an approximation of Dynamic Programming (DP) based on Fast Dynamic Time Warping, which has a linear time and space complexity in relation to the number of sentences being aligned23.Vecalign introduces a novel scoring function that measures the similarity of bilingual sentence embeddings. This approach calculates scores for the similarity of sentence embeddings by employing cosine similarity and normalizing it with randomly selected embeddings. It then averages neighboring pairs of sentence embeddings in both documents and aligns these approximate embeddings. This alignment is subsequently fine-tuned iteratively, using the original embeddings and a small window around them41.The LASER4 tool is used to compute the sentence embeddings, which are based on an architecture for creating language-independent sentence embeddings2 evaluated sentence alignment accuracy using the development/test split released with Bleualign, consisting of manually aligned yearbook articles published in both German and French by the Swiss Alpine Club from the Text + Berg corpus5. Hyperparameters were chosen to optimize F1 on the development set. They considered alignments of up to 6 total sentences, which means they allowed alignments of size 9, and the Coverage-based sentence alignment tool42. Hunalign was used in both bootstrapping mode as well as using a publicly available De–Fr lexicon from OPUS created from Europarl.Thompson and Koehn43 is a novel solution aimed at improving the accuracy of sentence alignment, particularly focusing on literary texts. Bertalign introduces a two-step algorithm for bilingual sentence alignment. In the first step, it identifies optimal one-to-one alignments by leveraging bidirectional encoder representations from transformer-based cross-lingual word embeddings. Specifically, it selects the top-k most semantically similar target sentences for each source sentence. In the second step, the Bertalign utilizes the paths found in the first step to recover all valid alignments that involve more than one sentence on each side of the bilingual text. The Bertalign aligner supports 25 languages, including the Slovak language.Bertalign43 state, literary texts pose unique challenges in the alignment process as they often involve complex, interpretative translations that do not neatly correspond to one-to-one mappings between source and target sentences. Traditional alignment methods tend to emphasize one-to-one links, making it challenging to handle the more intricate one-to-many and many-to-many alignments prevalent in literary content.As the Liu and Zhu43 compared Bertalign’s results with five baseline systems, including Gale-Church, Hunalign, Bleualign, Bleurtalign, and Vecalign. They demonstrate that Bertalign achieves the highest accuracy, measured by the F1 score, on both evaluation datasets compared to up to now approaches and methods.Liu and ZhuThe goal of the research is to evaluate the performance , Recall (2), and F1 score (3)) of different alignment algorithms  for the Slovak-English language pair. To achieve this goal, we required a dataset (corpus) that was not pre-aligned. Consequently, we opted not to utilize any pre-existing parallel corpora , as they are already aligned. We carried out an experiment on 50 documents (dataset) while investigating the performance of individual algorithms. The performance of each algorithm (tool) was measured using the precision, recall and f-score metrics. Our dataset has 50 cases and 25 variables .We created our custom dataset (corpus), which consists of texts collected in 2021 and 2022. The obtained texts contain English texts of various genres and their human translations into Slovak. In total, we obtained 86 English documents  and 86 corresponding, but not aligned Slovak translations ; in this study we use only 50 of them . We manually aligned all the examined texts to obtain a reference sentence alignment, which we later used for computing the performance measures. Manual sentence alignment was conducted by three professional translators. To guarantee the quality of the human-aligned reference, we conducted a thorough review of the outcomes generated by the tool designed for assessing aligners. Any disparities detected by the tool between the automatically aligned content and the human-aligned reference were manually inspected and corrected within the reference alignment in cases where errors were identified.We state the global null statistical hypotheses for the performance measures:Accuracy of the alignment  does not depend on the used alignment algorithm/tool .The number of total alignments is the number of alignments created by the tool and the number of matched alignments is the number of alignments that were found in both reference alignments and in alignments created by the tool.We have created our own tool that uses a simple algorithm to evaluate sentence alignments. It takes the alignment created by the aligner for source text, reads the first line and then searches in reference for source text . If a match is found, it takes the target alignment from reference and searches for a match in the target alignment file created by the aligner. If no match is found in the source texts, it is evaluated as a wrong alignment, since the reference alignment for the source text does not contain the automatic alignment created by the aligner.https://github.com/coezbek/hunalign-dict-muse. We utilized the code from https://github.com/rsennrich/Bleualign for sentence alignment with Bleualign, and https://github.com/thompsonb/vecaalign for sentence alignment with Vecalign. Additionally, we used https://github.com/bfsujason/bertalign for sentence alignment with Bertalign.We took the latest version available on github and used local builds . The only exception was BSA from Microsoft, which is not open-source and we used download link on their official webpage. In most of the cases we have used default parameters and configurations. For Hunalign, we did use the dictionaries collected from Different tools use different output formats. Some of them return aligned text files , some return a table with aligned sentence indexes , that can process the result from Vecalign and create a parallel corpus based on Vecalign results. Based on the information from the first entry and the source file, we can create a new text document, in which the sentences in the lines are written according to the instructions from Vecalign. Then, we repeat the algorithm for the second entry in the vecalign output and target file. As a result, we obtain a pair of sentence aligned text files.To create a more meaningful output, we created an algorithm . It also contains triple tilde (~ ~ ~) in cases where the alignment between source and target was not 1:1 Fig. .We wrote a simple program to post-process this output. We had to remove triple tildes, because the evaluation process would not be possible as the strings in output files would be different than those in the original files. Following this we created two aligned text files to match the specified output format.The aim of the research was to assess the performance  of different alignment algorithms used in tools  for the language pair Slovak-English. The experiment was conducted on 50 documents, with a focus on evaluating the performance of each algorithm. In other words, our dataset consists of 50 cases and 25 variables .We established global null statistical hypotheses for the observed performance measures:The correctness of alignment  does not depend on the alignment algorithm used .W = 0.001, Chi-sqr = 338.714, df = 9, p < 0.001, Matched alignments: W = 0.042, Chi-sqr = 150.843, df = 9, p < 0.001, Precision: W = 0.132, Chi-sqr = 96.130, df = 9, p < 0.001, Recall: W = 0.539, Chi-sqr = 29.271, df = 9, p < 0.001, F1 score: W = 0.516, Chi-sqr = 31.395, df = 9, p < 0.001), F1 score: W = 0.769, Chi-sqr = 12.506, df = 5, p < 0.05).Given the small deviations from normality, the sufficient number of cases and the robustness of the F test statistic against the violation of the assumption of normality, we decided to use parametric procedures. To test the global null hypotheses, in the case of Total alignments, Matched alignments, Precision, Recall, and F1 score, we used adjusted univariate tests for repeated measures (Huynh–Feldt correction) due to violation of the sphericity assumption .In the case of Total alignments, Matched alignments, Precision, Recall, and F1 score, we reject the null hypothesis at the 0.001 significance level, based on the results of adjusted univariate tests for repeated measures  between the examined algorithms . For this purpose, we used multiple comparisons, specifically the Duncan’s test, which is more appropriate compared to standard post-hoc tests.p < 0.05) and the BSA tool performs the worst (p < 0.05). The Bertalign, Vecalign, and Bleualign tools, in terms of the total number of alignments (Table p > 0.05). However, if we look at the number of matched alignments (Table p < 0.05), on the contrary, a statistically significant difference was not proved between the Bertalign, Vecalign, and Hunalign tools (p > 0.05), these tools formed a one homogeneous group in terms of the number of matched alignments. The BSA achieved the lowest number of alignments in both cases  and the best performance was achieved by the Bertalign tool, which is statistically significantly better than the Hunalign, Bleualign, and BSA tools (p < 0.05). On the other hand, a statistically significant difference was not demonstrated between the Bertalign and Vecalign algorithms (p > 0.05); these tools form a one homogeneous group in terms of the performance of accuracy measured by Precision. Similar results were also proved in the case of Recall (Table p > 0.05).In terms of the performance of accuracy measured by Precision and Recall, the results are similar Table a,b. In tll Table b, where p < 0.05) and the BSA tool performs the worst (p < 0.05). The Hunalign and Bleualign tools achieved the same performance in terms of F1 score and form a one homogeneous group (p > 0.05).However, if we look at the performance of the tools in terms of the harmonic mean of the Precision and Recall, i.e. F1 score Table , the BerThe highest variability Tables , and 3, If we look at the performance of individual tools in more detail, through individual cases—documents. The following figures Figs. , 5 and 6These results confirm the previous findings; the best performance is achieved by the Vecalign Fig.  and BertIn document ID#023 Vecalign returned one of the alignments in the form :[99]:0.000, which means that it aligned an empty English sentence to one Slovak sentence. After that all the alignments were wrongly aligned. In the original form, this document contains 440 English and 530 Slovak sentences respectively. A larger difference between the two may be the cause of such an error.Similarly, document ID#001 contains 303 source sentences and 384 target sentences, which is a difference of 81 sentences. In this case we can also see a higher number of residual alignments, which further supports our assumption.This could be fixed by splitting the document into smaller batches (paragraphs).residual > 1). Similarly, in the case of Bleualign .Based on performance measures , the Hunalign and Bleualign achieved approximately the same performance, which was also confirmed by a more detailed look at the results, through individual documents Figs. , 6. In bWe identified a few cases where the Bleualign tool misaligned sentences early in the process and was unable to recover. The rest of the sentences were misaligned accordingly and that might be the cause of the higher standard deviation.residual > 1).The worst performance is achieved by BSA Fig. , althougThis study provides an evaluation of five tools that are used to create automatic sentence alignments. We showed that both Bertalign and Vecalign, which requires only bilingual sentence embedding and are linear in time and space with respect to the number of sentences being aligned, outperform the previous state-of-the-art approaches and methods, which have a quadratic time complexity and requires a MT system.Our results indicate that the currently designed Bertalign tool achieves the best performance in alignment accuracy measured by Precision, Recall, F-score, and Match alignment with respect to reference alignment. However, a statistically significant differences were proven only between the Bertalign and BSA/Hunalign/Bleualign. The Bertalign and Vecalign achieve approximately the same performance in alignment accuracy measured by Precision, Recall, F-score and, Match alignment with respect to reference alignment. In terms of Total alignment, the Bertalign did not achieve the best performance and there was no statistically significant difference between the Bertalign and Vecalign/Bleualign in the performance of the alignment accuracy with respect to the reference alignment.We attempt to create a fair performance evaluation of sentence alignment tools. For this reason, we created multiple utility tools to obtain the results in the same output format.We showed that the method compares the output against a human aligned reference based on strings, but it does not take into consideration that the reference is not always perfect. This should be fixed in the future, either by improving the algorithm or manually checking each reported misaligned sentence pair, which would be time consuming, since most of the misalignments are correctly reported.5, Bleualign’s performance is significantly influenced by the quality of translation provided. In the absence of any translation, where the algorithm calculates sentence similarity between the target and source texts directly, its performance is lower than Gale and Church on the same evaluation set. This is due to the limited number of sentence alignments identified by BLEU, with some of them being inaccurate. In some cases , the tool was unable to recover after making a wrong alignment at the beginning and therefore the rest of the sentences were also wrongly aligned, resulting in bad performance. Changing the MT systems might improve the result, but for our experiments we only used MT output as provided by Google Translate.According to Sennrich and VolkThe main limitation we identified in automatic alignment is a decrease in alignment quality as the difference in the number of lines or sentences between the source and target increases. To address this limitation, we would suggest aligning smaller text chunks as a potential solution.29. Installing LASER itself consists of downloading encoders from Amazon s3, downloading external tools and then calculating vector embeddings for larger files which also takes some time.Another limitation of these tools is that almost all of them (except those that use length-based methods) depend on some other external tool. Bleualigner requires MT output, which must be generated by available tools and can be expensive with larger data sets. Hunalign requires a dictionary and Vecaling requires sentence embedding in a special.emb file format, which is generated by Facebook’s LASERLastly, there is the human aspect. Manually aligned references contained a few wrongly aligned sentence pairs, which we only found during testing of the evaluation algorithm. The tool reports –f –verbose flag is enabled) possibly misaligned sentences in source or target reference. We manually checked for false reports from the tool, and we found incorrect alignment in the reference. After fixing the reference, the tool no longer reported misalignment and the measurements for aligners therefore improved.


Multiple sequence alignment (MSA) is one of the hotspots of current research and is commonly used in sequence analysis scenarios. However, there is no lasting solution for MSA because it is a Nondeterministic Polynomially complete problem, and the existing methods still have room to improve the accuracy.We propose Deep reinforcement learning with Positional encoding and self-Attention for MSA, based on deep reinforcement learning, to enhance the accuracy of the alignment Specifically, inspired by the translation technique in natural language processing, we introduce self-attention and positional encoding to improve accuracy and reliability. Firstly, positional encoding encodes the position of the sequence to prevent the loss of nucleotide position information. Secondly, the self-attention model is used to extract the key features of the sequence. Then input the features into a multi-layer perceptron, which can calculate the insertion position of the gap according to the features. In addition, a novel reinforcement learning environment is designed to convert the classic progressive alignment into progressive column alignment, gradually generating each column’s sub-alignment. Finally, merge the sub-alignment into the complete alignment. Extensive experiments based on several datasets validate our method’s effectiveness for MSA, outperforming some state-of-the-art methods in terms of the Sum-of-pairs and Column scores.https://github.com/ZhangLab312/DPAMSA.The process is implemented in Python and available as open-source software from  Multiple sequence alignment (MSA) aims to align similar or homologous regions between multiple sequences at the least cost of minimum insertion of gaps. MSA has been widely used in biological sequence analysis -based method , an MSA method combining natural language processing technology and deep reinforcement learning (DRL) in MSA , PronConS contains s sequences, the corresponding alignment is CA. However, there is no entirely correct biological evolution model, and we cannot judge whether the alignment CA conforms to the law of natural evolution. Therefore, the alignment CA of dataset S may not be unique for the current research. There may be multiple or even countless results, recorded as the set Given a dataset  follows .CA, and kth deoxynucleotide of the ith sequence. The function x and y, and the calculation equation is shown in where x or y is a gap, the score is x and y are the same, the score is 4. (iii) Mismatch penalty: when x and y are different, the score is x and y, and then judge the matching of x and y. Therefore, the SP score is the sum of the scores of all paired deoxynucleotides in the alignment.The calculation basis of this function mainly includes the following three kinds: (i) Gap penalty: when either This study aims to find the alignment with the highest SP score. Therefore, the overall objective function can be expressed as.ith column in the aligned area described above, the score Another commonly used evaluation indicator is column score (CS). For the Sequence alignment: S, sequence alignment is performed column by column. The sequence state changes when a column is aligned, such as AA (Aligned Area). In contrast, the columns that have not completed the alignment are surrounded by a red box, denoted as NA (Not Aligned Area). The black arrow points to the current alignment column.State update: State embedding: NA are spliced into a long sequence and then converted into the corresponding sequence integer vector. Taking the state NA is . According to the above definition, each sequence in the NA is spliced into a long sequence, which is expressed as “ATTG_ATTTTG_TATTTCG_.” Then, the long sequence is converted into state vector L is the maximum length of the three aligned sequences, and n is the number of aligned sequences. Therefore, the final representation of the initial state is .Gaps insertion: The environment in reinforcement learning mainly includes the agent, state, action, and reward functions. Their definitions are as follows . The network consists of three linear layers. Parameters are shown in Q values respectively and corresponding When the sequence state in the environment changes, environmental information is transmitted to the replay memory. When the number of quaternions stored in the replay memory reaches the minimum number of batches (128), To optimize the weight of the evaluation Q network, we use the mean square error as the loss function, and its expression is as follows:y indicates the max action value under the state where We conducted multiple experiments on several datasets to evaluate DPAMSA. In particular, this experiment mainly answers the following questions:RQ1: Can our method get reliable results?RQ2: Can our method outperform the state-of-the-art MSA methods?RQ3: Are the positional encoding and self-attention mechanisms helpful to the final MSA?RQ4: How about the visualization results of the MSA?In the experiment, all sequences in datasets are a snippet from benchmarks such as OXBench . These dIn this experiment, four metrics are used to evaluate the methods. These metrics are as follows: Sum-of-pairs (SP) score is the sum of all paired sequence scores, represented by Seven commonly used MSA programs were selected in this control experiment. The algorithms used in these programs can be roughly divided into progressive alignment-based programs, iterative algorithm-based programs, and Hidden Markov model-based (HMM) programs. Specifically, the progressive alignment includes ClustalW  the HMM-Hyperparameters mainly include reinforcement learning parameters and relevant network parameters. The settings of these parameters in the experiment are shown in In dataset experiments, the datasets, hyperparameters, and running environments used in the experiment are the same. After aligning the five types of datasets, the relevant scores in The CS score is the ratio of the number of exactly matched columns to the length of the alignment, reflecting the overall quality of the alignment. Therefore, from the perspective of the average CS score, the first type and fifth types of datasets have better alignment quality. At the same time, the rate gradually decreases in the remaining three types. This downward trend has nothing to do with the method itself; the biggest reason is the sequence itself. Because the number of sequences increases, the nucleotide mismatch probability of each column gradually increases, which causes a decrease in the CS score. Because the number or length of sequences increases, the time of train and prediction gradually increases. The result data in In addition, To verify the stability and convergence of the model, we repeated five dataset experiments, obtained the average SP score according to each aligned result, and calculated the mean and standard deviation of the five dataset experiments. As shown in SP score is about 150. The oscillation is because the As shown in Across all five types of datasets, DPAMSA can outperform all the competitors significantly. For example, the SP score of DPAMSA is 16%–163% higher than that of other programs over all datasets. Besides, DPAMSA is 7%–43% higher than others in the CS score. Moreover, even in the number of optimal alignments, our method also significantly improves.Most construct alignment based on guide trees for the progressive alignment-based programs  and iterative alignment-based programs (MAFFT and MUSCLE). This indicates that the greedy nature of the construction process is easy to lead the methods to local optimum and lower accuracy DPAMSA adopts reinforcement learning, which can avoid the influence of greedy nature. For example, as shown in For Hidden Markov model-based programs , use a posteriori probability to optimize the guide tree, significantly improving alignment accuracy. However, they adopt the idea of progressive alignment, and their accuracy still has room for improvement. For example, they are combined with P values are as follows: P values show that our method significantly differs from other methods in the alignments except PronCons, while ProbCons is relatively tiny. More detailed derivations can be found in Assuming that the significance level is .05 and taking the CS score as the sample, the significance of DPAMSA and the other seven programs are tested, respectively. The calculated This section is an ablation experiment to determine our method’s utility of self-attention and positional encoding. We choose three models in this experiment, which are as follows: OM: This model keeps all modules described in P values are .011 and .005, respectively. The P value further indicates a significant difference between the complete and the other two models. This experiment proves that applying self-attention and positional encoding in MSA is feasible. Each of them can improve the accuracy of alignment to a certain extent.ATC, ATC, ATC] in the second alignment.In addition to these metrics mentioned above, we also found that our method can detect more homologous regions from the alignment. For example, This paper presents a DRL-based method with natural language process techniques to solve the MSA problem. We argue that the sequence feature is critical to enhancing the accuracy of the alignment. We introduced a self-attention mechanism to extract the feature of the current alignment and then utilized positional encoding to improve the reliability of the extracted feature. Finally, the feature was input into a multi-layer perceptron to predict the weight of the action in reinforcement learning. To our knowledge, DPAMSA is the first technique that exploits self-attention and positional encoding on the sequence alignment. We conducted extensive experiments on five datasets and demonstrated that this method could remarkably outperform several state-of-the-art competitors in MSA. Besides we also carried out the ablation experiment, which proves the effectiveness of the self-attention mechanism and positional encoding. In the future, we plan to optimize the architecture of the current model to reduce the complexity. We believe this paper would provide a novel and clear insight to the researchers engaging in MSA.btad636_Supplementary_DataClick here for additional data file.


Despite advances in method development for multiple sequence alignment over the last several decades, the alignment of datasets exhibiting substantial sequence length heterogeneity, especially when the input sequences include very short sequences (either as a result of sequencing technologies or of large deletions during evolution) remains an inadequately solved problem.We present HMMerge, a method to compute an alignment of datasets exhibiting high sequence length heterogeneity, or to add short sequences into a given ‘backbone’ alignment. HMMerge builds on the technique from its predecessor alignment methods, UPP and WITCH, which build an ensemble of profile HMMs to represent the backbone alignment and add the remaining sequences into the backbone alignment using the ensemble. HMMerge differs from UPP and WITCH by building a new ‘merged’ HMM from the ensemble, and then using that merged HMM to align the query sequences. We show that HMMerge is competitive with WITCH, with an advantage over WITCH when adding very short sequences into backbone alignments.https://github.com/MinhyukPark/HMMerge.HMMerge is freely available at Bioinformatics Advances online. Multiple sequence alignment (MSA) is a necessary first step in many common bioinformatics pipelines, such as phylogenetic tree inference and metagenomic taxon identification, and so obtaining high quality MSAs has high relevance in downstream analyses . One of UPP . Both UPHere, we present HMMerge, a new approach for computing alignments. We follow the same initial steps as WITCH and UPP . We then deviate from WITCH in several ways. First, we use only a selected subset of the HMMs from the WITCH ensemble of HMMs for the HMMerge ensemble. Second, instead of aligning the query sequence to each HMM and then computing a consensus of these extended alignments, we use the HMMerge ensemble of HMMs to build a new HMM  to represent the backbone alignment. The topology of the HMM is the same for all query sequences but the numeric parameters (transition and emission probabilities) are derived for each query sequence. Finally, given a query sequence, the numeric parameters are computed and then used to align the query sequence to the backbone alignment.As this study shows, using both simulated and biological data, HMMerge is competitive with WITCH when aligning datasets with sequence length heterogeneity (sometimes more accurate and sometimes less accurate), and has an advantage in some cases when there are very short sequences in the dataset. More generally, we show that two-stage methods, including the use of MAFFT-addfragments , provideWe first describe HMMerge, which is our new approach for aligning sequence datasets that exhibit sequence length heterogeneity. We then describe the experimental study we used to evaluate HMMerge.HMMerge operates in three stages: the backbone stage, the construction of the eHMM for the backbone, and then the search-and-align stage. HMMerge uses the same process for stages 1 and 2 as handled by both UPP and WITCH, but then differs from both for the third stage. Due to space limitations, we briefly review the first two stages, and provide details only for the third stage for HMMerge; see In the backbone stage, the input sequences are split into two sets, with one set containing some of the ‘full-length’ sequences and the remaining sequences denoted ‘query’ sequences. An alignment is built on the full-length sequences, using external methods , a majoIn Experiment 1, we explored both standard and two-stage methods on simulated datasets with introduced fragmentation.In this experiment, we examined both standard and two-stage methods on five rRNA datasets from the Comparative Ribosomal Website (CRW)  for the eHMMs we used for HMMerge. In this experiment, we explored the impact of using a larger eHMM –that is, Disjoint(50)+BB  or UPP(50) [i.e. using all the HMMs in the UPP(50) ensemble]. We perform this experiment on a subset of the study datasets.We created high-fragmentary (HF) versions of simulated nucleotide datasets, each with 1000 sequences, using three different simulators: ROSE . To makeThe ROSE simulated datasets have 15 model conditions each with 20 replicates, where each model condition varies by the average length of gaps  and by their varying substitution rates .The RNASim simulated datasets were originally used to evaluate alignment methods in The INDELible datasets were created for this study. The model tree for the simulation was taken from the set of gene trees from the ASTRAL-II study . In ordeWe used datasets from the Comparative RNA Website (CRW) .To separate the biological datasets into backbone sequences and query sequences, we split the sequences using visual inspection of their sequence length histograms. As a result, 23S.A and 23S.C were both split at 1250 (so that sequences shorter than 1250 in length were considered query sequences and the rest were backbone sequences), and 5S.3, 5S.E, and 5S.T were split at 100 (with the corresponding definition).For the simulated datasets, we summarize the empirical properties in We compare our new MSA pipeline, HMMerge, to three other two-stage methods , each using the same backbone alignment. We also compare these two-stage methods to a collection of leading MSA methods, including MAGUS, PASTA, Clustal Omega , MAFFT  were run on BlueWaters  as well as two-stage methods. When we include standard methods in the comparison, we report ‘total’ alignment error, which is alignment error on the entire sequence dataset. However, when we compare two-stage methods to each other, we report ‘query-only’ alignment error. This allows us to take advantage of the fact that all the two-stage methods are using the same backbone alignment.The comparison of six standard methods  and UPP on the 15 ROSE model conditions is given in A comparison between all four two-stage methods on the three hardest model conditions, 1000S1-HF, 1000L3-HF and 1000M1-HF , shows tA comparison between the standard methods and the two-stage methods is shown in Comparing the four two-stage methods to each other with respect to query-only alignment error , we see Results on the INDELIBLE datasets, shown in We compare the four two-stage methods with respect to query-only alignment error in A comparison of all methods, including the standard methods, is given in On the 23S.A dataset, MAFFT-linsi and MAGUS have the lowest error (0.074), followed closely by the four two-stage methods at 0.076–0.077. On the 23S.C dataset, MAFFT-linsi has the lowest error (0.038), followed closely by the four two-stage methods at 0.039, and by MAGUS at 0.040. On the 5S.E dataset, MAFFT-linsi has the lowest error (0.020), followed closely by the four two-stage methods and MAGUS at 0.024–0.029. On the 5S.3 dataset, MAFFT-addfrags has the lowest error (0.096), followed closely by the other three two-stage methods (0.099–0.101); the lowest error for any standard method is 0.105, achieved by PASTA. Finally, on the 5S.T dataset, MAFFT-addfrags has the lowest error (0.097), followed closely by the other three two-stage methods (0.099–0.102); the lowest error for any standard method is 0.108, achieved by MAGUS. We also explored the impact of using MAFFT-linsi for the backbone alignment instead of MAGUS on these datasets; as seen in With the exception of MAFFT-linsi , the trends on these five CRW datasets show that the four two-stage methods reliably have lower average alignment error than the standard methods.A comparison of the four two-stage methods with respect to query-only alignment error  show thaInspired by results reported in On the three CRW 5S datasets , DisjoinThus, this experiment suggests the possibility that HMMerge accuracy could improve by using larger ensembles [i.e. adding HMMs to the Disjoint(50) ensemble], but also suggests that it is not sufficient to simply add the HMM for the backbone alignment. See This study introduced HMMerge, a new technique for aligning datasets that exhibit sequence length heterogeneity. Like its predecessors, WITCH and UPP, it operates by constructing a backbone alignment of full-length sequences and then adds the remaining sequences into the backbone alignment using a method based on hidden Markov models. This study showed that HMMerge, WITCH and UPP all tended to have close accuracy, and generally that HMMerge and WITCH were more accurate than UPP. We also observed that using MAFFT-addfrags to add the remaining sequences into the backbone alignment had comparable accuracy to HMMerge, WITCh and UPP under some conditions. Finally, we saw that standard methods (i.e. methods that do not operate in this two-stage manner) tend to have lower accuracy than two-stage methods.p-distance). The biological CRW datasets have generally lower p-distances than the harder simulated model conditions, and on these biological datasets, we saw that MAFFT-linsi was the most accurate method on three of the datasets and that MAGUS also was close to the two-stage methods in accuracy. Thus, the likely explanation for this difference may be the mutation rate, as the conditions where the two-stage methods had clear dominance over the standard methods had high rates of evolution as well as substantial fragmentation. Thus, it may be that two-stage methods may only be needed when datasets exhibit both these factors: substantial sequence length heterogeneity and also large p-distances.It is interesting however to consider the difference between trends observed on the five biological datasets and the simulated datasets. Specifically, for the simulated datasets, we saw generally that the four two-stage methods had reliably lower error than the standard methods, except when the mutation rate was low , and in the second stage it adds the remaining sequences into the backbone alignment. HMMerge builds on techniques in previous methods that use ensembles of profile HMMs to represent the backbone alignment, but does so by creating a new HMM with more edges than a standard profile HMM. As our study shows, this novel machine learning model enables HMMerge to improve on WITCH when adding very short sequences into the backbone alignment, and is otherwise competitive with WITCH .There are implications of this study for both biologists and algorithms developers. For the biologists, the implications are that when aligning datasets with fragmentary sequences, standard methods  may not provide good accuracy, and instead alignment methods that are designed for use on such datasets should be considered. Here we would recommend the use of a two-stage method, though the conditions under which each such method might provide an advantage over the others are not yet understood.For the algorithms designer, this study shows the potential benefits to be gained from novel uses of ensembles of profile Hidden Markov Models to represent backbone alignments. Furthermore, although WITCH and HMMerge both provide improved accuracy compared to UPP, which was the first method in this category, it seems very likely that additional algorithmic exploration could lead to improved accuracy and potentially faster methods. We hope that this study will lead to new algorithmic advances, in order to best improve alignment accuracy under conditions with sequence length heterogeneity, since these are increasingly common in biological datasets.vbad052_Supplementary_DataClick here for additional data file.


Reference-based approaches are thus blind to the dynamics of the accessory genome, as well as variation within gene order and copy number. With the widespread usage of long-read sequencing, the number of high-quality, complete genome assemblies has increased dramatically. In addition to pangenomic approaches that focus on the variation in the sets of genes present in different genomes, complete assemblies allow investigations of the evolution of genome structure and gene order. This latter problem, however, is computationally demanding with few tools available that shed light on these dynamics. Here, we present PanGraph, a Julia-based library and command line interface for aligning whole genomes into a graph. Each genome is represented as a path along vertices, which in turn encapsulate homologous multiple sequence alignments. The resultant data structure succinctly summarizes population-level nucleotide and structural polymorphisms and can be exported into several common formats for either downstream analysis or immediate visualization.The genomic diversity of microbes is commonly parameterized as SNPs relative to a reference genome of a well-characterized, but arbitrary, isolate. However, any reference genome contains only a fraction of the microbial  The code and accession numbers of data used are available on github at PanGraph, that can compare the genomes of hundreds of bacteria and summarize them as a graph. This graph represents the large-scale diversity that accumulated in the history of the collection of genomes and is the entry point for further analyses of their evolution.In addition to evolution through the accumulation of small changes of the genome that arise as errors during replication of their genome, bacteria change and adapt by taking up genetic material and duplicating or deleting parts of their genome. Together with the action of mobile genetic elements, such horizontal exchange and structural modifications are the dominant mechanism of evolution. However, despite its importance, how genome structure and content evolves is poorly understood and few tools are available that help to address this problem. We have developed a tool, During evolution, microbial genomes change by both local mutations and large-scale alterations . Local mpangenome has motivated the development of methods that account for substantial variation in gene content. However, though such approaches can accurately capture nucleotide polymorphisms within genes, they usually approximate structural polymorphisms as gene presence–absence relationships [complete diversity of a given genomic sample set.Recent advances in long-read sequencing have enabled the low-cost assembly of complete genomes at the quality of reference databases . The accionships  irrespecpangenome framework of microbial diversity to graphical models [In recent years, efforts have focused on generalizing the l models . At a hil models . In multWhile easy to conceptualize, the construction of pangenome graphs has proven computationally challenging. Coloured and compacted generalizations of the de Bruijn graph-based assemblers have been successively used to build graphs from large sequence sets , with tolocally collinear blocks [An orthogonal approach has been to formulate the inference of the pangenome graph as a multiple genome alignment. Some early methods relied on homology searches to locate syntenic regions, termed r blocks , and pror blocks . Howeverr blocks . The strr blocks , and to r blocks  or gene r blocks . By usinPanGraph, a Julia [PanGraph algorithm groups homologous sequences through nucleotide alignments alone, without relying on gene annotation. The resulting graph both compresses the input sequence set and succinctly captures the population diversity at multiple scales: from nucleotide mutations and indels to structural polymorphisms driven by inversions, rearrangements and gene gain/loss. Importantly, these two scales are naturally separated in our representation. The underlying graph data structure can be exported into numerous formats for downstream analysis and visualization in software such as Bandage [Here we present  a Julia  library  Bandage .PanGraph transforms an arbitrary set of genomes into a graph that simultaneously compresses the collection of sequences and exhaustively summarizes both the structural and the nucleotide-level polymorphisms. The graph is composed of pancontigs, which represent linear multiple-sequence alignments of homologous sequence found within one or more input genomes. Pancontigs are connected by an edge if they are adjacent in at least one input sequence; individual sequences are then recapitulated by contiguous paths through the graph. Pancontigs are directed, meaning their orientation in a path can be either 5′ to 3′ or vice versa. More details on the structure of our graph representation can be found in the Supporting Information (SI) sect. I available with the online version of this article.PanGraph’s overarching strategy is to approximate multiple-genome alignment by iterative pairwise alignment of graphs of subsets of sequences, in the spirit of progressive alignment tools [pancontigs between both graphs, and the order of pairwise alignments is determined by a guide tree.To construct a pangraph, the algorithm needs to find homologous sequence within and among all input genomes. nt tools . PairwisThe alignment guide tree is constructed subject to three design constraints: (i) similar sequences are aligned first, (ii) the similarity computation must have good scaling properties with the length and number of input sequences, and (iii) the resultant tree is balanced to maximize parallelism. To this end, we formulate the algorithm as a two-step process. The initial guide tree is constructed by neighbour-joining ; the paipancontig. Pairs of subgraphs are aligned in a post-order traversal of the guide tree. The identified homologous intervals of the pancontig are then merged, thereby creating shorter contigs that represent homologous sections of multiple input genomes  is stored in pancontig alignments, rather than in the graph structure, and no mergers are performed if they have length shorter than this threshold. For instance, when a merger would generate flanking contigs shorter than this threshold, the merging is performed but the alignment is extended to include these regions. The default value for this parameter is 100 bp.The parameter pancontigs defines a new pancontig, connected on both sides by edges to the neighbouring pancontigs of both inputs, and thus locally collapses the two graphs under consideration. At the nucleotide level, the pairwise alignment of two pancontigs maps the consensus of one onto the other; merging two pancontigs requires the application of the map onto the nucleotide-level diversity of the underlying multiple-sequence alignment. Once both sets of sequences are placed onto a common coordinate system, the resultant consensus sequence, and thus polymorphisms, are recomputed. This procedure can be viewed as an approximate multiple sequence alignment algorithm that aligns homologous parts without further investigating insertions in the two sub-alignments. This shortens considerably the time needed, but might introduce minor inconsistencies and artefacts in the alignments. After building the graph, these can be removed by performing a standard multiple alignment of sequences within each pancontig (see ‘polish’ command in the documentation and SI sect. IIB).At the graph level, the merger of two The above procedure is repeated until no alignments with negative energy remain. More details on the merging procedure and the effect of parameters can be found in SI sect. II.PanGraph guide trees are balanced binary trees that break the task into many independent sub-problems and thereby enable scalable parallelism, as shown in PanGraph can export the alignment as a GFA file, where each pancontig is represented as a segment and each genome as a path. This allows for visualization in software such as Bandage [pancontigs taking the place of putative gene clusters – that can be visualized directly by the PanX toolkit [PanGraph is published under an MIT licence with source code, extensive documentation, examples and instructions for installation available at github.com/neherlab/pangraph. All data and scripts used to validate PanGraph are available within the same repository.The constructed pangenome graph can be exported in a variety of file formats for downstream analysis and visualization. In addition to a custom JSON schema,  Bandage . Lastly, toolkit . PanGrapPanGraph as a function of input size, and its accuracy as a function of sequence diversity.As a first validation step we use generated synthetic data to quantify the performance characteristics of N and sequence length L utilizing a Wright–Fisher model [T=50 generations. In addition to nucleotide mutations that occur at rate µ per generation, we modelled inversions, deletions (respective rates 0.01 and 0.05 per generation), and horizontal sequence transfer that occurs with tunable rate h per generation per genome . The ancestral state for each sequence is tracked through each evolutionary event so that the true mosaic relatedness structure can easily be converted to a graph. The simulation framework is distributed within the PanGraph command line tools for external use.We simulated populations of size er model  evolved PanGraph’s computational complexity grows linearly with the number of input genomes once the number of genomes exceeds a certain threshold and parallelism can be exploited. We note that PanGraph scales approximately log-linear with average sequence length, as expected from the underlying algorithmic complexity of minimap2 [The algorithmic complexity was measured empirically by constructing pangenome graphs from data generated by simulating populations of varying size and sequence length. The mean and standard deviation of the run-time obtained from 50 iterations are shown in minimap2 . Benchmaµ and horizontal sequence transfer h. For each  pair we perform 25 different simulations, and build pangenome graphs using three different options for the alignment kernel: minimap2 [asm10 and asm20 options and mmseqs2 [independent of the rate of horizontal transfer h and thus underlying graph complexity. The predominant determinant of accuracy was the sample diversity, controlled by the mutation rate µ in our simulations . For low-diversity datasets, breakpoints are inferred with accuracy of few basepairs, while for highly diverged isolates most breakpoints are displaced by several hundreds of basepairs . The choice of alignment kernel influences the threshold diversity at which accuracy is lost, suggesting that inability to detect homology between diverged sequences is the reason.To be useful and informative beyond data compression of microbial genomes, the contigs and break-points of the reconstructed graphs should correspond, at least approximately, to evolutionary events in the history of the sample. We quantified PanGraph’s ability to accurately reconstruct the true graph by computing the displacement of the inferred breakpoints relative to their known locus stored from the evolutionary simulation (cf. SI Section IVB for details). We evaluate this displacement by generating datasets with different rates of mutation minimap2  with asm mmseqs2 . CriticaPanGraph of 100 bp . These differ by the alignment kernel used  or by the value of the pseudo-energy parameters α and β from eq. (1). Different alignment kernels are expected to reach different accuracy on datasets with different diversities (cf. α=β=0) is expected to remove the threshold divergence of 10 % associated with the standard values of parameters  at the cost of more fragmented pangenome graphs.Using ties cf. . MoreovePanGraph can build pangenome graphs comprising hundreds of isolates in a few hours . For these species the use of null energy parameters slightly increases merging and sequence compression, at the cost of slightly more fragmented graphs . Overall this benchmark showcases the capabilities and limits of PanGraph, and demonstrates the value of adapting the pseudo-energy parameter and choice of alignment kernel to the expected diversity of the dataset considered.For species other than E. coli dataset. The results are reported in We then explored how the properties of the pangraph scale with the dataset size. To do so, we built pangenome graphs from randomized subsets of isolates of increasing size from the The number and size of pancontigs scale sub-linearly with the number of isolates, with more than 50 % of the pangenome being included in the 10 % longest pancontigs. Core pancontigs have higher-than-average length. This is expected given that core genes tend to stay syntenic over large evolutionary distances. Adding more strains does not generate excessive fragmentation of these pancontigs, and their size remains of several thousand base pairs even as hundreds of strains are added. The size of the core genome does not decrease significantly with the addition of new strains, while the total pangenome size remains orders of magnitude smaller than the total size of all genomes included in the graph.PanGraph provides the marginalize command, which can be used to project a large pangenome graph on a small subset of strains, removing all the other paths and merging transitive pancontigs. This operation is computationally much cheaper than building a new graph for the subset of strains considered.The interpretation of a pangenome graph containing hundreds of strains can be challenging. To this end, it is often informative to inspect simpler sub-graphs comprising only a subset of isolates. However, building many such sub-graphs is computationally intensive. To facilitate this task K. pneumoniae dataset. We then picked 50 random pairs of strains from the same set and built two graphs for each pair: the graph obtained by marginalizing the complete graph on the pair  and have average size compatible with the default 100 bp precision threshold of PanGraph set by the value of Lmin (cf. k=21) divided by (1 − d)k, where d is the average pairwise divergence on core genes for the pair considered. This divisor corrects for k-mers on homologous sequence that are not shared due to mutations. The resulting distribution of shared sequence is in very good agreement with the fraction of segments that are shared on both graphs .We performed the same test on species from the other datasets, obtaining similar results on all species whose divergence is compatible with PanGraph, the tool presented here, is able to capture the structural and nucleotide diversity in both the core and accessory genome in a scalable way. The resulting data structure captures large-scale structural variation in the connectivity of the graph, while nucleotide-level variation is included in pancontig alignments.While single nucleotide differences in the core genome are straightforward to analyse with existing tools, these analyses miss the great majority of genetic diversity. The ability to rapidly align large sets of complete genomes of a bacterial species is crucial for the investigation of the processes governing microbial genome evolution and structure. PanGraph allows it to create pangenome graphs containing hundreds of isolates in a few hours on a eight-core machine. The size of pancontigs and the fraction of core sequence have good scaling properties with the number of isolates in the graph, indicating that PanGraph is able to successfully capture pangenome properties. By construction, PanGraph operates in a gene-agnostic way, being only based on sequence homology, and is thus robust to gene annotation errors.In our analysis we demonstrated the capabilities and limits of this tool, both on synthetic and real sequences. The efficient implementation of minimap2 alignment kernel, PanGraph is able to correctly merge genomes with up to 5 % average divergence. Sequences with higher divergence (up to 10–15 %) can be merged using the mmseqs2 alignment kernel, and tuning the α and β energy parameters (cf. eq. 1), trading off speed for sensitivity. For more diverged data sets, homology detection tools that use protein sequences would probably be necessary.One of the main limitations is the diversity of the input sequences. With the default We also provide the ability to quickly marginalize big graphs on a subset of strains, obtaining simpler graphs that can more easily be explored. Graphs can also be exported in different formats for further analysis and visualization.PanGraph are not limited to whole bacterial chromosomes. Plasmids and other mobile genetic elements (MGEs) play a fundamental role in microbial evolution [PanGraph can be used to explore this diversity. Some example applications on plasmids are available in PanGraph’s documentation.The applications of volution , includivolution . MGEs ofvolution . In thisPanGraph was not developed with this aim in mind, its outputs can be used as input for other tools that perform variant calling and genotyping using Pangenome Reference Graphs (PRGs), such as pandora [gramtools [PanGraph’s documentation), and can be transformed in a set of PRGs using make_prg . However, we did not directly test or benchmark these approaches in the current paper.Even if  pandora  and gramramtools . To thisPanGraph will prove a valuable tool, with the potential to spur new insights into microbial diversity and the processes by which bacteria adapt and change.We hope that Click here for additional data file.