PORECHOP_ABI

https://img.shields.io/badge/wrapper_version-v9.10.0-10785b https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/porechop_abi?label=version%20update%20pull%20requests&color=1cb481

Adapter trimming for Oxford Nanopore reads with optional ab initio adapter inference.

URL: https://github.com/bonsai-team/Porechop_ABI

Example

This wrapper can be used in the following way:

rule porechop_abi:
    input:
        fq="data/reads.fasta",
    output:
        fq="treated/trimmed.fasta",
        consensus="treated/consensus.fasta",
    log:
        "logs/porechop_abi.log",
    threads: 2
    resources:
        mem_mb=1024,
    params:
        ab_initio=True,
    wrapper:
        "v9.10.0/bio/porechop_abi"

Note that input, output and log file paths can be chosen freely.

When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Software dependencies

  • porechop_abi=0.5.1

Input/Output

Input:

  • fq: one FASTA/FASTQ read file (can be gzipped)

  • ab_initio_config: custom ab initio config file (optional)

  • custom_adapters: custom adapters file (optional)

Output:

  • fq: one trimmed FASTA/FASTQ read file

  • consensus: consensus export file (only available with params.ab_initio=True)

Params

  • extra: additional program arguments

  • ab_initio: run adapter inference before trimming (bool, default: False)

Authors

  • Artur Gomes

Code

"""Snakemake wrapper for porechop_abi."""

__author__ = "Artur Gomes"
__copyright__ = "Copyright 2026, Artur Gomes"
__email__ = "arafaelogomes@gmail.com"
__license__ = "MIT"

import tempfile

from snakemake.shell import shell

extra = snakemake.params.get("extra", "")
ab_initio = snakemake.params.get("ab_initio", False)
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

ab_initio_flag = "--ab_initio" if ab_initio else ""
ab_initio_config = snakemake.input.get("ab_initio_config", "")
if ab_initio_config:
    ab_initio_config = f"--ab_initio_config {ab_initio_config}"

custom_adapters = snakemake.input.get("custom_adapters", "")
if custom_adapters:
    custom_adapters = f"--custom_adapters {custom_adapters}"

consensus = snakemake.output.get("consensus", "")
if consensus:
    if not ab_initio:
        raise ValueError("output.consensus requires params.ab_initio=True")
    else:
        consensus = f"--export_consensus {consensus}"

with tempfile.TemporaryDirectory() as tmpdir:
    shell(
        "porechop_abi"
        " -i {snakemake.input.fq:q}"
        " -o {snakemake.output.fq:q}"
        " -t {snakemake.threads}"
        " -tmp {tmpdir:q}"
        " {ab_initio_flag}"
        " {ab_initio_config}"
        " {custom_adapters}"
        " {consensus}"
        " {extra}"
        " {log}"
    )