Skip to main content

Package to find the equivalent antibiotic resistance genes (ARGs) in other databases based on ARG(s) from one AMR determinant database

Project description

ChAMReD

PyPI version

This project originated from the dilemma a scientist faces when choosing a database that stores antimicrobial resistance determinants. Multiple databases exist with comparative strengths and weaknesses. This project builds on the concepts of the haAMRonization project aiming to aggeregate and combine the information contained within the metadata associated with each project. The problem is exacerbated by the fact that the equivalent antimicrobial resistance genes (ARGs) can be named differently in each database.

The hypothesis for the project is as follows:

  • Given a match in one database find the matches in other databases and vice versa (reciprocal best hits)
  • Aggregate the combined descriptive information pertaining to antimicrobial resistance contained in the union of the metadata
  • Report this to user for them to make intelligent informed choices

The tool is split into two parts - a workflow to buld the databases (chamrdb-builder) and this the chamrdb tool itself (this repo) for querying and annotating hAMRonization results.

Current integrated database versions:

  • NCBI 4.2 (2026-03-24.1)

  • ResFinder 2026-03-11 & PointFinder 2026-03-11

  • CARD 4.0.1 (2025-05-29)

Installation

You can install directly with pip.

pip install chamred

Querying the graph

> charmed query --help

usage: chamred query [-h] [-d {card,ncbi,resfinder}] [-ct COVERAGE_THRESHOLD]
                     [-it IDENTITY_THRESHOLD] (-i ID | -f ID_FILE |
                     -j HAMRONIZATION_JSON_FILE) [-o OUTFILE_PATH]

options:
  -h, --help            show this help message and exit
  -d, --database {card,ncbi,resfinder}
                        which database are the gene(s) in
  -ct, --coverage_threshold COVERAGE_THRESHOLD
                        coverage threshold below which a match will not be
                        reported
  -it, --identity_threshold IDENTITY_THRESHOLD
                        identity threshold below which a match will not be
                        reported
  -i, --id ID           The id of a ARG in the specified database
  -f, --id_file ID_FILE
                        Path to a file containing ids of ARGs in the specified
                        database
  -j, --hamronization_json_file HAMRONIZATION_JSON_FILE
                        Path to a hamronization summaty in JSON format
  -o, --outfile_path OUTFILE_PATH
                        Path to file where query results will be written

The graph can be queried in one of 3 ways

1. Querying an individual

Requires specifying the identifier -i and database -d

chamred query -d ncbi -i WP_012695489.1 

Alternatively the gene name can be used

chamred query -d ncbi -i qnrB2

The output reports the matches and metadata from the other databases
qnrB2

Another example where the matches are one way hits not RBHs

chamred query -d resfinder -i "aac(3)-IIIb"

aac(3)-IIIb In these outputs ↔ means a RBH, and ➡ a search hit

2. Providing a list of identifiers from a single database

Requires specifying the database -d, the text file containing the ids -f, and a path for the tsv output file -o

grep "^>" chamred/data/db_fastas/card.protein.fasta  | sed 's/>//' > card_ids.txt
chamred query -d card -f card_ids.txt  -o docs/card_vs_ncbi_resfinder.tsv

This will produce a TSV file containing the matches and associated metadata with one row per id in the text file

3. Use hAMRonization summary output

Use the hAMRonization softare to convert the outputs from antimicrobial resistance gene detection tools into a unified format. Concatenate and summarize AMR detection reports into a single summary JSON file using the hamronize summarize command from this package. The JSON output from this step can be used to query ChamreDb.
Use -j to specify the json summary file and -o the path for the TSV output
Please Note
Only outputs using data derived from AMR detection tools that have searched either the CARD, NCBI or Resfinder 4 databases can be used.

chamred query -j docs/data/hamronize_summary.json -o docs/data/hamronize_summary.tsv

This will produce a TSV file containing the matches and associated metadata with one row per id in the text file

Contributors

Finlay Maguire

Anthony Underwood

Adam Witney

Alex Manuele

Inês Mendes

Thanh Le Viet

Trestan Pillonel

Varun Shamanna

Database Builder: chamrdb-builder

This workflow follows these steps to build the database.

  • Download sequences and associated metadata of ARGs from 3 databases

  • Parse the data to

    • extract the protein sequences and write into fasta format with the gene identifiers as the record ids.
    • extract the associated metadata and convert to a consistent JSON format
  • Find best matches of each gene from one source database against the other two target databases using MMseqs2

    • Where a reciprocal best hit (RBH) exists, report this.
    • If a RBH does not exist, report the best match as long as thresholds for coverage and indentity are met.
  • From the outputs of the MMseqs2 searches the RBHs or best matches of each gene from one database against the other two databases can be parsed to produce a Directed Graph using networkx. In this graph

    • the nodes represent a protein from one database
      • Node attributes contain the phenotype from the JSON metadata
    • the edges link nodes and represent the matches and attributes include
      • type, either RBH or OWH (one way hit)
      • coverage, (alignment length/query length)
      • identity, (percent identity of match)
        See the image below for a pictoral example using made up data



network diagram

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

chamred-0.4.1.tar.gz (610.3 kB view details)

Uploaded Source

Built Distribution

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

chamred-0.4.1-py3-none-any.whl (691.8 kB view details)

Uploaded Python 3

File details

Details for the file chamred-0.4.1.tar.gz.

File metadata

  • Download URL: chamred-0.4.1.tar.gz
  • Upload date:
  • Size: 610.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chamred-0.4.1.tar.gz
Algorithm Hash digest
SHA256 f702190e7813f0be9db861e2dd3d8094fffc525e06ea9fdf957da768a9792abb
MD5 b8ae4ecb999eb98a5ecde3d6213119c1
BLAKE2b-256 b8b896b813bb7f92cdcb74df90856928529b75c13748ec7c834a8c06949716d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for chamred-0.4.1.tar.gz:

Publisher: publish.yml on maguire-lab/chamred

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chamred-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: chamred-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 691.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chamred-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 925503cf37785385a906bdbe02ece8b432a2f9584179d1babd9e4b5877ef32c9
MD5 00b32cdf4993867c499d7321b5e7ee39
BLAKE2b-256 de07e82e8098b0b714f8c6f938156737d21da2de87481d5ee6d59b17f39310d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for chamred-0.4.1-py3-none-any.whl:

Publisher: publish.yml on maguire-lab/chamred

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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