Skip to main content

Parser for ResFinder output data

Project description

ResFinderParser

PyPI version PyPI pyversions License PyPI format

Harmonizing ResFinder outputs for scalable AMR analysis

ResFinderParser is a Python tool that parses and standardizes JSON outputs generated by ResFinder (CGE/DTU) across multiple isolates. It compiles per-sample resistance detection results into structured, analysis-ready tabular datasets.

ResFinder integrates multiple resistance detection layers, including acquired resistance genes (ResFinder database), chromosomal mutations (PointFinder), disinfectant-associated determinants (DisinFinder), and predicted phenotypic resistance. Although biologically comprehensive, these outputs are generated independently for each isolate and are not directly optimized for cross-sample analyses.

The parser restructures these results into harmonized matrices suitable for:

  • Antimicrobial resistance (AMR) surveillance
  • Comparative resistance profiling
  • Resistance frequency and trend analysis
  • Integration into automated genomic analysis pipeline

By transforming nested JSON outputs into standardized TSV files, the tool enables scalable genomic resistance analyses across research and surveillance contexts.

Requirements

  • Python 3.8+
  • pandas 2.0+

Installation

Using Poetry (recommended)

poetry install

Using pip

pip install resfinder-parser

Input

ResFinderParser expects the JSON output files generated by ResFinder. The tool should be run on a directory containing one subfolder per isolate, each including the corresponding ResFinder *.json file (and, if available, PointFinder and DisinFinder results).

Example structure:

RESFINDER_DIR/
├── ISOLATE_001/
│   └── ResFinder_results.json
├── ISOLATE_002/
│   └── ResFinder_results.json
└── ...

The parser extracts resistance genes, chromosomal mutations, disinfectant-associated determinants, and predicted phenotypes directly from the JSON structure.

Outputs

The parser generates four standardized TSV files:

  1. isolate_summaries.tsv One row per isolate containing:

    • isolate_id
    • analysis_date
    • ResFinder version
    • databases used
    • provided species
    • predicted phenotype summary Useful for run tracking and dataset documentation.
  2. resfinder_results.tsv Long-format table (isolate × antibiotic) including:

    • antibiotic
    • resistance class
    • amr_resistant (True/False)
    • identity
    • coverage
    • grade Suitable for resistance frequency analysis and comparative profiling.
  3. pointfinder_results.tsv Long-format mutation table including:

    • gene
    • mutation
    • nucleotide change
    • associated phenotype
    • PMID Enables mutation-level resistance analysis.

  1. combined_presence_absence.tsv Wide-format matrix:
    • One row per isolate
    • One column per detected gene (ResFinder + DisinFinder)
    • One column per relevant mutation (PointFinder) Designed for comparative analyses, clustering, and integration with epidemiological metadata. All outputs are directly compatible with R, Python (pandas), and automated genomic analysis pipelines.

Usage

Command Line

resfinder-parser -r /path/to/RESFINDER_DIR -o /path/to/output_dir

As a Python Module

from resfinder_parser import ResfinderCollector

collector = ResfinderCollector("/path/to/RESFINDER_DIR", "/path/to/output_dir")
collector.collect()

Arguments:

  • -r, --resfinder_dir (required): directory containing isolate subfolders
  • -o, --output_dir (optional): directory where output files will be written

Development

Run tests:

poetry run pytest

Citation

We recommend citing ResFinder (this repository) and its associated databases:

  • Zankari et al., 2012. Journal of Antimicrobial Chemotherapy.
  • Florensa et al., 2022. Microbial Genomics.
  • CGE/DTU ResFinder platform.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resfinder_parser-0.3.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resfinder_parser-0.3.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file resfinder_parser-0.3.0.tar.gz.

File metadata

  • Download URL: resfinder_parser-0.3.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.12 Linux/6.8.0-101-generic

File hashes

Hashes for resfinder_parser-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6c91a090c0d8fc6432f2855dd23a61d9802ee1e705abd070189816d712beaf1e
MD5 f3257e052980fe0dd09d69d5baa5e199
BLAKE2b-256 c64236348d7d07f2f3f22d8f8fa7334e1a751955e4b6b4d297582380dbdec845

See more details on using hashes here.

File details

Details for the file resfinder_parser-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: resfinder_parser-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.12 Linux/6.8.0-101-generic

File hashes

Hashes for resfinder_parser-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c64f9663b9a2a0b5a31b6ffa1412f2a38f045e6d9a040d9e3758410d3abad35
MD5 5b25fda2d5546c21c7f9713d8dae01ab
BLAKE2b-256 4109fc09a4d05fd7fee2c78182c2f0d45c74d237a988bbd6fbed653e857d5549

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page