Skip to content

Annotate pattern regions with custom match-modes #2

Description

@jakob-schuster

The user can specify error rate globally with --error-rate, but they can also override it per-region with ~.

# match with a 0.2 error rate
if read matches [_ AGCTAGCTAG~0.2 _] => count!('contains primer')

Currently, the user can also specify match mode globally with --match-mode, but they cannot override it per-region; this would be a useful feature for fine-tuning the matching behaviour where necessary. Even though this would make these patterns more verbose, it would only be for niche scenarios where the user needs to specify fine-grained match semantics.

if read matches [_ GGG::{mode='all'} _ AAA::{mode='first'} _] => count!('match')
TTTTTTTGGGTTTTTTTTGGGTTTTTTAAATTTTTAAATTTTT
a      ^^^.................^^^
b                 ^^^......^^^
c      ^^^.........................^^^
d                 ^^^..............^^^

For this read, only the matches {a, b} are identified; all occurrences of GGG are matched, but only the first occurrence of AAA.

Maybe a more practical example, this could be used to specify matching to the end of a poly(A) tail:

# extract everything from the first occurrence of a primer to the end of a >=16bp poly(A) tail.
if read matches [_ trimmed:(AGCTAGCTAG::{error=0.2, mode='first'} _ AAAAAAAAAAAAAAAA::{error=0, mode='last'}) _ ] =>
  trimmed.out!('out.fq')

By using a struct for these annotations, we would allow for both mode and distance to be specified with GGG::{error=0.2, mode='all'}, and allow for future extensions to what can be annotated in this way. Existing syntax GGG~0.2 could be retained but treated as sugar for GGG::{error=0.2}. The double-colon :: is just a first thought of course; alternative syntax ideas welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions