Interrelating small molecules according to their aligned fragmentation spectra is central to tandem mass spectrometry-based untargeted metabolomics. Current alignment algorithms do not provide statistical significance and compounds that have multiple delocalized structural differences and therefore often fail to have their fragment ions aligned. Here we align fragmentation spectra with both statistical significance and allowance for multiple chemical differences using Significant Interrelation of MS/MS Ions via Laplacian Embedding (SIMILE). SIMILE yields spectral alignment inferred structural connections in molecular networks that are not found with cosine-based scoring algorithms. In addition, it is now possible to rank spectral alignments based on p-values in the exploration of structural relationships between compounds and enhance the chemical connectivity that can be obtained with molecular networking. Interrelating metabolites by their fragmentation spectra is central to metabolomics. Here the authors align fragmentation spectra with both statistical significance and allowance for multiple chemical differences using Significant Interrelation of MS/MS Ions via Laplacian Embedding (SIMILE). Such compound identification often requires determining if an experimental fragmentation spectrum matches an authentic standard with the annotated data.Tandem mass spectrometry is widely used in metabolomics experiments to hypothesize chemical structures. This is done by aligning fragment ions that share the same mass-to-charge ratio . The charged fragments are directly observed as m/z’s in the fragmentation spectrum, while the neutral fragments can be indirectly observed as neutral losses by subtracting (or adding) the fragment m/z’s from their precursor m/z. Therefore, when the assumptions hold as is often the case, two fragments from different molecules can be aligned if they share the same m/z or the same m/z difference with respect to their precursor m/z. More recently, a concept of hypothetical neutral loss is proposed to further align neutral losses from pairs of fragment ions, showing significantly improved correlation between spectral and structural similarities5. Alignment approaches on fragmentation data have also proven useful for mass spectrometry-based proteomics by identifying pairs of peptides that differ by multiple modifications8.Recently, alignment approaches have been developed that aim to yield scores that are a proxy for compound similarity rather than identity. For instance, GNPS-based molecular networking and NIST Hybrid Search both implement an alignment approach that is sensitive to compounds that differ by a single/localized structural difference(s)12. Recent implementations combining machine learning with in silico structural database searching allow exploring high-confidence identifications to explore biochemistry outside of known chemical databases13. Other tools have enabled the false-discovery rates from tandem mass spectra database searches to separate correct from incorrect hits through false-discovery rate assignments . While there are methods for estimating statistical significance for compound identification, to our knowledge, no method for calculating the significance of fragmentation-spectra alignments from a pair of spectra has been described15.Machine-learning approaches such as SIRIUS, CANOPUS, MS2LDA, and Spec2Vec also incorporate precursor ion neutral losses as a feature in their implementations17. These methods are fundamentally different from fragmentation-spectra-based cosine similarity in that they rely on substitution matrices describing the log odds of amino acids sharing common ancestry relative to random chance such as the PAM and BLOSUM matrices19. These approaches have not been widely applied to fragmentation data for two reasons: first, unlike protein- substitution matrices that are generally of size 20 by 20 (amino acids), a global substitution matrix for fragment ions would be infinite due to the infinite number of possible m/z values; and second, m/z values are only partially tied to chemical structure due to the one-to-many correspondence between m/z values and chemical structures. However, if restricted to a single pair of fragmentation spectra, a spectral graph-theoretic framework parameterized by their all-by-all m/z difference counts can generate finite, context sensitive, and mathematically consistent fragment ion similarity matrices based on average commute times20.Protein-sequence alignment algorithms like Needleman–Wunsch, Smith–Waterman, and BLAST yield alignments with statistical significance that are robust to multiple substitutions, insertions, and deletionsp-value estimation , an approach that leverages methods used for protein-sequence alignment to enable robust pairwise alignment of fragmentation spectra with ion Fig. . Rather We used tandem mass spectra from NIST20’s Small Molecule High Resolution Accurate Mass MS/MS Library to compare SIMILE to existing algorithms, determine strengths of SIMILE, and identify potential areas for improvement of SIMILE. The reference tandem mass spectra of compounds were filtered by unique InChIKey closest to 40-eV collision energy within ± 5 eV, resulting in a dataset comprising a single spectra for each of 24.5k molecules . These spectra were used in analysis without modification or further filtering.We compared “pairs of spectra” from the spectral dataset, and evenly sampled 100,000 pairs from each Classyfire compound class, with the requirement that at least one compound in each pair was from a specific compound class. Compound classes with less than 100,000 pairs were eliminated, resulting in 63 unique compound classes for negative ionization mode and 145 unique compound classes for positive ionization mode having at least 100,000 pairs for comparison. Rather than focusing on performance across compound classes, this approach simply served to remove unexpected bias in the dataset where a small number of compound classes might be overrepresented. This gave a final total for negative ionization mode of 6,300,000 pairs and for positive ionization mode 14,500,000 pairs for analysis.Since each pair of spectra is accompanied by a pair of corresponding chemical structures, for each ionization mode, we performed an all-vs-all calculation across all pairs to calculate the maximum common substructure (MCS) Jaccard similarity coefficient. MCS is a property of a pair of molecules computed based on their overlapping chemical structure. If you know the chemical structure of each molecule in a pair of molecules, then the MCS can be easily calculated. This was used to define a rubric of chemical similarity in which an MCS less than 0.35 is considered “not similar”, between 0.35 and 0.45 to be “low similarity”, 0.45–0.7 to be “medium similarity”, and greater than 0.7 to be “high similarity”. These cutoffs are based on the finding that, across all pairs of molecules, the average MCS plus one standard deviation was 0.4. The distribution of MCS values across unfiltered pairs of molecules can be seen in Fig. 21. Using the MCS associated with each pair of spectra/compounds as the ground-truth structural similarity for each pair, we sought to test how well each algorithm could convey structural similarity from spectral similarity. The absolute ute Fig.  and relaute Fig.  of returThe parameters chosen for each spectral similarity algorithm are such that an experienced practitioner would be comfortable choosing them. In addition, each algorithm returned approximately the same percent of “not similar”, or false positive, and one can see that the algorithms all have comparable abilities to return a relative number of structurally similar results. As can be seen in Fig. Using these parameters for each algorithm for this analysis, SIMILE was found to identify more structurally similar pairs than all other algorithms in positive and negative ionization modes Fig. . More imTo further understand the degree to which SIMILE can find more pairs of structurally related molecules, a synthetic dataset was created consisting of 20 flavonoids and 20 indoles randomly selected from the Berkeley Lab public GNPS reference library. Molecular networks were created using either GNPS or SIMILE scoring  would aid this case and potentially many others.Shown in Fig 26. However, substitution/similarity matrices also appear in many other contexts, including text, speech, video, or even mathematically abstracted signals30. Once a similarity matrix is chosen, widely known methods can be used to calculate optimal alignments between pairs of signals32. To this end, we have developed a method of generating similarity matrices for fragmentation spectra to associate fragment ions by the similarity of their fragmentation paths. We found that our alignment method, SIMILE, yields different and typically more associations than cosine-based scoring algorithms and significant alignment scores generated by SIMILE correspond to compound structural similarity. SIMILE is currently limited to analysis of protonation/deprotonation, which is certainly a limitation. We see that developing approaches to comprehensively addressing additional adducts is an important direction for future research.Spectral similarity applications, like spectral networking, benefit from increasing connections between truly similar metabolites. One way of accomplishing this is by using a scoring method that is robust to arbitrary structural differences and provides statistical significance. In protein-sequence alignment, this is achieved by using substitution matrices with alignment algorithms that generate scores according to known distributionsp-values are capturing aspects of how similar compounds fragment similarly. For modified cosine, the number of matching ions acts as a heuristic to approximate the significance of aligning/scoring the similarity of two spectra; in contrast with SIMILE, there is a mechanistic calculation of significance using a framework based on fragment ion substitutability. Likely, there will be classes of molecules that are more appropriate for cosine-based scoring than SIMILE-based scoring. Consequently, it makes sense to use SIMILE as an algorithm to accompany traditional scoring approaches (like modified cosine).As can be seen in Figs. 33. The number of paths connecting two fragment ions increases when the number of total fragment ions increases. Likewise, the “length” of a path connecting fragment ions decreases when the frequency of m/z differences in the path increases. In other words, two fragment ions are similar if they are connected by many paths exhibiting high- frequency m/z differences.The underlying SIMILE distance measure for comparing fragment ions is closely related to Euclidean Commute Time Distance (ECTD), which has the property of decreasing with the number of connecting paths and increasing with the “length” of connecting paths33. We use a normalized and directed graph laplacian as the SIMILE similarity matrix to ensure that similarity scores in the fragment ion similarity matrix are normalized. We can then score fragmentation-spectra pairs by using a dynamic programming algorithm to align their fragment ions according to similarity scores32. This in turn mirrors how pairs of protein sequences can be scored by aligning their residues according to a substitution matrix.Saerens et al. prove that the pseudoinverse of the graph laplacian acts as a covariance matrix with respect to ECTDFor much of metabolomics research , it is necessary to use intermediate spectral similarity scores. Interrelating fragmentation spectra with intermediate scores in SIMILE is aided by a significance estimate; without statistical significance, intermediate similarity scores are to some degree uninterpretable. For example, intermediate scores could imply moderate structural similarity or tentative high similarity. Interpretation of intermediate scores has a direct effect on how researchers prioritize metabolites of interest and ultimately on the outcome of their research. As such, SIMILE significance estimation assists in deriving biological insight from metabolomics data when confronted with underexplored biochemistry. The significance of SIMILE alignments is calculated via a Monte Carlo permutation test with alignment score as the test statistic. It is important to note that significant SIMILE alignment of fragmentation spectra does not necessitate compound structure similarity. This is similar to how protein sequences can have significant alignment but yield different tertiary structures or functions. Likely, a significant SIMILE alignment indicates that two molecules fragment similarly, not that they necessarily have similar structures. Nevertheless, the results presented here show that significant fragmentation-spectra alignments often correspond to moderate-to-high structural similarity.p-value and an alignment between fragments.While SIMILE is a very promising approach for scoring pairwise spectral alignments, since this is the first application of scoring metabolite-fragmentation spectra using a similarity matrix, close attention must be applied. We recommend complementing SIMILE with the use of cosine-based scoring for compound identification. There is a massive amount of literature on cosine-based scoring, is well established, and has been in use for many decades. Since we find that SIMILE often works for cases where cosine-based scoring fails, using both approaches will provide more identifications. In addition, SIMILE provides a m/z difference in Fig This said, it is likely that the parameters used in this study to compare alignment algorithms could be further optimized to improve performance. While beyond the scope of this work, this would likely provide additional insights on how the various approaches can be best used as part of metabolomics workflows. However, such optimizations almost certainly result in trade-offs in performance, for example, improving specificity vs. number of hits, both of which can be desirable objectives. In addition, from the m/z differences in the alignment, one can glean structural clues regarding the differences between the molecules. For example, the predominant Here we describe SIMILE, a metabolomics tool immediately useful to complement existing widely used approaches with the potential to open up a completely new area for research in fragment ion similarity matrices with significance estimation. This approach provides a scoring and significance framework for discovering relationships between molecules that would have been dismissed with existing approaches. As such, using SIMILE as an algorithm to accompany traditional scoring approaches (like modified cosine) should lead to increased discovery in multiple fields, including compound and pathway discovery, and other useful applications of spectral networking.https://github.com/biorack/simile) as the release “v1_manuscript-submission”. Figure p-values calculated—Hub Link) where spectra from [M + H] + adducts for N-acetyl-5-hydroxytryptamine and 5-hydroxy-DL-tryptophan are scored.The SIMILE algorithm calculates spectral similarity by aligning substitutable fragments, identification of the significance of their alignment; and scoring the degree to which two spectra are correlated. The underlying mathematical framework for these calculations is described below. Python code for each step is available in the GitHub repository  space dependent on the frequency and connectivity of the m/z differences between them.For this reason, we use the average “commute time” of fragment ions as our distance measure that considers all paths weighted by p-value exchanges fragment ions between the A and B and so the fragment ions must be projected into the same space.We rely on the variance–covariance matrix with respect to ECTD space for the remainder of the SIMILE algorithm because it forms a valid kernel , which we denote the SIMILE similarity matrix. When comparing fragmentation spectra A and B, it is important to note that intraspectral  and interspectral  comparisons are considered in tandem by forming a square (A + B) by (A + B) similarity matrix. This is critical, because our In order to quantify the similarity of fragmentation spectra A and B, the SIMILE similarity matrix is used in conjunction with a dynamic programming algorithm related to those used for pairwise alignment of biological sequences. For the sum of the similarities in the alignment, we denote the SIMILE alignment score and use as a proxy for compound similarity.m/z order-based alignment of fragment ions exist such as maximum weight matching , there is a reason as to why one may prefer alignment. Because SIMILE projects fragment ions into a space dependent on the frequency of m/z differences and not the magnitude of those differences, it is possible for similar fragment ions to have very different masses. However, one would naturally expect large mass differences to imply comparatively less structural similarity than smaller mass differences. By using alignment instead of maximum weight matching, we are in effect forcing the score to address this trade- off albeit stochastically. While alignment is not guaranteed to appropriately match similar fragment ions  where there are k permutations of n-by-m similarity matrices, three key optimizations in the implementation details confer significant speedup by enabling vectorized operations. This effectively moves k times max of the operations out of Python and into highly optimized compiled C code. One, because the gap penalty is zero and only the alignment score is needed , we can replace the O(nm) dynamic programming implementation for alignment with a single-loop iterating over min in Python to greedily compute the alignment score using alternating vectorized maximum and rolling maximum operations. Two, the k-by-n-by-m array consisting of “stacks” of permuted similarity matrices is constructed by broadcasting the similarity matrix using k random permutation indices that minimize needless data copying. Three, because permuted similarity matrices are stacked, the alignment of each stack is independent of one another, and the underlying alignment-score operation is partially vectorized, we extend the vectorized alignment- score operation to operate on each stack in a vectorized fashion. On a modern Linux workstation and at a p-value of 0.0001, we found the average compute time to be 20 milliseconds for SIMILE comparisons within NIST20 without any parallelization  difference of the concatenated m/z list is stored in an m + n by m + n m/z difference matrix, D.  in the top-left m by m, Y minus Y  in the bottom-right n by n, X minus Y in the top-right m by n, and Y minus X  in the bottom-left n by m. In Fig. m/z differences, frequencies of specific differences, and ion similarity scores comparing the two hypothetical molecules, but all four quadrants are used in the calculation. For each element Dij of the top m by m + n quadrants of D, the m/z differences in the block that are within a given m/z tolerance window of Dij are counted and element-wise assigned to the m/z difference frequency matrix, C p−1/2. Finally, the m/z similarity matrix S is calculated by taking the Moore–Penrose pseudoinverse of (L + LT)/2. SXX and SYY are defined as the top-left m-by-m quadrant and the bottom-right n-by-n quadrant of S, respectively. Likewise, SXY and SYX are defined as the top-right m-by-n quadrant and the bottom-left n-by-m quadrant of S, respectively.To calculate a similarity matrix from the 32. It is defined by the recurrence relationA = 0 for all i and A = 0 for all j. The terminal value of A is the alignment score and tracing back the elements of S, Bhich contribute to this score, yields the alignment.The alignment and alignment score are calculated using the dynamic programming approach described by Needleman and Wunsch for sequence alignments, but with a fixed gap penalty of zerom/z values are exchangeable between m/z-ordered fragmentation spectra X and Y only if they generate fragmentation spectra X′ and Y′ that are also m/z ordered. This null hypothesis corresponds to the assumption that exchanging interspectral similarity scores in SXY and SYX with intraspectral similarity scores in SXX and SYY improves alignment scores so long as m/z order is preserved in the resulting SX′Y′ and SY′X′.The significance of the alignment is calculated via a permutation test with the alignment score used as test statistic under the null hypothesis that S to calculate the p-value, we use Monte Carlo testing with early stopping to asymptotically approach the true p-value with bounded and known error35. In practice, this is done by first generating a random permutation of indices that index the concatenated m/z list, such that the first n entries are m/z ordered and the last m entries are m/z ordered, which implicitly generates hypothetical fragmentation spectra X′ and Y′. This permutation of indices is then used to permute the rows and columns of S symmetrically. The alignment score is calculated with the alignment algorithm described above. The p-value is then the probability that a random alignment score from the empirical distribution is greater than the observed alignment score or one out of the number of iterations, whichever is greater  library. These spectra are acquired on a variety of instruments . The MatchMS python package version 0.6.2 was used to calculate the modified cosine spectral similarity score and determine the number of matching ions21. Each spectrum was square-root intensity scaled and further normalized using the MatchMS function “normalize_intensities”. Pairs of spectra were evaluated with the modified_cosine.pair function, a scoring algorithm that includes precursor loss masses and intensities. A score cutoff greater than or equal to 0.6 and a number of matching ions greater than or equal to 6 were used to identify similar spectra.In general, the following score cutoffs for each algorithm are based on the published parameters. For CSS and SIMILE, the development teams worked together to select parameters for the comparisons. As is stated above, for SIMILE, a score cutoff greater than or equal to 0.7, a 5. For each MS/MS spectrum, top-30 fragments (sorted by intensity) were reserved, and peak intensities were subject to normalization and square-root transformation. The maximum number of hypothetical neutral losses (HNLs) was set to 100, and the minimum HNL mass was set to 36. Both CSS score and CSS match number were output to optimize the cutoffs for similar spectra. A score cutoff greater than or equal to 0.6 and a match number cutoff greater than or equal to 40 was used to identify similar spectra.The Core Structure-based Search (CSS) algorithm was rewritten in C# for large-scale spectral comparisonGNPS-aligned cosine spectral similarity was written in C++ for large-scale comparisons and run externally of GNPS’ molecular networking to benchmark the scoring function in isolation of molecular networking. This was done specifically because the molecular networking workflows introduce other heuristic processing algorithms that increase the interpretability of the molecular networks that interfere with benchmarking. MS/MS spectra were aligned and scored with a fragment tolerance of 0.5 Da. A score cutoff greater than or equal to 0.6 and a number of matching ions greater than or equal to 6 were used to identify similar spectra.p-value greater than 0.05 for SIMILE. This is a more strict threshold than was used in the NIST20 data. Finally, the network topology was constrained first to preserve only the 10 top-scoring edges and second to constrain subgraph size to 100 nodes or less. This resulting SIMILE network was merged with the existing network based on GNPS-cosine scores. The existing GNPS network was created using the same topological filters as were used for SIMILE.Following the calculation of all-by-all SIMILE scores, filtering both by score cutoffs and topology is required to make an interpretable network. The all-by-all scores were filtered to remove scores less than 1.0 and s, of the overlapping bonds given by s = N / ((NA + NB) − N) where N is the number of overlapping bonds between the pair of molecules A and B. NA and NB are the number of bonds in each of the molecules A and B, respectively. The alignment of a connected block between each pair of molecules is done using the RDKIT python package with a timeout of 1800 seconds and ringMatchesRingOnly set to False37. One pair of compounds timed out and was discarded from further analysis. Here we refer to the MCS Jaccard similarity of bonds as MCS.The chemical similarity metric used in this paper is the Jaccard similarity coefficient, Further information on research design is available in the Supplementary InformationReporting Summary


In 2020 and 2021, more than 1.5 million SARS-CoV-2 sequences were submitted to GenBank. The initial version (v1.0) of the VADR  software package that GenBank uses to automatically validate and annotate incoming viral sequences is too slow and memory intensive to process many thousands of SARS-CoV-2 sequences in a reasonable amount of time. Additionally, long stretches of ambiguous N nucleotides, which are common in many SARS-CoV-2 sequences, prevent VADR from accurate validation and annotation.VADR has been updated to more accurately and rapidly annotate SARS-CoV-2 sequences. Stretches of consecutive Ns are now identified and temporarily replaced with expected nucleotides to facilitate processing, and the slowest steps have been overhauled using blastn and glsearch, increasing speed, reducing the memory requirement from 64Gb to 2Gb per thread, and allowing simple, coarse-grained parallelization on multiple processors per host.https://github.com/ncbi/vadr) for local installation and use.VADR is now nearly 1000 times faster than it was in early 2020 for processing SARS-CoV-2 sequences submitted to GenBank. It has been used to screen and annotate more than 1.5 million SARS-CoV-2 sequences since June 2020, and it is now efficient enough to cope with the current rate of hundreds of thousands of submitted sequences per month. Version 1.4.1 is freely available ( The coronavirus disease 2019 (COVID-19) pandemic caused by the severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) has resulted in widespread illness, death and economic disruption . The pubThe GenBank database maintained by the National Library of Medicine’s (NLM) National Center for Biotechnology Information (NCBI), is a comprehensive genetic sequence database in the public domain . GenBankhttps://submit.ncbi.nlm.nih.gov/sarscov2/) for data submitters to facilitate sequence and associated metadata upload [Due to the importance of SARS-CoV-2 data, GenBank created a dedicated and specialized submission portal workflow  software package , which palerts by the program. For example, one type of alert, with internal alert code cdsstopn, is reported if an early in-frame stop codon is detected in a predicted CDS region during the alignment stage, and another (fstukcfi) is reported if a potential frameshift is detected in a coding region. A subset of alerts, including cdsstopn and fstukcfi, are fatal in that they cause the sequence to fail and prevent it from automatic entry into GenBank. There are more than 70 different possible types of alerts, about 50 of which are fatal . VADR processing identifies potentially problematic sequences and information on failing sequences is sent back to submitters who are encouraged to check their data and resubmit with supporting information [At each stage, different types of unexpected situations can be detected and reported as tal  available in early 2020 when the COVID-19 pandemic started. The relatively long length of the genome means that the classification, coverage determination and alignment stages are too slow for practical use on thousands of sequences because the running time of those stages empirically scale with the square of the genome length or worse. Processing a single full length SARS-CoV-2 sequence using VADR 1.0 takes approximately five minutes and processing all GenBank SARS-CoV-2 sequences from 2020 and 2021 would take more than 6100 CPU days .To accelerate processing of SARS-CoV-2 sequences, the slowest steps were modified to use blastn  .To reduce the amount of memory required and to enable further acceleration via multi-threading, the memory expensive  package , 19 for -r option).To better handle long stretches of Ns, a pre-processing step was added that identifies regions of Ns and, when appropriate, temporarily replaces them with the expected nucleotides from the reference model sequence for purposes of validation and annotation  as well as the boundaries of all hits to that model. This single blastn step is roughly 200 times faster than the two cmsearch runs for typical SARS-CoV-2 sequences. The more similar the input sequence is to the reference model sequence, the less likely it is that replacing cmsearch with blastn will change the resulting alerts or annotation, and so this approach is well-suited for typical SARS-CoV-2 sequences which are highly similar to the NC_045512 reference.The classification and coverage determination stages of VADR annotation are typically performed by two separate rounds of the  package , 21, fircmalign program. For SARS-CoV-2 (size 30kb), the amount of RAM required for cmalign, when using its default banded dynamic programming algorithm [-s option, this stage is modified to use the top scoring blastn alignment already computed from the classification and coverage determination stage. An alignment seed derived from that blastn alignment becomes fixed and only sequence regions outside the seed region (if any) are aligned in a separate step. In general, the more similar each input sequence is to the reference model, the longer the seed alignment will be, making this approach well suited for typically highly similar SARS-CoV-2 sequences. The seeded alignment strategy is depicted in The sequence alignment in the alignment stage of VADR v1.0 is performed by Infernal’s lgorithm , can be glsearch program of the FASTA package [glsearch alignment for the 5’ end of the sequence with 100nt overlap with the 5’ end of the seed is computed. Analogously, if the seed does not end with the final sequence position, a glsearch alignment for the 3’ end of the sequence with 100nt overlap with the 3’ end of the seed is computed.If the seed alignment includes the entire sequence, then the alignment stage is complete. This is the case for about 96% of sequences from 2020 and 2021 . If not, package , 19 whicglsearch and seed alignments are determined to be consistent, the fixed seed alignment is then joined with the glsearch alignments of the 5’ and/or 3’ ends by simply concatenating the alignments after removing the overlapping regions from the seed alignment. The 5’ subsequence glsearch alignment and seed alignment are considered consistent if the 3’-most overlapping nucleotide of the 5’ subsequence aligns to the same model position in both the glsearch and seed alignment. And, likewise, the 3’ subsequence glsearch alignment and seed alignment are considered consistent if the 5’-most overlapping nucleotide of the 3’ subsequence aligns to the same model position in both the glsearch and seed alignment. If either 5’ or 3’ glsearch alignments are not consistent with the seed alignment, a non-fatal unjoinbl alert is reported for the sequence and then the entire sequence is realigned using glsearch. In practice, this is rare, occurring in 6.6% of sequences for which glsearch is used, and less than 0.3% of total sequences in the ENA test set of 14,912 sequences from If the blastn alignment, which can include gaps (either an insertion or deletion in the sequence relative to the reference model), where each ungapped region of sequence between two gaps is referred to as an ungapped segment below. This seed is shortened in some situations. If the seed includes a gap at a position that is within a CDS start or stop codon in the reference, then the seed is shortened to its longest ungapped segment. This shortening is performed because blastn tends to place gaps differently than glsearch does in some situations that lead to unnecessary downstream fatal alerts if those gaps are in start or stop codons. If no gaps in the seed occur within start or stop codons, the seed is shortened by removing 5’- and 3’-terminal ungapped segments from both ends until the following two criteria are met:glsearch regions.the 5’- and 3’-most terminal ungapped segments either include the sequence terminus  or have a length of at least 100nt, which corresponds to the overlap length between the seed and all ungapped segments have a minimum length of 10nt.The alignment seed is defined as the top-scoring unjoinbl alert triggering the relatively slow step of glsearch realignment of the full sequence. Criteria 2 is enforced because in gap-rich regions glsearch creates alignments that are less likely than blastn alignments to result in unnecessary downstream alerts .Criteria 1 is enforced because if a terminal segment has a length less than 100nt then there will almost certainly be a gap in the overlapping region of the seed and terminal aligned regions, which will increase the chance of an As shown in v-annotate.pl has an optional pre-processing step enabled with the -r option that identifies stretches of Ns and temporarily replaces them, if possible, with the expected nucleotides from the homologous positions in the reference model sequence. The validation and annotation of the sequence then proceeds with the modified sequence. If the sequence passes, the original sequence that includes Ns is deposited into GenBank, and feature annotation is “trimmed” to indicate which features begin and/or end with one or more Ns. Trimming involves changing the coordinates of the feature start/stop positions to the first/final non-ambiguous nucleotide. The N-replacement strategy is depicted in To address this, blastn for each input sequence. All hits are then sorted by input sequence start position. In the rare situation that one hit is completely spanned by another, the lower scoring hit is discarded. The missing regions in both the input sequence and reference model sequence not covered by any of the non-discarded hits are then evaluated to determine if they satisfy the criteria listed below. The evaluation of each missing region between two hits involves comparing the missing sequence region S with the corresponding missing reference model region M. S and M are checked to see if:S is at least 5 nucleotides.the length of S is at least 0.25 if S contains the first or final nucleotide in the sequence, or at least 0.5 if it does not.the fraction of N nucleotides in S and M are equal length.The N-replacement step begins by running --r_minlen), and criteria 2 .Command line options exist to change the thresholds in criteria 1 , criteria 5 (--r_diffminnonn) and criteria 6 (--r_diffminfract).Command line options exist to change the thresholds in criteria 4  a 5’-flush alignment in which the first nucleotide of S is aligned to the first nucleotide of M and a gapless alignment is extended towards the 3’ end for L positions (where L is the shorter of the lengths of S and M) with any extra positions in either S or M aligned to gaps at the 3’ end of the alignment; and (ii) a 3’-flush alignment in which the final nucleotide of S is aligned to the final nucleotide of M and a gapless alignment is extended towards the 5’ end for L positions with any extra positions in either S or M aligned to gaps at the 5’ end of the alignment. The fraction of matches between observed non-N nucleotides in S and expected nucleotides in M is determined for the 5’-flush and 3’-flush alignments and if either is at least 0.75, then criteria 6 is met.Because S are replaced by the corresponding expected nucleotides in M .When criteria 1, 2 and 3 are met, any N nucleotides in S are still replaced by the corresponding expected nucleotides in M but the correspondence is not trivial due to the difference in length between S and M. In this case, if the 5’-flush ‘alignment’ yielded a higher  fraction of matches in non-N nucleotides between S and M, then that alignment is used to determine the corresponding nucleotides for replacement of Ns. If the 3’-flush alignment yielded a higher fraction of matches, then that alignment is used.Alternatively, when criteria 3 is not met but criteria 4, 5 and 6 are met, any N nucleotides in glsearch program and making sufficiently small partitions in version 1.4.1, the memory requirement is reduced to 2Gb per CPU in practice making parallelism across multiple CPUs practical. When run with the --split --cpu <n> options, v-annotate.pl runs in a special mode that first splits the input sequence file into x smaller files, each with about 10 SARS-CoV-2 sequences , and processes each file independently with a separate execution of v-annotate.pl (this time without the --split and --cpu options) on <n> CPUs in parallel requiring a total of <n>*2Gb of total RAM on the host machine. When all of the sequences have been processed, the output from the x runs of v-annotate.pl are then merged into the final output files. The final output is identical to what would be obtained if the program was run without parallelization on the full input sequence file (e.g. without the --split and --cpu options). Because information on each sequence  is kept in memory by the program, the amount of RAM required for this information scales with the total length of all sequences in the input sequence file. This is why the size of the x files is limited to 300kb, which empirically reduces the required memory to 2Gb RAM per CPU. The final step that merges the output of the x runs is performed in a memory efficient manner that does not require keeping data from all sequences in memory. In practice, GenBank uses the --split --cpu 8 options when running v-annotate.pl to parallelize over 8 CPUs.VADR processes each sequence independently, so splitting up the sequence file into multiple partitions and processing each partition independently on a single CPU is a simple and effective parallelization strategy on multi-processor machines. With version 1.0, this strategy was impractical on typical hardware because the alignment stage would have required up to 64Gb of RAM per CPU and so would have only been possible on extremely high memory host machines. Using the memory-efficient v-annotate.pl in the GenBank submission portal pipeline. Terminal ambiguous nucleotides including Ns at the beginning and end of the sequences were removed prior to testing, such that the first and final nucleotide of each sequence are non-ambiguous, because the GenBank submission portal trims sequences in this way prior to VADR processing.To characterize the efficacy of the N-replacement and seeded alignment strategies, VADR v1.4.1 was tested on a random sample of 14,912 SARS-CoV-2 sequences deposited in the the ENA database between July 1, 2020 and December 31, 2021. This dataset is composed of 1000 randomly selected sequences from each month in which at least 1000 were published in ENA, and all sequences from every other month. Only four SARS-CoV-2 sequences were published in ENA prior to July 2020 and these were not included. ENA sequences were chosen for testing because all GenBank sequences have been pre-screened by VADR, whereas ENA does not include VADR as part of its submission pipeline, and so ENA sequences represent a more realistic sample of submitted sequences that would be input to blastn-based N-replacement strategy. After N-replacement, the alignment seed covers 99.6% of each sequence on average, and is the complete sequence for 96.4% of sequences. The statistics are generally consistent over the 18 month period, with only slight month-to-month variability.blastn alignment) but used cmalign instead of glsearch to align regions outside the seed and did not allow multi-CPU parallelization.glsearch and the --split option on a single CPU yielded about a 130-fold speedup relative to v1.0 and reduced the required RAM to 2Gb. Parallelization on multiple CPUs using the --cpu option resulted in further acceleration, decreasing the number of seconds per sequence to 0.13 seconds (2400-fold speedup vs v1.0) when run on 32 CPUs. The GenBank submission portal currently runs VADR v1.4.1 on 8 CPUs in parallel, which processes SARS-CoV-2 sequences nearly 1000 times faster than VADR v1.0 did in early 2020. These data show that the combination of N-replacement and seeded alignment is highly effective on SARS-CoV-2 sequences from 2020 and 2021.The N-replacement and seeded alignment strategies alone offered about a 7-fold speedup in v1.1 versus v1.0, but did not lower the high 64Gb RAM requirement. In v1.4.1, combining those two strategies with glsearch, is used to process the 14,912 sequences, only 3892 sequences pass and 11,020 fail. If v1.4.1 is used with only N-replacement (-r option), 13,436 sequences pass and 1,576 sequences fail, indicating the importance of N-replacement on allowing N-rich sequences to pass. Alternatively, if v1.4.1 is run as recommended, using N-replacement, seeded alignment, and glsearch , 13,430 sequences pass , and 1,582 sequences fail. Of the six additional sequences that fail, four fail due to low similarity in the first 10 nucleotides  one fails due to a short potential frameshift (OU218955.1), and the other fails due to uncertainty in a mature peptide boundary (OU923822.1). All six of these cases are arguably acceptable failures as they are situations that warrant manual examination prior to publication in GenBank. Of the other 14,906 sequences with the same pass/fail outcomes between v1.4.1 with recommended options and v1.4.1 with only N-replacement, only 42 (0.3%) differ in terms of annotation of one or more features, often by a single nucleotide at the start or stop boundary of a single feature. The low number of differences in pass/fail outcomes  and feature annotations show that the seeded alignment and glsearch acceleration strategies have only a small impact on pass/fail outcomes and annotation.The data in GenBank began using VADR in 2018 for automatic validation and annotation of norovirus sequences , and latBecause the growth in sequence data from tens of sequences a month to thousands per month occurred relatively quickly over the course of just a few months in early 2020 , the speblastn, glsearch and blastx. Reimplementations of the tasks performed by these programs would be burdensome, and unlikely to match the efficiency of the relatively optimized existing implementations, likely slowing down processing. However, as SARS-CoV-2 continues to mutate, the current N-replacement strategy may prove too ineffective for continued use and need to be modified or overhauled, potentially by a radical change such as better tolerance of Ns instead of replacement. One obvious way the current strategy could be modified is if a more accurate alignment of the missing sequence and model regions were computed when they differ in length, using a Needleman-Wunsch-like algorithm [Though effective, the N-replacement strategy is complex and not perfect as it does not replace all Ns in sequences  has detailed instructions, including a tutorial, on using VADR for SARS-CoV-2 analysis, as well as information on when each version of VADR was used for automated GenBank sequence processing.The acceleration heuristics described here were not the only changes made to VADR SARS-CoV-2 processing in 2020 and 2021. In total, 14 releases of VADR were made between January 2020 and January 2022 (v1.0.2 to v1.4.1). The VADR GitHub Wiki (not cause a sequence to fail but rather to cause those features to be annotated as a miscellaneous feature (misc_feature) instead. Since February 19, 2021 this strategy has been used for the ORF8 CDS feature. On August 5, 2021, it was extended to the ORF3a, ORF6, ORF7a, ORF7b and ORF10 CDS features, as well as the stem loop from NC_045512 positions 29728 to 29768. On December 2, 2021, GenBank processing reverted to using a single model because the common mutations that motivated the addition of the three alternative models would no longer cause a sequence to fail due to the miscellaneous feature failover, and because using the single NC_045512 model was generally leading to more accurate, consistent, and justifiable results on the breadth of sequence diversity that was being observed at the time. The results of all tests reported here were performed with the single NC_045512 model, but the heuristics work similarly for alternative models. In the future, as SARS-CoV-2 continues to undergo mutations, it may be necessary to complement the NC_045512 model with additional models, for example for novel variants. If that happens, the heuristics here should work well in principle but may need to be refined based on attributes of the new sequence data.Between January and April 2020, three alternative reference model sequences were added to the set of VADR models, including one for each of the B.1.1.7  and B.1.525 variants and one with a deletion at NC_045512 reference position 28254. These models were added to allow sequences with certain natural mutations relative to NC_045512 to pass that would have otherwise failed due to one or more fatal alerts if only the NC_045512 reference model was used. In February 2021, v1.1.3 of VADR introduced the capability of allowing certain fatal alerts for specific features to https://github.com/ncbi/vadr) for users to download and run locally, enabling them to screen their own data prior to submission to GenBank or for other purposes.The improvements to the speed and memory efficiency of VADR described here for SARS-CoV-2 processing were necessary for GenBank to keep up with the high volume of sequence submissions in 2020 and 2021. Processing the more than 1.5 million GenBank sequences with the version that existed in January 2020 (v1.0) would have required more than 15 CPU years. With the current implementation in the GenBank SARS-CoV-2 processing pipeline, VADR v1.4.1 running in parallel on 8 CPUs, the same set of sequences would require roughly one week to process, and this could be further sped up by additional parallelization with more CPUs and/or additional hosts. VADR is freely available (


Information provided by high-throughput sequencing platforms allows the collection of content-rich data about biological sequences and their context. Sequence alignment is a bioinformatics approach to identifying regions of similarity in DNA, RNA, or protein sequences. However, there is no consensus about the specific common terminology and representation for sequence alignments. Thus, automatically linking the wide existing knowledge about the sequences with the alignments is challenging.The Sequence Alignment Ontology (SALON) defines a helpful vocabulary for representing and semantically annotating pairwise and multiple sequence alignments. SALON is an OWL 2 ontology that supports automated reasoning for alignments validation and retrieving complementary information from public databases under the Open Linked Data approach. This will reduce the effort needed by scientists to interpret the sequence alignment results.SALON defines a full range of controlled terminology in the domain of sequence alignments. It can be used as a mediated schema to integrate data from different sources and validate acquired knowledge. Sequence alignment is a well-known bioinformatics approach to identifying regions of similarity in DNA, RNA, or protein sequences. Finding the optimum alignment of two or more biological sequences allows for identifying highly-conserved regions resulting from functional, structural, or evolutionary relationships between the sequences. Thus, these techniques aim to compare nucleic sequences  or amino acid sequences (protein) across species or within a genome to establish regions of similarity. Software tools can produce these alignments in different formats, such as those generated by CLUSTAL W  or MAFFTScientific workflows may use the sequence alignment results as inputs for other analyses. For example, several computational biology techniques, such as sequence homology  and phylMoreover, with the development of high-throughput platforms, a boundless amount of biological data is available, which comprises the sequences themselves  and other biologically relevant information. This information may include the name of the species (organism), a brief description of the sequence and the sequence type . Some other useful information can be derived from the former, such as metrics about the alignment quality using score functions. Integrating such information with the sequence alignment information would help researchers find relevant data and enhance the quality of the interpretation of the retrieved results. The enormous potential of ontologies allows a wide range of applications in integrative research. In this sense, ontologies play a crucial role in data integration and data management in the context of life sciences and biomedical research. Linked Open Data Cloud   and part_of (partitive relation). Each of these concepts can then be characterised according to attributes. For example, MAO defines an associative relation, is_name, which allows specifying a user-defined name for a given sequence to provide a further understanding of such sequence. It also allows the integration of 3D structural information about proteins. However, as of 2015, the ontology is tagged as deprecated/inactive in the OBO Foundry website [Thompson et al.  describe website .Furthermore, the MAO ontology is only available in OBO format, which can not take advantage of automated reasoning for ontology validation and the search for subsumption hierarchies. However, it can be translated to OWL (as OBO can be considered a subset of OWL). Due to the nature of OBO, most knowledge is represented as labels, lacking OWL entailments related to reasoning. Therefore, this ontology is a simple approach to representing this kind of knowledge, limiting its use to the presentation, interoperability, and data sharing between multiple alignment protocols.KinView  is a visThis paper presents an approach that reuses MAO conceptualisation and extends it with additional OWL, mainly object and datatype properties and SWRL axioms, to enable data validation.Determine the domain and scope of the ontology SALON is focused on the description and formalisation of biological sequence alignments.Consider reusing existing ontologies We have reviewed the OBO Foundry ontologies seeking existing ontologies that match SALON scope and intended application. We did not find any other related ontology apart from MAO.Enumerate important terms in the ontology Essential terms in the ontology are those needed to describe biological sequence alignments. These terms have been extracted from MAO and manually extended with other concepts defined, taking information from the scientific literature in the field. Examples of such terms are Alignment, Alignment Sequence, Alignment Column, Feature, and Sub Alignment. Furthermore, terms for describing alignment construction methods are selected, for example, Deterministic Approach and Stochastic Approach. Finally, we included terms regarding scores, such as Alignment Score, Column Score, and Column Score Function.Define classes and the class hierarchy Classes in the ontology correspond to important terms. In contrast with MAO, complete covering of 3D structural information is not included in SALON. We are focused on merely describing sequence alignments, ranging from a single residue to a set of sequences  and its construction method/scoring. Examples of classes in the ontology are: Alignment, AlignmentSequence, AlignmentColumn, ConstructionMethod and AlignmentScore. We have defined DNAAlignmentSequence and ProteinAlignmentSequence as subclasses of AlignmentSequence. DeterministicApproach and StochasticApproach have been defined as subclasses of ConstructionMethod.Define the properties of classes and slots Object properties and data properties (slots) are defined to describe Alignments. For example, an alignment has columns and contains sub-alignments. A sub-alignment has sequences, an alignment sequence has features, an alignment has a score, and a sub-alignment has a construction method. On the other hand, alignment sequences are described by the data properties character, identifier, accession number, keyword, and score value.Define the facets of the slots This step includes the definition of cardinality constraints and value restrictions. An example of cardinality constraint in our ontology is that a Sub-alignment has at least two Alignment sequences.Create instances Ontology Individuals are obtained by mapping the data from different data sources to RDF according to the ontology specification. One of the data sources used in the proposed use cases is the benchmark alignment database BAliBASE [BAliBASE .The SALON ontology has been developed using the Prótegé OWL editor version 5 in OWL 2 format. To assess the compliance of the ontology against the FAIR principles, we have used the FOOPS! validator [The proposed ontology has been developed using the standard ontology 101 development process , consistalidator , a web sAlignment, AlignmentColumn, AlignmentScore, AlignmentScoreFunction, AlignmentSequence, ColumnScore, ColumnScoreFunction, ConstructionMethod, Feature, Protein, and SubAlignment , and ranges from 0 to 100 (representing a percentage) for the whole alignment (AlignmentScoreFunction). The entropy value of any given column in a multiple sequence alignment ranges from 0 (only one residue is represented in that position of the sequence) to 4.322 . Thus the alignment scores a maximum of Some examples of score functions include the percentage of totally conserved columns, percentage of non-gaps, and entropy  scores. GUIDANCE  and HeadGUIDANCE  help us SWRL is a rule language that incorporates mechanisms to identify semantic relationships between individuals , hence pFor example, to check if the alignment in Fig. SWRL rules require a reasoner that supports them. The rules engine uses alignments and rules as inputs for inferring new facts, e.g., if the alignment is correct or not. Furthermore, as SWRL rules are built in the ontology, no external validation system is required to ensure alignment correctness.To test how the ontology instances can be used in real scenarios, we have deployed an on-premises instance of Stardog Knowledge-graph platform. Stardog supports the SPARQL query language and thus provides access to the data via the SPARQL protocol, a declarative language for performing operations over SPARQL endpoints, capable of receiving and processing those requests. Unlike other triple stores, Stardog supports SWRL rules (which this ontology uses). Therefore, SALON requires a running Stardog server instance to unlock all features at the server side . Virtuoso or any other triple store can be used, but in such a case, SWRL will not be evaluated, and the validation will be limited to the inference support provided.RDF instance files can be inserted into Stardog using a SPARQL update query. Automatic scripts for RDF repository population using Python can be found at GitHub .Due to the increasing use and development of high-throughput platforms, many biological data are available in public databases and repositories. Usually, databases provide different information regarding the same biological structure. Bringing together all this information into a single and unified repository might be very time-consuming. SALON can help to address this issue. The SPARQL protocol defines a federated form of the SPARQL query language that provides access to remote endpoints. Those queries (which can be issued to a SPARQL endpoint) are not constrained to working with a single database, but federated queries are supported across multiple endpoints. This powerful feature enables the online query of several related SPARQL Endpoints. However, the resolution of such queries relies on the availability of the individual SPARQL Endpoints to provide a complete answer.This way, complete information from several Open Linked Data resources can be integrated using a single query through the federation. For example, we can use the information already stored in our repository about protein sequences to integrate data from other data sources. When a new alignment record is inserted in our RDF repository, a federated query is automatically triggered against UniProt Knowledgebase (UniProtKB), the most well-known databases of protein structures and functional information. UniProtKB stores data about proteins, e.g., source organism, name, NCBI identifier, and gene, and provides a public accessible SPARQL endpoint .However, the Linked Data sources’ distributed nature makes these federated queries fail due to the system failure in one of its parts. For this reason, in the example described in this section, the additional information returned with the federated query is inserted into the local database.accessionNumber data property) to find matched records from UniProtKB and retrieve information that would aid subsequent analyses. Listing 4 shows the corresponding federated SPARQL query to aggregate information about the protein 1D2N. The range of the SALON accessionNumber data property is a string containing the UniProtKB entry of the protein. Using this value, we obtain all the information related to such a protein and insert it in our RDF repository.The sequence’s accession number can be used, for example, to retrieve 3D protein structures and compare alternative multiple sequence alignments in terms of their relative accuracy . SALON cNote that this information about each protein involved in the alignment process is unavailable in the alignment data. Thus, a user obtaining the alignment will need to retrieve such information from UniProtKB. Traditionally this could be done by manually exploring the UniProt portal with a vast human effort . An alternative would be to develop a software application using the UniProt services to retrieve such data, with the required programming skills from the user. Federated SPARQL queries simplify this process to retrieve updated information related to this data.The FASTA format is used to represent biological sequences. Still, it lacks a strict standard specification, translating into consistency issues as bioinformatics tools fail to parse description lines correctly. This problem can cause malfunctioning of third-party tools and unexpected results when parsing those files. There are cases in which FASTA files’ description lines are poorly described, or some information about the sequences (such as their source organism or accession number in reference databases) is missing.For example, UniProtKB and NCBI provide different specifications about the required and optional information in their sequences’ header lines see Fig. . It can It is frequent that, when comparing a highly conserved protein or domain of such a protein from two closely related species, a single PDB identifier can be mapped to several UniProtKB entries. In those cases, manual intervention by the domain expert might be required to help identify the most suitable option for the experiment required.To test SALON, we have focused on a set of manually constructed and verified alignments from a relevant dataset such as BAliBASE 4.0. This dataset provides high-quality reference alignments of DNA and protein sequences in XML and FASTA formats. In this database, each multiple alignment contains information about the sequences and some quality measures related to the alignments themselves, such as the column score, i.e., the fraction of aligned columns that are correctly reproduced.Figure BAliBASE alignments can also be downloaded in FASTA, a text-based file format representing either nucleotide sequences or peptide sequences using single-letter codes. FASTA files contain headers or description lines, distinguished from the sequence itself by a greater-than symbol. The information in the description line of the sequence, e.g., its protein identifier or source organism, can also be mapped to their corresponding terms in the ontology using a custom mapping function to transform FASTA to semantic-aware formats, i.e., RDF. When not present, this data can be retrieved from different sources to construct the description line. By matching identifiers found in the description line of a sequence against entries in authoritative biological databases, we can add informative labels to ensure that third-party tools can be used without adaptation. This consistency problem has been addressed in the past by web tools such as SeqScrub , but no Additionally, these instances are provided in the GIT repository so users can use any Open Source tool with RDF and SWRL support (such as Protègè). With the incorporation of SWRL rules, alignments can be validated to ensure their correctness and robustness automatically. For example, an alignment inferred as incorrect by the reasoner can be due to an error in the underlying alignment algorithm, which can dramatically impact subsequent steps in the pipeline. Similarly, Fig. The alignment of biological sequences is probably one of the most critical tasks in bioinformatics. Sequence alignments have many applications, such as gene finding, gene function prediction, or genome sequence assembly. Therefore, the availability of biological databases with information about correct and complete sequence alignments is of particular interest to scientists and researchers in this area. Several studies show that biological knowledge is growing and is usually distributed among many databases. Querying specific knowledge about proteins, genes, etc., can improve a sequence alignment by enriching it with relevant biological information. Efficient data integration is a challenge in general, and it is a bottleneck for biological sequence alignments enrichment. Semantic Web technologies simplify access to heterogeneous biological databases through standard models of knowledge representation.Ontologies are considered a central part of the Semantic Web for the formal description and representation of domain knowledge. Annotating biological sequence alignment (and its associated information) with an ontology allows the development of linked data repositories, providing homogeneous access to heterogeneous information and enabling intelligent and advanced applications. In this direction, we presented SALON, an ontology describing pairwise and multiple sequence alignments. Our proposal defines a valuable and comprehensive vocabulary for the representation of biological sequences using a full range of controlled terminology in the context of sequence alignment. Its usability has been proved constructing an RDF repository with information on sequence alignments. The algorithms developed to populate this repository from existing datasets are also provided so scientists can replicate this process for their data at .The SALON ontology can also play as a mediated schema for the virtual integration of data from different sources using federated SPARQL queries. These data can then be gathered to, for example, generate description lines of FASTA sequences or exchange header line formats between different services. To validate sequence alignments, SALON can be further exploited by defining SWRL rules, which automatically determine if a sequence alignment is plausible based on its global assigned score. This feature has been tested in the BAliBASE dataset but can be applied according to the scientists’ data.In future work, we plan to use these results to create a novel database on sequence alignments to enable an easy way to use this software solution by users with limited technical knowledge. This includes defining new classes and properties to describe sequence alignments’ construction methods in collaboration with domain experts. In the near future, we plan to submit our proposal to the Linked Open Vocabularies (LOV) catalogue, which, in addition to Zenodo, is aimed to encourage the use of the ontology by practitioners and other scientists in the field.