Repository navigation
fix(parser): strip only the TSO's G-run (tso_g_max=3), not every leading G - #15
Merged
Merged
Conversation
parse_barcodes did s[36:].lstrip("G"), which also removed genuine 5'
Gs of the insert after the TSO's rGrGrG. Strip at most tso_g_max Gs
(default 3). New run() options tso_g_max (CLI --tso_g_max) and legacy
(CLI --legacy); legacy=True restores lstrip("G") exactly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e tso_g_max/legacy) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bnemoz
added a commit
that referenced
this pull request
Nov 17, 2026
- legacy=True now forces both tso_g_max=None and barcode_prefer_exact=False
- parse_barcodes takes tso_g_max, prefer_exact and return_counts together
- fix a silent semantic conflict: the new exact-hit orientation path still used
s[36:].lstrip("G"), which would have bypassed #15 for nearly every read; it now uses
strip_tso_g(s[36:], tso_g_max). Added tests covering both orientation paths.
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.
Problem
parse_barcodestakes the insert ass[36:].lstrip("G"). Read layout: barcode 16 + UMI 10 + TSOTTTCTTATATGGG, where positions 26–35 areTTTCTTATATand the TSO's rGrGrG run starts at position 36.lstrip("G")removes the TSO run and also every genuine G at the 5′ end of the insert.In SimPlex the cDNA starts directly at FR1 codon 1. That codon begins with G for many genes (e.g.
GAC ATC…,GAA ATT…,GAG GTG…), sov2-basecuts the first V base off those chains. In real data the insert starts in the 5′UTR, so the bases lost there sit outside V(D)J.Fix
strip_tso_g(sequence, tso_g_max)inutils.pyremoves at mosttso_g_maxleading Gs.parse_barcodes(..., tso_g_max=3)uses it.run()arguments, documented in the docstring:tso_g_max: int = 3(CLI--tso_g_max);legacy: bool = False(CLI--legacy).legacy=Trueforceslstrip("G").pairplex correct-barcodesalso callsparse_barcodes, so it gets the new default too. It has no legacy flag.G-run length at position 36 (real data, barcode-first orientation)
Method: stream the reads of one real memory-B-cell well; the file holds 111,307 reads, all of them parsed. Use the same orientation logic as
parse_barcodes; 99.998% of reads are barcode-first. Count the run of Gs starting at position 36. The "exact TSO" column keeps only reads whose positions 26–35 read exactlyTTTCTTATAT. A second well (first 200k reads) gives the same shape (table below).Second well, exact-TSO reads (n=24,642): 0: 22.4%, 1: 21.5%, 2: 12.8%, 3: 10.2%, 4: 16.1%, 5: 11.7%, 6: 2.3%, 7: 2.3%, 8+: 0.6%.
Reading the distribution
TTTCTTATAT. G is still the most common base at positions 36–39 (55%, 47%, 48%, 68%), well above the ~25–30% G seen from position 42 on.lstripdid.tso_g_max=4to strip one non-templated G as well.Tests
New file
pairplex/tests/test_tso_g_strip.py:strip_tso_gedge cases (k = 0, 3, 4, None; short runs; empty strings);parse_barcodeson constructed reads (…TTTCTTATATGGG+GGACAGTCkeepsGGACAGTCat k = 3);run()default keeps a genuine 5′ G, andlegacy=Truerestoreslstrip, even whentso_g_maxis set as well;tso_g_maxvalues are rejected.Full suite: 36 passed.
Smoke run on 2 SimPlex wells with 2 workers: with
legacy=Truethe metadata, annotated paired/unpaired tables and consensus sequences matchv2-baseexactly (consensus FASTA records come out in a different order because ofas_completed). With the default, the consensus set changes slightly: well000 has 893 → 892 metadata rows and 736 → 735 annotated sequences.Benchmark
Pending:
D3-tso-g3-v1(defaulttso_g_max=3) vsv2-base. Results will be added here.🤖 Generated with Claude Code