Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially replace cutadapt with seqkit amplicon to simplify primer processing #30

Open
nrminor opened this issue Oct 14, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@nrminor
Copy link
Owner

nrminor commented Oct 14, 2024

Right now, read trimming up to and including primers is very, very complicated. Here's the script block of the process that performs this task:

script:
    amplicon = file(patterns_file).getSimpleName()
    """
    FORWARD_PATTERN=\$(head -n 1 ${patterns_file})
    REVERSE_PATTERN=\$(tail -n 1 ${patterns_file})

    echo "Removing the forward primer: \$FORWARD_PATTERN"
    cutadapt \
    ${untrimmed} \
    -j ${task.cpus} \
    --front \$FORWARD_PATTERN \
    --revcomp \
    --match-read-wildcards \
    --errors ${params.max_mismatch} \
    --untrimmed-output ${barcode}_${amplicon}_fwd.untrimmed.fastq.gz \
    -o tmp.fq

    echo "Removing the reverse primer: \$REVERSE_PATTERN"
    cutadapt \
    tmp.fq \
    -j ${task.cpus} \
    --adapter \$REVERSE_PATTERN \
    --revcomp \
    --match-read-wildcards \
    --errors ${params.max_mismatch} \
    --minimum-length ${params.min_len} \
    --maximum-length ${params.max_len} \
    --untrimmed-output ${barcode}_${amplicon}_rev.untrimmed.fastq.gz \
    -o ${barcode}.${amplicon}.trimmed.fastq.gz && \
    rm tmp.fq
    """

Instead, all the above could be replaced with:

FORWARD_PATTERN=\$(head -n 1 ${patterns_file})
REVERSE_PATTERN=\$(tail -n 1 ${patterns_file})

seqkit amplicon \
-f -r 1:-1 \
--forward \$FORWARD_PATTERN \
--reverse \$REVERSE_PATTERN \
--max-mismatch ${params.max_mismatch} \
--strict-mode \
${barcode}.${amplicon}.trimmed.fastq.gz

Docs for seqkit amplicon are here.

@nrminor nrminor added the enhancement New feature or request label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant