The Ruzzo–Tompa algorithm or the RT algorithm is a linear-time algorithm for finding all non-overlapping, contiguous, maximal scoring subsequences in a sequence of real numbers. The Ruzzo–Tompa algorithm was proposed by Walter L. Ruzzo and Martin Tompa. This algorithm is an improvement over previously known quadratic time algorithms. The maximum scoring subsequence from the set produced by the algorithm is also a solution to the maximum subarray problem.
The Ruzzo–Tompa algorithm has applications in bioinformatics, web scraping, and information retrieval.
Applications
Bioinformatics
The Ruzzo–Tompa algorithm has been used in Bioinformatics tools to study biological data. The problem of finding disjoint maximal subsequences is of practical importance in the analysis of DNA. Maximal subsequences algorithms have been used in the identification of transmembrane segments and the evaluation of sequence homology.
The algorithm is used in sequence alignment which is used as a method of identifying similar DNA, RNA, or protein sequences. Accounting for the ordering of pairs of high-scoring subsequences in two sequences creates better sequence alignments. This is because the biological model suggests that separate high-scoring subsequence pairs arise from insertions or deletions within a matching region. Requiring consistent ordering of high-scoring subsequence pairs increases their statistical significance.
Web scraping
The Ruzzo–Tompa algorithm is used in Web scraping to extract information from web pages. Pasternack and Roth proposed a method for extracting important blocks of text from HTML documents. The web pages are first tokenized and the score for each token is found using local, token-level classifiers. A modified version of the Ruzzo–Tompa algorithm is then used to find the k highest-valued subsequences of tokens. These subsequences are then used as predictions of important blocks of text in the article.
Information retrieval
The Ruzzo–Tompa algorithm has been used in Information retrieval search algorithms. Liang et al. proposed a data fusion method to combine the search results of several microblog search algorithms. In their method, the Ruzzo–Tompa algorithm is used to detect bursts of information.
Problem definition
The problem of finding all maximal subsequences is defined as follows: Given a list of real numbered scores , find the list of contiguous subsequences that gives the greatest total score, where the score of each subsequence . The subsequences must be disjoint (non-overlapping) and have a positive score.
Other algorithms
There are several approaches to solving the all maximal scoring subsequences problem. A natural approach is to use existing, linear time algorithms to find the maximum subsequence (see maximum subarray problem) and then recursively find the maximal subsequences to the left and right of the maximum subsequence. The analysis of this algorithm is similar to that of Quicksort: The maximum subsequence could be small in comparison to the rest of sequence, leading to a running time of in the worst case.
Algorithm
The standard implementation of the Ruzzo–Tompa algorithm runs in time and uses O(n) space, where n is the length of the list of scores. The algorithm uses dynamic programming to progressively build the final solution by incrementally solving progressively larger subsets of the problem. The description of the algorithm provided by Ruzzo and Tompa is as follows:
- Read the scores left to right and maintain the cumulative sum of the scores read. Maintain an ordered list of disjoint subsequences. For each subsequence , record the cumulative total of all scores up to but not including the leftmost score of , and the total up to and including the rightmost score of .
- The lists are initially empty. Scores are read from left to right and are processed as follows. Nonpositive scores require no special processing, so the next score is read. A positive score is incorporated into a new sub-sequence of length one that is then integrated into the list by the following process:
- The list is searched from right to left for the maximum value of satisfying
- If there is no such , then add to the end of the list.
- If there is such a , and , then add to the end of the list.
- Otherwise (i.e., there is such a j, but ), extend the subsequence to the left to encompass everything up to and including the leftmost score in . Delete subsequences from the list, and append to the end of the list. Reconsider the newly extended subsequence (now renumbered ) as in step 1.
- Once the end of the input is reached, all subsequences remaining on the list are maximal.
The following Python code implements the Ruzzo–Tompa algorithm:
def ruzzo_tompa(scores): """Ruzzo–Tompa algorithm.""" k = 0 total = 0 # Allocating arrays of size n I, L, R, Lidx = * len(scores) for _ in range(4)] for i, s in enumerate(scores): total += s if s > 0: # store I by (start,end) indices of scores I = (i, i + 1) Lidx = i L = total - s R = total while True: maxj = None for j in range(k - 1, -1, -1): if L < L: maxj = j break if maxj is not None and R < R: I = (Lidx, i + 1) R = total k = maxj else: k += 1 break # Getting maximal subsequences using stored indices return : I] for l in range(k)]
See also
References
- ^ Spouge, John L.; Ramírez, Leonardo Mariño; Sheetlin, Sergey L. (2014). "Searching for repeats, as an example of using the generalised Ruzzo-Tompa algorithm to find optimal subsequences with gaps". International Journal of Bioinformatics Research and Applications. 10 (4/5): 384–408. doi:10.1504/IJBRA.2014.062991. ISSN 1744-5485. PMC 4135518. PMID 24989859.
- ^ Ruzzo, Walter L.; Martin, Tompa (1999). "A Linear Time Algorithm for Finding All Maximal Scoring Subsequences". Proceedings. International Conference on Intelligent Systems for Molecular Biology: 234–241. ISBN 9781577350835. PMID 10786306.
- "A Linear Time Algorithm for Finding All Maximal Scoring Subsequences" (PDF).
- ^ Karlin, S; Altschul, SF (Jun 15, 1993). "Applications and statistics for multiple high-scoring segments in molecular sequences". Proceedings of the National Academy of Sciences of the United States of America. 90 (12): 5873–5877. Bibcode:1993PNAS...90.5873K. doi:10.1073/pnas.90.12.5873. PMC 46825. PMID 8390686.
- ^ Pasternack, Jeff; Roth, Dan (2009). "Extracting article text from the web with maximum subsequence segmentation". Proceedings of the 18th international conference on World wide web. pp. 971–980. doi:10.1145/1526709.1526840. ISBN 9781605584874. S2CID 346124.
- ^ Liang, Shangsong; Ren, Zhaochun; Weerkamp, Wouter; Meij, Edgar; de Rijke, Maarten (2014). "Time-Aware Rank Aggregation for Microblog Search". Proceedings of the 23rd ACM International Conference on Conference on Information and Knowledge Management. pp. 989–998. CiteSeerX 10.1.1.681.6828. doi:10.1145/2661829.2661905. ISBN 9781450325981. S2CID 14287901.
- Spouge, John L.; Mariño-Ramírez, Leonardo; Sheetlin, Sergey L. (2012). "The ruzzo-tompa algorithm can find the maximal paths in weighted, directed graphs on a one-dimensional lattice". 2012 IEEE 2nd International Conference on Computational Advances in Bio and medical Sciences (ICCABS). pp. 1–6. doi:10.1109/ICCABS.2012.6182645. ISBN 978-1-4673-1321-6. S2CID 14584619.
- "Web Scraping: Everything You Need To Know". Datamam. 2021-07-30. Retrieved 2023-02-16.
- Spouge, John L.; Mariño-Ramírez, Leonardo; Sheetlin, Sergey L. (2012). "The ruzzo-tompa algorithm can find the maximal paths in weighted, directed graphs on a one-dimensional lattice". 2012 IEEE 2nd International Conference on Computational Advances in Bio and medical Sciences (ICCABS). pp. 1–6. doi:10.1109/ICCABS.2012.6182645. ISBN 978-1-4673-1321-6. S2CID 14584619.
Further reading
- Ali, Syed Arslan; Raza, Basit; Malik, Ahmad Kamran; Shahid, Ahmad Raza; Faheem, Muhammad; Alquhayz, Hani; Kumar, Yogan Jaya (2020). "An Optimally Configured and Improved Deep Belief Network (OCI-DBN) Approach for Heart Disease Prediction Based on Ruzzo–Tompa and Stacked Genetic Algorithm". IEEE Access. 8. Institute of Electrical and Electronics Engineers (IEEE): 65947–65958. doi:10.1109/access.2020.2985646. ISSN 2169-3536. S2CID 215817246.