Repository navigation
Score all sequence pairs without building alignmentsJd/all pairs scores - #1166
Open
josemduarte wants to merge 2 commits into
Open
josemduarte wants to merge 2 commits into
josemduarte wants to merge 2 commits into
Conversation
Alignments.getAllPairsScores, and the pairwise stage of getMultipleSequenceAlignment, built a full NeedlemanWunsch or SmithWaterman alignment for every pair, with a traceback matrix, only to read its score or its number of identical positions and length. AllPairsScores encodes each sequence once with PairwiseStatisticsAligner and aligns every pair with it, in linear memory and with no traceback. Its score is that of NeedlemanWunsch or SmithWaterman, and its number of identical positions and length are those of the alignment they return, ties included. So GLOBAL, LOCAL, GLOBAL_IDENTITIES and LOCAL_IDENTITIES scoring all take this path, and the scorers it returns for the guide tree have the same scores, maximum and minimum scores as the aligners' (or FractionalIdentityScorer's), hence the same distances and the same multiple alignment. GLOBAL_IDENTITIES is the default of getMultipleSequenceAlignment. Pairs run on the ConcurrencyTools pool, one task per query sequence. Other scorer types, a single sequence, an empty sequence, mixed compound sets, positive gap penalties or compounds outside the compound set of the substitution matrix take the existing path. On 10 cores, all pairs of 100 related proteins of about 300 residues with BLOSUM62 and affine gaps take about 370 ms for GLOBAL and GLOBAL_IDENTITIES and 460-490 ms for LOCAL and LOCAL_IDENTITIES, against 1000-1120 ms with the aligners. AllPairsScoresTest checks score, maximum, minimum, distance and similarity of every pair against the aligners for the four types, with random and related proteins, rare compounds, very different lengths, DNA, six gap penalties and three matrices, local pairs with no positive cell, and the multiple alignment. Co-authored-by: Jose Duarte <jose.m.duarte@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #1161, building on @mikepapadim's work there now that #1164 is merged.
What
Alignments.getAllPairsScoresand the pairwise stage ofgetMultipleSequenceAlignmentbuilt a fullNeedlemanWunschorSmithWatermanalignment for every pair, with a traceback matrix, only to read its score, or its number of identical positions and length.The new package-private
AllPairsScoresencodes each sequence once withPairwiseStatisticsAligner(#1164) and aligns every pair with it, in linear memory and with no traceback. This applies toGLOBAL,LOCAL,GLOBAL_IDENTITIES(the MSA default) andLOCAL_IDENTITIESscoring.NeedlemanWunsch/SmithWaterman. Identicals and length are those of the alignment they return, ties included.FractionalIdentityScorer's). So distances, the guide tree and the multiple alignment are unchanged.ConcurrencyToolspool, one task per query sequence.Performance
getAllPairsScoreson all pairs of 100 related proteins of about 300 residues, with BLOSUM62, affine gaps (10/1) and 10 cores. Times are steady-state medians in ms, each run in a fresh JVM, with identical checksums:Cold first calls are 5–15% slower than these numbers in both columns.
#MMMM had its own score-only copy of the recurrences. That copy is about 2× faster than
PairwiseStatisticsAlignerfor plainGLOBAL/LOCAL, but it would have been a third copy alongsideAlignerHelperandPairwiseStatisticsAligner, and it couldn't serve the*_IDENTITIEStypes. This PR keeps a single kernel. Single-threaded numbers for all three variants are in the comments on #MMMM.Tests
AllPairsScoresTestchecks the score, max, min, distance and similarity of every pair against the aligners, for all four types. The cases cover:mvn testinbiojava-alignmentpasses: 152 tests, 1 skipped, which was already skipped before this PR.🤖 Generated with Claude Code