Skip to content

Matching and transformations

Operations wrap an interval and can be composed. Validate the complete geometry because not every operation is meaningful for every shape.

Function Effect
rev(I) Reverse interval I.
revcomp(I) Reverse-complement I.
trunc(I, n) / trunc_left(I, n) Remove n bases from the right/left.
trunc_to(I, n) / trunc_to_left(I, n) Retain a target length from the left/right side.
pad(I, n, A) / pad_left(I, n, A) Add n copies of a nucleotide on the right/left.
pad_to(I, n, A) / pad_to_left(I, n, A) Pad from the right/left to a target length.
remove(I) Consume the interval but remove it from the retained representation.
norm(I) Normalize a variable-length interval to its declared range.

Use seqproc explain to check the direction of left/right transformations in the compiled geometry before applying them to data.

bc = filter(b[8], "barcodes.txt")

filter requires exact membership. The distance-bounded form permits up to n Hamming mismatches while retaining the observed sequence:

bc = filter_within_dist(b[8], "barcodes.txt", 1)

Whitelist files contain one sequence per line; do not add a header, comments, or blank rows. Identical duplicate entries are normalized internally. Approximate filters require equal-length comparisons; use mapping or anchor edit distance when the desired semantics include replacement or indels.

Mapping files place the replacement sequence in the first column and the sequence to match in the second. Columns are tab-separated and there is no header.

AACGTGAT\tAACGTGAA
TGGTGGTA\tTGGTGGTT
bc = map(b[8], "barcode-map.tsv", self)
bc_hamming = map_with_mismatch(b[8], "barcode-map.tsv", self, 1)
bc_edit = map_with_edit(b[8], "barcode-map.tsv", self, 1)

The third argument is the fallback transformation when no mapping is selected; self leaves the observed interval unchanged. Conflicting duplicate mapping keys are rejected because their replacement is not well-defined.

An exact fixed sequence can be named directly:

linker = f[CAGAGC]
1{b[8]<linker>u[10]r:}

Annotations make it approximate or request a relative search:

#[search(relative)]
#[edit(1)]
linker = f[CAGAGC]
1{b[8]<linker>u[10]r:}

#[hamming(n)] permits substitutions only. #[edit(n)] uses Levenshtein distance and can accommodate insertions and deletions. #[search(relative)] locates the anchor relative to the current parsing position and is the preferred spelling of the legacy anchor_relative(...) function.

Choose thresholds from protocol knowledge and controlled validation data; larger search tolerances can improve sensitivity while increasing ambiguous or spurious matches.