Skip to content

Prune chain candidates that cannot start a chain - #654

Open
ksahlin wants to merge 1 commit into
mainfrom
prune-chain-candidates
Open

ksahlin wants to merge 1 commit into
mainfrom
prune-chain-candidates

Conversation

@ksahlin

@ksahlin ksahlin commented Oct 10, 2026

Copy link
Copy Markdown
Owner

extract_chains sorts all anchors with a score of at least 0.7 times the
best score (the candidates) and then starts a chain from each candidate
that is not yet part of another chain. An anchor j that is the
predecessor of a candidate i with a strictly higher score can never
start a chain: i comes before j in the sorted list, and when it is i's
turn, either i is unused and its walk visits j first, or i was already
marked as used by a walk that continued to j.

Such anchors are now removed from the candidates before sorting. They
are marked in the loop that collects the candidates (by setting their
score to -inf, which cannot be a real score), so no extra pass over the
anchors is needed. Output is unchanged.

Speedup on an Apple M4 Max, -x, 1 thread, median of 5 runs:

  • maize, 50 nt reads: chaining -3% to -4.5%, total mapping time -3%
  • maize, 150 nt reads: chaining -1.5% to -2%, total mapping time -1%
  • rye, 50 nt reads: chaining -3%
  • chrY, CHM13, rye 150 nt and all 10 kb reads: unchanged

If the speedup is very marginal also when evaluated independently,
it might not be worth it. Let's discuss.

extract_chains sorts all anchors with a score of at least 0.7 times the
best score (the candidates) and then starts a chain from each candidate
that is not yet part of another chain. An anchor j that is the
predecessor of a candidate i with a strictly higher score can never
start a chain: i comes before j in the sorted list, and when it is i's
turn, either i is unused and its walk visits j first, or i was already
marked as used by a walk that continued to j.

Such anchors are now removed from the candidates before sorting. They
are marked in the loop that collects the candidates (by setting their
score to -inf, which cannot be a real score), so no extra pass over the
anchors is needed. Output is unchanged.

Speedup on an Apple M4 Max, -x, 1 thread, median of 5 runs:

- maize, 50 nt reads: chaining -3% to -4.5%, total mapping time -3%
- maize, 150 nt reads: chaining -1.5% to -2%, total mapping time -1%
- rye, 50 nt reads: chaining -3%
- chrY, CHM13, rye 150 nt and all 10 kb reads: unchanged

If the speedup is very marginal also when evaluated independently,
it might not be worth it. Let's discuss.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant