Trim a Peptide Leaderboard solved by 386

Sept. 7, 2015, 4:11 p.m. by Rosalind Team

The Trim algorithm, shown below, sorts all peptides in Leaderboard according to their scores, resulting in a sorted Leaderboard. Trim> then retains the top N scoring peptides including ties, and removes all other peptides from Leaderboard.

Trim(Leaderboard, Spectrum, N, AminoAcid, AminoAcidMass) for j ← 1 to |Leaderboard| Peptidej-th peptide in Leaderboard LinearScores(j) ← LinearScore(Peptide, Spectrum) sort Leaderboard according to the decreasing order of scores in LinearScores sort LinearScores in decreasing order for jN + 1 to |Leaderboard| if LinearScores(j) < LinearScores(N) remove all peptides starting from the j-th peptide from Leaderboard return Leaderboard return Leaderboard

Trim Problem

Trim a leaderboard of peptides.

Given: A leaderboard of linear peptides Leaderboard, a linear spectrum Spectrum, and an integer N.

Return: The top N peptides from Leaderboard scored against Spectrum. Remember to use LinearScore.

Sample Dataset

LAST ALST TLLT TQAS
0 71 87 101 113 158 184 188 259 271 372
2

Sample Output

LAST ALST

Extra Dataset

Please login to solve this problem.