Repository navigation
Add --trim-poly-tails to remove poly(A) tails and poly(T) heads (#37) - #86
Merged
Merged
Conversation
Off by default. Tails are found as cutadapt's --poly-a does: scanning in from the read end, +1 for each A (T at the start, U counting as T), -2 for anything else, cutting where the score peaks with at most 20% other bases, so sequencing errors inside a tail are tolerated. Runs shorter than the minimum length are left alone: --trim-poly-tails uses 10, --trim-poly-tails 15 sets another. Tails must reach the read end, so adapters have to be removed first. Applied after --trim-approach to the outer ends of the read only, by narrowing the kept ranges, so --update-mods and BAM output work as is. Validated on simulated reads with ONT-like errors up to 15%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closed
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.
Closes #37. Adds removal of poly(A) tails and poly(T) heads from RNA and cDNA reads. It is off by default: default output is unchanged, and the v0.14.1 digest test still passes.
Usage
--trim-poly-tailsremoves a poly(T) head from the start and a poly(A) tail from the end of each read; U counts as T. Both ends are trimmed because cDNA reads come in both orientations. Runs shorter thanMIN_LENGTH(default 10) are left alone.--trim-poly-tails 15or--trim-poly-tails=15sets another minimum. chopper has no positional arguments, so the optional value can't be confused with anything else:--trim-poly-tails -i x.fquses the default.How tails are found
The scoring is the same as cutadapt's
--poly-a(poly_a_trim_indexinqualtrim.pyx):This tolerates sequencing errors inside the tail without running on into the transcript.
The one difference from cutadapt is the default minimum: 10 instead of 3. In simulation, a minimum of 3 trimmed about 3% of reads that have no tail, because they end in "AAA" by chance; 10 trims about 0.1% and loses nothing on real tails.
Anchored only: the tail must reach the end of the read, so adapters and primers have to be removed first, for example by the basecaller or
dorado trim. A few leftover bases past a tail are removed with it, as long as the whole stays within the 20%.How it fits
--trim-approachand narrows only the outer ends of the kept segments: a polyT head off the first segment and a polyA tail off the last. Interior split points are not read ends and are left alone.(start, end)ranges,--update-mods, uBAM output and segment naming work without changes. A test checks that a modification call stays on its base.--minlengthis checked again afterwards.Validation (simulated only)
ONT-like errors: half deletions, a quarter substitutions, a quarter insertions. 400 bp body, 10,000 reads per condition, run through the release binary:
Body bases are lost when a body happens to start with T or end with A. Those bases can't be told apart from a tail, so no method avoids this.
Not yet validated on real reads: the data at hand isn't adapter-clipped.
Tests
make cipasses: 80 unit tests (8 new, including a seeded simulation at 2–15% errors) and 21 end-to-end tests (2 new).🤖 Generated with Claude Code