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

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)

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

Installation

You can install directly with pip.

git clone https://github.com/maguire-lab/chamred && cd charmed
pip install .

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

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.0.tar.gz (610.2 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.0-py3-none-any.whl (691.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chamred-0.4.0.tar.gz
  • Upload date:
  • Size: 610.2 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.0.tar.gz
Algorithm Hash digest
SHA256 020104c0e98322167ffa3dd5d3097c9e1e6315cae9a0a85cdcfc7c471190c82c
MD5 20eed115f9707c73e0d1f7caed873e14
BLAKE2b-256 1c8d2e9a0a1273e7c5b5e8c3624a42aa5eff0a695086968dc60b889ed3db33fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for chamred-0.4.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: chamred-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 691.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89af49d56fdf54b38ee950d42cb71eac139f489ac6a17f456ba05a657abe1de4
MD5 d6e630bc4ce9ebcd2535bff803c68e98
BLAKE2b-256 2f54899a8ae76a03faf4d6c110297cc69263624772a3d2a9993cc430c67f32ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for chamred-0.4.0-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