A method and system for improved gene sequence alignment based on sliding window of Smith-Waterman
By combining the improved Smith-Waterman algorithm with the sliding window technique, and dynamically setting parameters and traversing gene sequence pairs, the problem of large computational load and slow speed in traditional gene sequence alignment methods in large-scale data processing is solved, and efficient and accurate gene sequence alignment is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SANYA UNIVERSITY
- Filing Date
- 2025-08-25
- Publication Date
- 2026-07-21
AI Technical Summary
Traditional gene sequence alignment methods suffer from high computational cost and slow processing speed when dealing with large-scale data, making algorithm efficiency and resource utilization bottlenecks.
An improved Smith-Waterman algorithm combined with sliding window technology is adopted. By dynamically setting the sliding window parameters, gene sequence pairs are traversed step by step, local optimal alignment is performed, local optimal results are output, and finally the global optimal alignment result is determined.
It significantly improves the computational efficiency and resource utilization of gene sequence alignment, especially when dealing with large-scale data, enhancing the accuracy and speed of alignment.
Smart Images

Figure CN121237219B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of gene sequence alignment technology, and in particular to a sliding window-based gene sequence alignment method and system that is an improvement on the Smith-Waterman method. Background Technology
[0002] With the rapid development of genomics and bioinformatics, gene sequence alignment plays a crucial role in fields such as genomics research, disease diagnosis, and drug development. Gene sequence alignment aims to identify the similarities and differences between different gene sequences, helping scientists reveal evolutionary relationships between species, gene functions, and related biological characteristics.
[0003] In existing technologies, traditional gene sequence alignment methods, such as the Smith-Waterman algorithm and the Needleman-Wunsch algorithm, have been widely used for local and global gene sequence alignment. These algorithms, by constructing a score matrix and employing dynamic programming techniques, are able to handle alignments involving various mutation types, including insertions, deletions, and substitutions.
[0004] However, with the increase in the amount of genomic data, these traditional algorithms face technical challenges such as large computational load and slow processing speed for gene sequence alignment. In particular, when dealing with large-scale data, algorithm efficiency and resource utilization become bottleneck technical issues. Summary of the Invention
[0005] To address the technical challenges of large computational load and slow processing speed in traditional gene sequence alignment methods, especially when dealing with large-scale data where algorithm efficiency and resource utilization become bottlenecks, this invention provides an improved Smith-Waterman-based sliding window gene sequence alignment method and system.
[0006] The technical solutions provided by the embodiments of the present invention are as follows:
[0007] First aspect:
[0008] This invention provides an improved Smith-Waterman sliding window-based gene sequence alignment method, comprising:
[0009] S1: Obtain multiple gene sequences to be aligned and combine each gene sequence to be aligned into pairs;
[0010] S2: Dynamically set the sliding window parameters based on the gene sequence pairs to be compared;
[0011] S3: Based on the sliding window parameters, traverse the gene sequence pairs to be compared through the sliding window;
[0012] S4: Using the improved Smith-Waterman algorithm, the sequence fragments of the gene sequence pairs to be aligned within each sliding window are aligned, and the local optimal alignment result of each sequence fragment is output.
[0013] S5: Sort the results of each local best comparison;
[0014] S6: Based on the sorting results, determine the globally optimal alignment result for the gene sequence pairs to be aligned.
[0015] The second aspect:
[0016] This invention provides an improved Smith-Waterman sliding window-based gene sequence alignment system, comprising:
[0017] processor;
[0018] A memory storing computer-readable instructions that, when executed by the processor, implement the Smith-Waterman improved sliding window-based gene sequence alignment method as described in the first aspect.
[0019] Third aspect:
[0020] The present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the Smith-Waterman improved sliding window-based gene sequence alignment method as described in the first aspect.
[0021] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following:
[0022] In this embodiment of the invention, by dynamically setting sliding window parameters according to the gene sequence pairs to be aligned, traversing the gene sequence pairs to be aligned through the sliding window according to the sliding window parameters, and using the improved Smith-Waterman algorithm, the sequence fragments of the gene sequence pairs to be aligned within each sliding window are compared, and the local optimal alignment results of each sequence fragment are output. This solves the technical problem of large computational load and slow processing speed of gene sequence alignment. In particular, when processing large-scale data, the algorithm efficiency and resource utilization are effectively improved. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A schematic flowchart of a sliding window-based gene sequence alignment method improved from Smith-Waterman provided in an embodiment of the present invention;
[0025] Figure 2 This is a schematic diagram of a sliding window-based gene sequence alignment system, an improvement on the Smith-Waterman system, provided in an embodiment of the present invention. Detailed Implementation
[0026] The technical solution of the present invention will now be described with reference to the accompanying drawings.
[0027] In embodiments of the present invention, words such as "exemplarily," "for example," etc., are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present the concept in a concrete manner. Furthermore, in embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one.
[0028] In the embodiments of this invention, the terms "image" and "picture" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, their intended meanings are consistent. Similarly, the terms "of," "corresponding (relevant)," and "corresponding" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, their intended meanings are consistent.
[0029] In this embodiment of the invention, sometimes a subscript such as W1 may be written in a non-subscript form such as W1. When the difference is not emphasized, the meaning they express is the same.
[0030] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0031] Reference manual attached Figure 1 The diagram illustrates a flowchart of a sliding window-based gene sequence alignment method based on Smith-Waterman provided by an embodiment of the present invention.
[0032] This invention provides an improved Smith-Waterman sliding window-based gene sequence alignment method. This method can be implemented using an improved Smith-Waterman sliding window-based gene sequence alignment device, which can be a terminal or a server. The processing flow of the improved Smith-Waterman sliding window-based gene sequence alignment method may include the following steps:
[0033] S1: Obtain multiple gene sequences to be compared and combine each gene sequence to be compared into a pair of gene sequence pairs.
[0034] In this embodiment of the invention, the method of pairing gene sequences to be compared mainly improves the overall performance and accuracy of large-scale gene sequence alignment by reducing computational complexity, improving alignment accuracy and efficiency, optimizing resource utilization, and facilitating subsequent analysis and sorting.
[0035] In one possible implementation, the step of S1, which combines each gene sequence to be compared into a pair of gene sequences to be compared, specifically includes sub-steps S101 to S105:
[0036] S101: Compare the lengths of each gene sequence to be compared to determine the length similarity value between each gene sequence to be compared.
[0037] It should be noted that the length similarity value refers to the degree of similarity in length between two gene sequences to be compared. Specifically, for each gene sequence to be compared, the shorter gene sequence is divided by the longer gene sequence to obtain the length similarity value between the gene sequences. This value is used to measure the similarity in length between two gene sequences and is usually used to determine which gene sequence pairs are likely to have higher comparison value.
[0038] S102: Using the K-mer algorithm, subsequences are extracted from each gene sequence to be compared, resulting in a continuous subsequence of a preset length corresponding to each gene sequence to be compared.
[0039] It's important to note that the K-mer algorithm is a technique for segmenting strings or sequences (such as DNA sequences) into continuous substrings of length K. Each K-mer represents a segment consisting of K consecutive characters and is commonly used in sequence alignment, sequence analysis in genomics, and data compression. By analyzing the frequency distribution of K-mers, sequence features can be extracted, and the similarity between different sequences can be compared.
[0040] Specifically, based on a preset length, each gene sequence to be aligned is divided into multiple subsequences of equal length, which are continuous segments within the gene sequence. Starting from the beginning of the gene sequence to be aligned, all possible continuous subsequences are extracted sequentially until the end of the gene sequence to be aligned, resulting in continuous subsequences of the preset length corresponding to each gene sequence to be aligned. The K-mer algorithm is existing technology, and will not be elaborated upon further in this invention.
[0041] It should be noted that those skilled in the art can set the preset length according to actual needs, and this invention does not limit it.
[0042] S103: Based on the continuous subsequences, determine the MinHash signature of each gene sequence to be compared using the MinHash algorithm:
[0043]
[0044] Among them, MH(s) i ) represents the i-th gene sequence to be compared, s i The MinHash signature, where min represents the minimum value, k represents the k-th subsequence, and K i This represents the i-th gene sequence to be compared, s. i The corresponding continuous subsequence of a preset length, H={h1,h2,…,h N} represents a set of hash functions containing N hash functions, where N represents the total number of hash functions.
[0045] It's important to note that the MinHash algorithm is a technique for estimating the similarity between two sets, particularly effective when dealing with large-scale data. It calculates "signatures" of the sets using multiple hash functions and then uses these signatures to estimate the Jaccard similarity between the sets. MinHash is highly efficient in approximate calculations and is widely used for similarity measurements in big data, document deduplication, and genomics.
[0046] It's important to note that MinHash signatures refer to the "fingerprint" or "signature" of each gene sequence obtained by hashing consecutive subsequences of a gene sequence using multiple hash functions. MinHash signatures generate a sequence signature by taking the minimum hash value of each subsequence, aiming to estimate the similarity between two gene sequences using a smaller representation.
[0047] S104: Determine the similarity index between each gene sequence to be compared based on the MinHash signature:
[0048]
[0049] in, This represents the i-th gene sequence to be compared, s. i Compare with the j-th gene sequence s j The similarity index between them, δ represents the exponential function, where when MH(s) i )=MH(s j When ), δ(MH) n (s i ),MH n (s j ))=1, otherwise, δ(MH) n (s i ),MH n (s j ))=0, MH n (s i ) represents the i-th gene sequence to be compared, s i The nth hash value in the MinHash signature, MH n (s j ) represents the j-th gene sequence to be compared, s j The nth hash value in the MinHash signature.
[0050] It should be noted that the similarity index refers to the similarity between two gene sequences calculated based on their MinHash signatures, and is usually measured using Jaccard similarity. This index estimates the similarity between two gene sequences by comparing how well their MinHash signatures match; a higher value indicates greater similarity between the sequences.
[0051] S105: When the length similarity value is greater than or equal to the preset length similarity value and the similarity index is greater than or equal to the preset similarity index, the gene sequences to be compared are combined into pairs to form gene sequence pairs to be compared.
[0052] It should be noted that those skilled in the art can set the preset length similarity value and preset similarity index according to actual needs, and this invention does not limit them.
[0053] In this embodiment of the invention, by combining gene sequences in pairs, in step S101, sequence pairs with high alignment value are first screened by comparing the length similarity of gene sequences, reducing unnecessary alignment calculations. In step S102, a fixed-length subsequence is extracted using the K-mer algorithm, improving the comparability of gene sequences and simplifying calculations. Next, in step S103, the MinHash algorithm is used to generate signatures for gene sequences, significantly improving the efficiency of similarity estimation in a big data environment. In step S104, a similarity index is calculated based on the MinHash signature to quickly assess sequence similarity, avoiding the computational burden of global alignment. Finally, in step S105, by setting a threshold to screen and combine sequence pairs, the specificity and accuracy of the alignment are ensured, improving the quality of the alignment results and further reducing the waste of computational resources.
[0054] S2: Dynamically set the sliding window parameters based on the gene sequence pairs to be compared.
[0055] Optionally, the sliding window parameters include the sliding window size and the sliding window step size.
[0056] In this embodiment of the invention, by dynamically setting the parameters of the sliding window, personalized alignment of different gene sequence pairs can be achieved, ensuring that the alignment process is both efficient and accurate. This method improves the sensitivity, accuracy, and robustness of the alignment while ensuring efficient use of computing resources, which is particularly important for processing large-scale gene data.
[0057] In one possible implementation, S2 specifically includes sub-steps S201 to S203:
[0058] S201: Extract multimodal features of the gene sequence pairs to be compared. The multimodal features include the difference index and length deviation value between each gene sequence to be compared in the gene sequence pairs.
[0059] It should be noted that the difference index refers to the similarity difference between two gene sequences to be compared. Specifically, the difference index is obtained by subtracting the similarity index from a specific value of 1. The larger the difference index, the greater the difference between the two gene sequences. It is usually used to adjust the size and step size of the sliding window to improve the comparison sensitivity.
[0060] It should be noted that the length deviation value refers to the difference in length between two gene sequences to be compared. Specifically, the length deviation value between each gene sequence to be compared is obtained by subtracting the length similarity value from the specific value of 1. The larger the length deviation value, the greater the difference in length between the two gene sequences. It is usually used to dynamically adjust the parameters of the sliding window so that sequences with large length differences can be properly aligned.
[0061] S202: Dynamically set the sliding window size based on the difference index and length deviation value:
[0062]
[0063] Where W represents the size of the sliding window, and clip() represents the clip function. means rounding down to an integer, W base W represents the baseline window width, α represents the weighting coefficient of the difference index, σ represents the difference index between each pair of gene sequences in the pair, β represents the weighting coefficient of the length deviation value, ρ represents the length deviation value between each pair of gene sequences in the pair, and W represents the length deviation value between each pair of gene sequences in the pair. min W represents the lower limit of the window width. max This indicates the maximum width of the window.
[0064] It should be noted that within the specified sliding window size range [W] min W max Within a given range, the greater the difference (ασ+βρ) between the two gene sequences to be compared, the smaller the window should be to improve the window sensitivity during gene sequence alignment.
[0065] It should be noted that those skilled in the art can set the base window width, the weighting coefficient of the difference index, the weighting coefficient of the length deviation value, the lower limit of the window width, and the upper limit of the window width according to actual needs, and this invention does not limit these settings.
[0066] S203: Dynamically set the sliding window step size based on the sliding window size:
[0067]
[0068] Where S represents the sliding window step size, and η represents the window overlap enhancement factor. min This indicates the lower limit of the sliding window step size.
[0069] It should be noted that those skilled in the art can set the window overlap enhancement factor and the lower limit of the sliding window step size according to actual needs, and this invention does not limit them.
[0070] It should be noted that, within the specified range of sliding window step size... Within this range, the greater the difference (ασ+βρ) between the two gene sequences to be aligned, the smaller the step size should be to improve the window coverage during gene sequence alignment, and ensure at least 50% window overlap.
[0071] In this embodiment of the invention, by dynamically setting the sliding window parameters, the alignment strategy can be flexibly adjusted based on the difference index and length deviation value of the gene sequences to be aligned. In S201, by extracting multimodal features of the gene sequences, the similarity differences and length differences between sequences can be accurately measured, thus providing a basis for adjusting the window parameters. In S202, the sliding window size is dynamically set according to the difference index and length deviation value to ensure a balance between alignment accuracy and computational efficiency. In S203, by dynamically adjusting the step size, appropriate window overlap is ensured, increasing the coverage and accuracy of the alignment. These dynamic adjustments improve the sensitivity, robustness, and efficiency of the alignment process, especially when processing large-scale gene data, effectively improving the quality of alignment results and optimizing the use of computational resources.
[0072] S3: Based on the sliding window parameters, traverse the gene sequence pairs to be compared through the sliding window.
[0073] Specifically, the sliding window will gradually slide to cover each part of the gene sequence pair to be compared, based on the window size and step size dynamically set in the previous step. Each time the sliding window covers an area of fixed length, these fragments will be used for further local alignment. The sliding window will start from the beginning position in the sequence and move gradually according to the set step size until the entire gene sequence pair has been traversed.
[0074] In this embodiment of the invention, the method of using a sliding window to progressively traverse the gene sequence pairs to be compared has significant advantages in improving alignment accuracy, optimizing computational efficiency, enhancing coverage, and handling complex variations. By flexibly adjusting the window size and step size, it is possible to better adapt to the characteristics of gene sequences, improve the alignment effect, and ensure that the computation process is efficient and robust.
[0075] S4: Using the improved Smith-Waterman algorithm, the sequence fragments of the gene sequence pairs to be aligned within each sliding window are aligned, and the local optimal alignment result of each sequence fragment is output.
[0076] It's important to note that the Smith-Waterman algorithm is a classic dynamic programming algorithm used to compute the locally optimal alignment of two sequences. It determines the optimal alignment path by constructing a score matrix and iteratively calculating the score at each position. This algorithm is widely used in bioinformatics for the local alignment of DNA, RNA, or protein sequences and can handle cases involving insertions, deletions, or substitutions.
[0077] It should be noted that the improved Smith-Waterman algorithm in this invention includes two improvement schemes (Scheme A and Scheme B). In practical applications, either one can be selected for gene sequence alignment tasks.
[0078] In this embodiment of the invention, the improved Smith-Waterman algorithm performs locally optimal alignment within each sliding window, which not only accurately handles variations such as insertions, deletions, and substitutions in gene sequences but also improves alignment accuracy and efficiency. The improved algorithm combines flexible schemes (A and B) to provide more efficient and accurate alignment results for different types of gene sequences and alignment tasks, especially when processing large-scale gene data, effectively improving computational efficiency and reliability.
[0079] In one possible implementation, the alignment operation of the sequence fragments of the gene sequence pairs to be aligned within the sliding window using the improved Smith-Waterman algorithm in S4 of scheme A specifically includes sub-steps S401A to S405A:
[0080] S401A: In the sliding window, initialize the score values of the first row and first column elements in the score matrix to 0.
[0081] It's important to note that the score matrix is a matrix used in gene sequence alignment to store the results of each base alignment. In this matrix, each element represents the score for the corresponding base alignment position. The rows and columns of the matrix correspond to the base positions of the two gene sequences to be aligned, and the score for each position is calculated progressively using dynamic programming. The initial rows and columns of the score matrix are usually set to 0 to simplify calculations. Subsequently, by comparing adjacent base pairs and combining the score function, the other elements of the matrix are filled, ultimately generating a locally optimal alignment path.
[0082] Furthermore, the score matrix is a matrix with X+1 rows and Y+1 columns. After initialization, the element in the first row of the score matrix takes the value d. 0,y =0, the first column element in the score matrix takes the value d. x,0 =0. And so on, the element in the second row of the score matrix takes the value d. 1,y The second column element in the score matrix takes the value d. x,1 Until the element in the (X+1)th row of the score matrix has a value of d. 1,Y The element in the (Y+1)th column of the score matrix has a value of d. X,1 S402A: Calculate the score value of the element in the second row and the element in the second column of the score matrix:
[0083]
[0084] Where, d 1y This represents the score value of the element in the 2nd row and yth column of the score matrix, where p() represents the base pair score function. This represents the i-th gene sequence to be compared, s. i The first base, This represents the j-th gene sequence to be compared, s. j The y′th base, where, when hour, otherwise, d x1 This represents the score value of the element in the x-th row and 2nd column of the score matrix. This represents the i-th gene sequence to be compared, s. i The x′th base, This represents the j-th gene sequence to be compared, s. j The first base, where, when hour, otherwise,
[0085] It should be noted that in the improved Smith-Waterman algorithm of Scheme A, the first row and first column of the score matrix are initialized to 0 to simplify subsequent calculations. Mathematical derivation shows that the calculation of elements in the second row and second column depends only on the initial values (0) on the diagonal, i.e., the values in the first row and first column. This is because in the traditional Smith-Waterman algorithm, the calculation of each element requires consideration of the values above, to the left, and on the diagonal. However, the derivation shows that the calculation of elements in the second row and second column only involves the diagonal elements and the character matching results. Therefore, skipping comparisons in other directions and directly calculating the scores of the second row and second column effectively simplifies the calculation, reduces complexity, and does not affect the accuracy of the comparison results.
[0086] S403A: Based on the scores of the elements in the second row and second column of the score matrix, calculate the scores of the remaining elements in the score matrix:
[0087]
[0088] Where, d xy This represents the score of the element in the x-th row and y-th column of the score matrix, where num represents the maximum score among the two ways to traverse the gap path (insertion / deletion), and d represents the score of the element in the x-th row and y-th column of the score matrix. x-1,y-1 Let represent the score value of the element in the (x-1)th row and (y-1)th column of the score matrix, where ... hour, otherwise, d x-1,y d represents the score value of the element in the (x-1)th row and yth column of the score matrix. x,y-1 This represents the score value of the element in the x-th row and y-1-th column of the score matrix.
[0089] S404A: Traverse the score matrix and determine the position of the element with the maximum score.
[0090] S405A: Starting from the position of the element with the maximum score, backtrack to generate a locally optimal alignment path, and output the locally optimal alignment path as the locally optimal alignment result.
[0091] In this embodiment of the invention, gene sequence alignment is performed using an improved Smith-Waterman algorithm, resulting in significant optimizations. In steps S401A and S402A, initializing the first row and first column of the score matrix to 0 simplifies calculations, reduces complexity, and improves computational efficiency. In step S403A, recursively calculating other elements in the score matrix ensures the accuracy and refinement of the alignment. Steps S404A and S405A, by traversing the score matrix and backtracking to generate locally optimal alignment paths, ensure the optimality and reliability of the alignment results. These optimizations make the alignment process more efficient when handling large-scale gene data, while accurately handling variations such as insertions, deletions, and substitutions in gene sequences, thus improving the accuracy and robustness of the alignment.
[0092] In one possible implementation, the alignment operation of the sequence fragments of the gene sequence pairs to be aligned within the sliding window using the improved Smith-Waterman algorithm in S4 of scheme B specifically includes sub-steps S401B to S405B:
[0093] S401B: In the sliding window, initialize the score values of the first row and first column elements in the score matrix to 0.
[0094] S402B: Set the replacement matrix:
[0095]
[0096] Where Score() represents the replacement matrix, This represents the i-th gene sequence to be compared, s. i The x′th base Compare with the j-th gene sequence s j The y′th base The substitution score between them, where ε() represents the assignment function.
[0097] It's important to note that the substitution matrix is a matrix used in gene sequence alignment to calculate the substitution score between two base pairs. This matrix assigns a score to each base pair (e.g., A and T, G and C) based on base pair matches and mismatches. The substitution matrix is designed to optimize the alignment process, particularly highlighting critical base matches and mismatches, thereby improving the sensitivity and accuracy of the alignment.
[0098] It should be noted that the assignment function refers to a function used to quantify the importance of specific bases or positions in a gene sequence. In this embodiment, the assignment function assigns a weight to each base by calculating a "conservation score" for the gene site. The conservation score reflects the degree of conservation of that base in homologous sequences. The purpose of the assignment function is to ensure that, during alignment, higher weights are given to key regions that have maintained a high degree of consistency throughout evolution, thereby improving the accuracy and efficiency of the alignment.
[0099] Optionally, with For example, the calculation formula for the assignment function is as follows:
[0100]
[0101] Where κ represents the base weight, log2 represents the logarithmic function to base 2, ConservationScore represents the gene evolution conservation score, and M represents the number of homologous sequences. Represents the base position corresponding to the m-th homologous sequence, where, when hour, otherwise,
[0102] It is important to note that homologous sequences refer to gene or DNA sequences that originate from a common ancestral gene in different species or different individuals of the same species. These sequences have gradually changed through genetic variation during evolution, but because they originate from a common ancestral gene, they still maintain a certain degree of similarity in structure and function. Comparing homologous sequences can help scientists reveal evolutionary relationships between species, understand the functional conservation of genes, and the changes in genes across different species.
[0103] It should be noted that in the improved Smith-Waterman algorithm of Scheme B, the purpose of setting the substitution matrix and assignment function is to optimize the gene sequence alignment process. The substitution matrix assigns different scores based on the differences in matching and mismatching in the gene sequence to highlight key matching or mismatching positions, thereby improving the sensitivity and accuracy of the alignment. The assignment function, by calculating a "conservatism score," quantifies the importance of key sites in the gene sequence, giving these sites higher weight in the alignment process. This ensures that the alignment process focuses on evolutionarily conserved regions, thereby improving the accuracy and efficiency of the alignment results.
[0104] S403B: Based on the replacement matrix, calculate the score values of the remaining elements in the score matrix:
[0105]
[0106] Where max represents the maximum value. This represents the i-th gene sequence to be compared, s.i The x′th base The replacement score between a given empty space (i.e., a missing part of the sequence, representing an insertion operation). This represents a gap (i.e., a missing sequence location, indicating a deletion operation) and the j-th gene sequence to be aligned, s. j The y′th base The replacement score between them.
[0107] S404B: Traverse the score matrix and determine the position of the element with the maximum score.
[0108] S405B: Starting from the position of the element with the maximum score, backtrack to generate a locally optimal alignment path, and output the locally optimal alignment path as the locally optimal alignment result.
[0109] In this embodiment of the invention, the alignment process is optimized by initializing the scoring matrix S401B and using a substitution matrix and assignment function S402B, thereby improving the accuracy and sensitivity of gene sequence alignment. The substitution matrix can accurately handle base pair matching and mismatch, while the assignment function, by calculating the conservation score, assigns higher weight to evolutionarily conserved regions during the alignment process, thus improving the accuracy of the alignment. By dynamically calculating the scoring matrix S403B and backtracking to generate locally optimal alignment paths S404B and S405B, the accurate handling of variations such as insertions, deletions, and substitutions in the gene sequence is ensured, and the selection of alignment paths is optimized. These steps make the alignment process more efficient and accurate, especially when processing large-scale gene data, providing high-precision alignment results.
[0110] S5: Sort the results of each local best alignment.
[0111] In this embodiment of the invention, the step of sorting the locally optimal alignment results not only improves the accuracy, efficiency, and precision of the alignment, but also provides a reliable basis for selecting the subsequent globally optimal alignment path. It ensures that the final output alignment results are the most valuable, while enhancing the flexibility and adaptability of the alignment process. Especially when dealing with complex and large-scale gene data, it can significantly improve computational efficiency and the reliability of the results.
[0112] In one possible implementation, S5 specifically includes sub-steps S501 to S502:
[0113] S501: The local optimal alignment path score is obtained by weighted summation of the length of the local optimal alignment path and the corresponding maximum score.
[0114] It should be noted that the local optimal alignment path score refers to a comprehensive score calculated in gene sequence alignment by considering the length and maximum score of the local optimal alignment path. This score, obtained by weighting the path length and the corresponding maximum score, aims to quantify the quality and importance of the local alignment. A higher score indicates that the path has higher accuracy and reliability during the alignment process, and it is usually used to select the best alignment path and serve as the basis for determining the subsequent global optimal alignment result.
[0115] Specifically, firstly, a weight (path weight) is assigned to each path based on its length and corresponding maximum score. Then, these lengths and maximum scores are weighted and summed according to preset weight coefficients to obtain the final score for each path. This score comprehensively considers both the length of the alignment path and the quality of the alignment (maximum score), reflecting the overall superiority of the path. Finally, the score of the locally optimal alignment path serves as a measure of the alignment quality, used for subsequent ranking and determination of the global alignment results.
[0116] It should be noted that those skilled in the art can set the path weight according to actual needs, and this invention does not limit this.
[0117] S502: Sort the local best alignment results in descending order of their local best alignment path scores.
[0118] In this embodiment of the invention, by performing a weighted summation (S501) and sorting (S502) on the length and maximum score of the locally optimal alignment path, the quality and importance of the alignment path can be effectively quantified. The weighted summation step ensures that long and high-scoring paths are given priority, improving the accuracy and stability of the alignment. Simultaneously, the sorting step improves alignment efficiency and reduces unnecessary computation by prioritizing high-scoring paths, especially when processing large-scale gene data. The strategy of combining scores and sorting ensures that the finally selected local path is not only reliable but also highly representative, thus providing a precise foundation for globally optimal alignment and improving the accuracy and robustness of the alignment results.
[0119] S6: Based on the sorting results, determine the globally optimal alignment result for the gene sequence pairs to be aligned.
[0120] In this embodiment of the invention, by determining the globally optimal alignment result based on the sorting results, the accuracy, stability, and representativeness of the alignment results can be ensured. The locally optimal path selected after sorting provides a solid foundation for the generation of the globally optimal path, thereby improving alignment accuracy, reducing computational burden, increasing the efficiency of the alignment process, and enhancing the interpretability of the results and the reliability of subsequent analysis.
[0121] In one possible implementation, S6 specifically includes sub-steps S601 to S604:
[0122] S601: Based on the sorting results, determine the local optimal alignment path with the highest score as the target alignment path.
[0123] S602: Determine whether the target alignment path is connected to the locally optimal alignment path in the adjacent sliding window. The connection relationship includes: overlap, connection and disconnection.
[0124] S603: When the target alignment path overlaps with or is connected to the local optimal alignment path in the adjacent sliding window, merge the target alignment path with the local optimal alignment path in the adjacent sliding window to obtain the merged path, update the target alignment path to the merged path, and return to S602.
[0125] S604: When the target alignment path is not connected to the local optimal alignment path in the adjacent sliding window, the target alignment path is determined as the global optimal alignment result of the gene sequence pair to be aligned.
[0126] In this embodiment of the invention, step S601 ensures the accuracy and reliability of the alignment results by selecting the locally optimal alignment path with the highest score as the target path. Step S602 effectively ensures the continuity and integrity of the alignment path by determining the connection relationship between the target alignment path and adjacent sliding window paths. Step S603 merges paths when the target path connects with adjacent window paths to avoid information loss, improve alignment accuracy, reduce redundant calculations, and increase efficiency. Step S604 directly selects the target path as the globally optimal alignment result when paths are not connected, ensuring the stability and robustness of the alignment results. Overall, these steps optimize the accuracy, efficiency, and stability of the alignment process, especially when dealing with large-scale and complex gene data, providing efficient and reliable globally optimal alignment results.
[0127] Reference manual attached Figure 2 The diagram shows a schematic of the structure of a sliding window-based gene sequence alignment system, an improvement on the Smith-Waterman system, provided by the present invention.
[0128] The present invention also provides a Smith-Waterman improved sliding window-based gene sequence alignment system 20, applied to the above-mentioned Smith-Waterman improved sliding window-based gene sequence alignment method, comprising:
[0129] Processor 201;
[0130] The memory 202 stores computer-readable instructions that, when executed by the processor 201, implement the Smith-Waterman improved sliding window-based gene sequence alignment method as described in the method embodiment.
[0131] The Smith-Waterman improved sliding window-based gene sequence alignment system 20 provided by the present invention can perform the above-described Smith-Waterman improved sliding window-based gene sequence alignment method and achieve the same or similar technical effects. To avoid duplication, the present invention will not elaborate further.
[0132] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following:
[0133] In this embodiment of the invention, by dynamically setting sliding window parameters according to the gene sequence pairs to be aligned, traversing the gene sequence pairs to be aligned through the sliding window according to the sliding window parameters, and using the improved Smith-Waterman algorithm, the sequence fragments of the gene sequence pairs to be aligned within each sliding window are compared, and the local optimal alignment results of each sequence fragment are output. This solves the technical problem of large computational load and slow processing speed of gene sequence alignment. In particular, when processing large-scale data, the algorithm efficiency and resource utilization are effectively improved.
[0134] It should be understood that the processor in the embodiments of the present invention can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0135] It should also be understood that the memory in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0136] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.
[0137] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.
[0138] In this invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be a single item or multiple items.
[0139] It should be understood that, in various embodiments of the present invention, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0140] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0141] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0142] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0143] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0144] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0145] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0146] This invention provides a computer-readable storage medium storing a computer program thereon, characterized in that, when executed by a processor, the program implements the Smith-Waterman improved sliding window-based gene sequence alignment method as described in the method embodiment.
[0147] The present invention provides a computer-readable storage medium that can implement the steps and effects of the Smith-Waterman improved sliding window-based gene sequence alignment method of the above method embodiments. To avoid repetition, the present invention will not repeat them.
[0148] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following:
[0149] In this embodiment of the invention, by dynamically setting sliding window parameters according to the gene sequence pairs to be aligned, traversing the gene sequence pairs to be aligned through the sliding window according to the sliding window parameters, and using the improved Smith-Waterman algorithm, the sequence fragments of the gene sequence pairs to be aligned within each sliding window are compared, and the local optimal alignment results of each sequence fragment are output. This solves the technical problem of large computational load and slow processing speed of gene sequence alignment. In particular, when processing large-scale data, the algorithm efficiency and resource utilization are effectively improved.
[0150] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0151] The following points need to be explained:
[0152] (1) The accompanying drawings of the embodiments of the present invention only involve the structures involved in the embodiments of the present invention. Other structures can refer to the general design.
[0153] (2) For clarity, the thickness of layers or regions is enlarged or reduced in the drawings used to describe embodiments of the present invention; that is, these drawings are not drawn to actual scale. It is understood that when an element such as a layer, film, region, or substrate is referred to as being “above” or “below” another element, the element may be “directly” located “above” or “below” the other element, or there may be intermediate elements.
[0154] (3) Where there is no conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other to obtain new embodiments.
[0155] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A sliding window-based gene sequence alignment method improved from the Smith-Waterman method, characterized in that, include: S1: Obtain multiple gene sequences to be compared, and combine each of the gene sequences to be compared into pairs of gene sequences to be compared; S2: Dynamically set the sliding window parameters according to the gene sequence pairs to be compared; The sliding window parameters include the sliding window size and the sliding window step size; Specifically, S2 includes: S201: Extract the multimodal features of the gene sequence pair to be compared. The multimodal features include the difference index and length deviation value between each gene sequence to be compared in the gene sequence pair. The difference index is 1 minus the similarity index between each gene sequence to be compared. The length deviation value is 1 minus the length similarity value between each gene sequence to be compared. S202: Dynamically set the size of the sliding window based on the difference index and the length deviation value: ; in, W Indicates the size of the sliding window. clip ( ) represents the clip function. Indicates rounding down to the nearest integer. W base Indicates the base window width. α The weighting coefficients of the difference index are represented. σ This represents the difference index between the individual gene sequences in the gene sequence pair to be compared. β The weighting coefficients represent the length deviation values. ρ This represents the length deviation value between each gene sequence in the gene sequence pair to be compared. W min Indicates the lower limit of the window width. W max Indicates the maximum width of the window; S203: Dynamically set the sliding window step size according to the sliding window size: ; in, S Indicates the step size of the sliding window. η Indicates the window overlap enhancement factor. S min Indicates the lower limit of the sliding window step size; S3: According to the sliding window parameters, traverse the gene sequence pairs to be compared through the sliding window; S4: Using the improved Smith-Waterman algorithm, the sequence fragments of the gene sequence pairs to be aligned within each sliding window are compared, and the local optimal alignment result of each sequence fragment is output. Specifically, the alignment operation of the sequence fragments of the gene sequence pairs to be aligned within the sliding window using the improved Smith-Waterman algorithm in S4 includes: S401B: In the sliding window, initialize the score values of the first row and first column elements in the score matrix to 0; S402B: Set the replacement matrix: ; in, Score () indicates the replacement matrix. Indicates the first i Gene sequences to be compared s i The One base With the j Gene sequences to be compared s j The One base The replacement score between them ε ( ) represents an assignment function; Among them, with For example, the calculation formula of the assignment function is as follows: ; ; in, κ Indicates base weights, log 2 represents the logarithmic function with base 2. ConservationScore This represents the score of gene evolution conservation. M Indicates the number of homologous sequences. Indicates the first m The corresponding base sites of the homologous sequences, where, when hour, ,otherwise, ; S403B: Based on the replacement matrix, calculate the score values of the remaining elements in the score matrix: ; in, d xy Represents the score matrix of the first... x Line number y The score of each column element. max This indicates taking the maximum value. d x-1,y-1 Represents the score matrix of the first... x- Line 1, Page y- The score value of the element in column 1, d x-1,y Represents the score matrix of the first... x- Line 1, Page y The score of each column element. Indicates the first i Gene sequences to be compared s i The One base The score for a substitution between an open player and an open one. d x,y-1 Represents the score matrix of the first... x Line number y- The score value of the element in column 1, Indicates an empty space and the first j Gene sequences to be compared s j The One base Replacement scores between; S404B: Traverse the score matrix to determine the position of the element with the maximum score; S405B: Starting from the position of the element with the maximum score, backtrack to generate a locally optimal alignment path, and output the locally optimal alignment path as the locally optimal alignment result; S5: Sort the results of each of the local optimal comparisons; S6: Based on the sorting results, determine the global optimal alignment result of the gene sequence pairs to be aligned.
2. The improved Smith-Waterman-based sliding window gene sequence alignment method according to claim 1, characterized in that, The step of S1, which involves combining each of the gene sequences to be compared into a pair of gene sequences to be compared, specifically includes: S101: Compare the lengths of each of the gene sequences to be compared to determine the length similarity value between each of the gene sequences to be compared. S102: Using the K-mer algorithm, subsequence extraction is performed on each of the gene sequences to be compared to obtain a continuous subsequence of a preset length corresponding to each of the gene sequences to be compared to be compared. S103: Based on the continuous subsequences, determine the MinHash signature of each of the gene sequences to be compared using the MinHash algorithm; S104: Determine the similarity index between each of the gene sequences to be compared based on the MinHash signature; S105: When the length similarity value is greater than or equal to the preset length similarity value and the similarity index is greater than or equal to the preset similarity index, the gene sequences to be compared are combined in pairs to form the gene sequence pairs to be compared.
3. The improved Smith-Waterman-based sliding window gene sequence alignment method according to claim 1, characterized in that, S5 specifically includes: S501: The local optimal alignment path length and the corresponding maximum score value are weighted and summed to obtain the local optimal alignment path score value; S502: Sort the local optimal alignment results in descending order of their scores.
4. The improved Smith-Waterman-based sliding window gene sequence alignment method according to claim 3, characterized in that, S6 specifically includes: S601: Based on the sorting results, determine the local optimal alignment path with the highest score as the target alignment path; S602: Determine the connection relationship between the target alignment path and the local optimal alignment path in the adjacent sliding window, wherein the connection relationship includes: overlap, connection and disconnection; S603: When the target alignment path overlaps with or is connected to the local optimal alignment path in the adjacent sliding window, merge the target alignment path with the local optimal alignment path in the adjacent sliding window to obtain a merged path, update the target alignment path to the merged path, and return to S602. S604: When the target alignment path is not connected to the locally optimal alignment path in the adjacent sliding window, the target alignment path is determined as the globally optimal alignment result of the gene sequence pair to be aligned.
5. A sliding window-based gene sequence alignment system improved from the Smith-Waterman system, characterized in that, include: processor; A memory storing computer-readable instructions, which, when executed by the processor, implement the Smith-Waterman improved sliding window-based gene sequence alignment method as described in any one of claims 1 to 4.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the Smith-Waterman improved sliding window-based gene sequence alignment method as described in any one of claims 1 to 4.