hAMRonization 1.3.1__tar.gz → 1.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hamronization-1.3.1 → hamronization-1.4.1}/PKG-INFO +79 -12
- {hamronization-1.3.1 → hamronization-1.4.1}/README.md +77 -10
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/AmrFinderPlusIO.py +58 -13
- hamronization-1.4.1/hAMRonization/DatabaseMapping.py +453 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/Interfaces.py +53 -3
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/RgiIO.py +6 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/TBProfilerIO.py +22 -9
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/__init__.py +1 -1
- hamronization-1.4.1/hAMRonization/data_sources.py +90 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization.egg-info/PKG-INFO +79 -12
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization.egg-info/SOURCES.txt +4 -1
- {hamronization-1.3.1 → hamronization-1.4.1}/setup.cfg +1 -1
- {hamronization-1.3.1 → hamronization-1.4.1}/setup.py +26 -2
- hamronization-1.4.1/test/test_db_mapping.py +249 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/test/test_parsing_validity.py +84 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/LICENSE.txt +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/AbricateIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/AmrPlusPlusIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/AribaIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/CSStarIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/DeepArgIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/FARGeneIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/GrootIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/KmerResistanceIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/MykrobeIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/ResFamsIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/ResFinderIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/SraxIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/Srst2IO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/StarAmrIO.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/constants.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/hAMRonizedResult.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/hamronize.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization/summarize.py +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization.egg-info/dependency_links.txt +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization.egg-info/entry_points.txt +0 -0
- /hamronization-1.3.1/hAMRonization.egg-info/zip-safe → /hamronization-1.4.1/hAMRonization.egg-info/not-zip-safe +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization.egg-info/requires.txt +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/hAMRonization.egg-info/top_level.txt +0 -0
- {hamronization-1.3.1 → hamronization-1.4.1}/test/test_interfaces.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hAMRonization
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Tool to convert and summarize AMR gene detection outputs using the hAMRonization specification
|
|
5
5
|
Home-page: https://github.com/pha4ge/hAMRonization
|
|
6
|
-
Download-URL: https://github.com/pha4ge/archive/v1.
|
|
6
|
+
Download-URL: https://github.com/pha4ge/archive/v1.4.1.tar.gz
|
|
7
7
|
Author: Finlay Maguire
|
|
8
8
|
Author-email: finlaymaguire@gmail.com
|
|
9
9
|
License: LGPLv3
|
|
@@ -83,8 +83,8 @@ conda create --name hamronization --channel conda-forge --channel bioconda hamro
|
|
|
83
83
|
|
|
84
84
|
Or to install and run using docker, podman, singularity:
|
|
85
85
|
```
|
|
86
|
-
docker pull
|
|
87
|
-
docker run --rm
|
|
86
|
+
docker pull ghcr.io/pha4ge/hamronization:latest
|
|
87
|
+
docker run --rm ghcr.io/pha4ge/hamronization:latest hamronize --help
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
Or to install the latest development version:
|
|
@@ -169,6 +169,50 @@ and they will be concatenated appropriately (i.e. only one header for tsv)
|
|
|
169
169
|
hamronize rgi --input_file_name rgi_report --analysis_software_version 6.0.0 --reference_database_version 3.2.5 test/data/raw_outputs/rgi/rgi.txt test/data/raw_outputs/rgibwt/Kp11_bwtoutput.gene_mapping_data.txt
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
+
#### Mapping to other AMR databases (RGI, AMRFinderPlus, ResFinder)
|
|
173
|
+
|
|
174
|
+
The results of `rgi` (CARD), `amrfinderplus` (NCBI Reference Gene Database) and
|
|
175
|
+
`resfinder` (ResFinder) can optionally be mapped to the other two of these
|
|
176
|
+
databases with `--db_mapping chamredb` or `--db_mapping argnorm`:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
hamronize amrfinderplus --db_mapping chamredb --analysis_software_version 4.0.3 --reference_database_version 2024-07-22.1 --input_file_name sample1 amrfinderplus_report.tsv
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This appends a `<database>_mapping` column for each of the other two databases
|
|
183
|
+
(e.g. `card_mapping` and `resfinder_mapping` for AMRFinderPlus) and a
|
|
184
|
+
`database_mapping_source` column recording which resource was used. Multiple
|
|
185
|
+
mapped entries are separated by ` | `, and the columns are left empty where no
|
|
186
|
+
mapping is found.
|
|
187
|
+
|
|
188
|
+
- [chamredb](https://github.com/antunderwood/chamredb) uses a graph of
|
|
189
|
+
reciprocal best hits (RBH) between CARD, NCBI and ResFinder sequences. The
|
|
190
|
+
RBHs are reported for each database, or the one-way hits (OWH) where there is
|
|
191
|
+
no RBH, with their identity and coverage, e.g.
|
|
192
|
+
`ARO:3001022 (TEM-156; RBH; identity=1.0; coverage=1.0)`. Hits are looked up
|
|
193
|
+
by accession, then by gene name.
|
|
194
|
+
- [argNorm](https://github.com/BigDataBiology/argNorm) maps NCBI and ResFinder
|
|
195
|
+
genes onto CARD ARO terms, e.g. `ARO:3001022 (TEM-156; Perfect)`. Mappings
|
|
196
|
+
from CARD, and between NCBI and ResFinder, go via the ARO term, e.g.
|
|
197
|
+
`blaTEM-156 (blaTEM-156_1_AM941159; via ARO:3001022; Perfect)`. argNorm's
|
|
198
|
+
`Loose` matches are not used for these indirect mappings, and only the best
|
|
199
|
+
available cut-off is reported. Alleles sharing a gene name are grouped
|
|
200
|
+
(`+N more`).
|
|
201
|
+
|
|
202
|
+
Pinned copies of chamredb's
|
|
203
|
+
[`graph.json`](https://github.com/antunderwood/chamredb/blob/master/chamredb/data/graph.json)
|
|
204
|
+
(2026-11-09 graph) and argNorm's (v1.1.0)
|
|
205
|
+
[mapping tables](https://github.com/BigDataBiology/argNorm/tree/main/argnorm/data)
|
|
206
|
+
are downloaded, with their checksums verified, when hAMRonization is installed
|
|
207
|
+
(see `hAMRonization/data_sources.py`). This needs network access at install
|
|
208
|
+
time. Set `HAMRONIZATION_SKIP_DATA_DOWNLOAD=1` to install without them. To use
|
|
209
|
+
a different copy, pass `--db_mapping_data` with the path to a `graph.json` or
|
|
210
|
+
an argNorm `data` directory. Both resources were built against specific
|
|
211
|
+
database releases, so genes added more recently may not map.
|
|
212
|
+
|
|
213
|
+
When `--db_mapping` is used, `hamronize` prints what to cite to stderr (see
|
|
214
|
+
[Citation](#citation)).
|
|
215
|
+
|
|
172
216
|
You can summarize hAMRonized reports regardless of format using the 'summarize'
|
|
173
217
|
function:
|
|
174
218
|
|
|
@@ -225,6 +269,17 @@ You can also output a `json` formatted hAMRonized report:
|
|
|
225
269
|
|
|
226
270
|
`parsed_report.write('all_hAMRonized_abricate_report.json', output_format='json')`
|
|
227
271
|
|
|
272
|
+
To add the database mapping columns (see above) when writing an `rgi`,
|
|
273
|
+
`amrfinderplus` or `resfinder` report, pass a mapper; `mapper.map(result)` also
|
|
274
|
+
returns the mapping for a single result as a dict:
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
from hAMRonization.DatabaseMapping import get_mapper
|
|
278
|
+
mapper = get_mapper("argnorm", "rgi") # or get_mapper("chamredb", "rgi", "path/to/graph.json")
|
|
279
|
+
print(mapper.citation_message) # what to cite for this mapping
|
|
280
|
+
hAMRonization.parse("rgi.txt", metadata, "rgi").write(output_location="rgi.tsv", db_mapper=mapper)
|
|
281
|
+
```
|
|
282
|
+
|
|
228
283
|
If you want to write multiple reports to one file, this `.write` method can accept `append_mode=True` to append rather than overwrite the output file and not include the header (in tsv format).
|
|
229
284
|
|
|
230
285
|
`parsed_report.write('all_hAMRonized_abricate_report.tsv', append_mode=True)`
|
|
@@ -234,24 +289,24 @@ If you want to write multiple reports to one file, this `.write` method can acce
|
|
|
234
289
|
|
|
235
290
|
Currently implemented parsers and the last tool version for which they have been validated:
|
|
236
291
|
|
|
237
|
-
1. [abricate](hAMRonization/AbricateIO.py): last updated for v1.
|
|
238
|
-
2. [amrfinderplus](hAMRonization/AmrFinderPlusIO.py): last updated for v4.
|
|
239
|
-
3. [amrplusplus](hAMRonization/AmrPlusPlusIO.py): last updated for
|
|
292
|
+
1. [abricate](hAMRonization/AbricateIO.py): last updated for v1.4.0
|
|
293
|
+
2. [amrfinderplus](hAMRonization/AmrFinderPlusIO.py): last updated for v4.2.7
|
|
294
|
+
3. [amrplusplus](hAMRonization/AmrPlusPlusIO.py): last updated for v4 (MEGARes v4.00)
|
|
240
295
|
4. [ariba](hAMRonization/AribaIO.py): last updated for v2.14.6
|
|
241
296
|
5. [csstar](hAMRonization/CSStarIO.py): last updated for v2.1.0
|
|
242
|
-
6. [deeparg](hAMRonization/DeepArgIO.py): last updated for
|
|
297
|
+
6. [deeparg](hAMRonization/DeepArgIO.py): last updated for v2.0.0
|
|
243
298
|
7. [fargene](hAMRonization/FARGeneIO.py): last updated for v0.1
|
|
244
299
|
8. [groot](hAMRonization/GrootIO.py): last updated for v1.1.2
|
|
245
300
|
9. [kmerresistance](hAMRonization/KmerResistanceIO.py): late updated for v2.2.0
|
|
246
301
|
10. [mykrobe](test/data/raw_outputs/mykrobe/report.json): last updated for v0.8.1
|
|
247
302
|
11. ~pointfinder~ (removed, PointFinder is now integrated in ResFinder)
|
|
248
303
|
12. [resfams](hAMRonization/ResFamsIO.py): last updated for hmmer v3.3.2
|
|
249
|
-
13. [resfinder](hAMRonization/ResFinderIO.py): last updated for v4.
|
|
250
|
-
14. [rgi](hAMRonization/RgiIO.py) (includes RGI-BWT) last updated for
|
|
304
|
+
13. [resfinder](hAMRonization/ResFinderIO.py): last updated for v4.7.3
|
|
305
|
+
14. [rgi](hAMRonization/RgiIO.py) (includes RGI-BWT) last updated for v6.0.8
|
|
251
306
|
15. [srax](hAMRonization/SraxIO.py): last updated for v1.5
|
|
252
307
|
16. [srst2](hAMRonization/Srst2IO.py): last updated for v0.2.0
|
|
253
|
-
17. [staramr](hAMRonization/StarAmrIO.py): last updated for v0.
|
|
254
|
-
18. [
|
|
308
|
+
17. [staramr](hAMRonization/StarAmrIO.py): last updated for v0.12.3
|
|
309
|
+
18. [tbprofiler](hAMRonization/TBProfilerIO.py): last updated for v7.0.0 (also parses v3/v4 output)
|
|
255
310
|
|
|
256
311
|
## Implementation Details
|
|
257
312
|
|
|
@@ -388,6 +443,18 @@ Here are some known issues that we would welcome input on trying to solve!
|
|
|
388
443
|
|
|
389
444
|
- `contig_id` isn't general enough when some tools this ID naturally corresponds to a `read_name` (deepARG), individual ORF (resfams), or protein sequence (AFP with protein input): *change to `query_id_name` or similar?*
|
|
390
445
|
|
|
446
|
+
|
|
447
|
+
#### Limitations of cross-database mapping
|
|
448
|
+
|
|
449
|
+
This is a highly messy and approximate process so any cross-mappings should be taken with a major grain of salt and directly validated if being used for important purposes.
|
|
450
|
+
|
|
391
451
|
## Citation
|
|
392
452
|
If you use hAMRonization please cite the following publication:
|
|
393
453
|
> I Mendes et al. 2024. "hAMRonization: Enhancing antimicrobial resistance prediction using the PHA4GE AMR detection specification and tooling". bioRxiv. https://doi.org/10.1101/2024.03.07.583950
|
|
454
|
+
|
|
455
|
+
If you use `--db_mapping chamredb`, also reference [chamredb](https://github.com/antunderwood/chamredb). It has no separate publication or preprint at this point.
|
|
456
|
+
|
|
457
|
+
If you use `--db_mapping argnorm`, please also cite:
|
|
458
|
+
> S Ugarcina Perovic, V Ramji, H Chong, Y Duan, F Maguire, LP Coelho. 2025. "argNorm: normalization of antibiotic resistance gene annotations to the Antibiotic Resistance Ontology (ARO)". Bioinformatics. https://doi.org/10.1093/bioinformatics/btaf173
|
|
459
|
+
|
|
460
|
+
`hamronize` prints the relevant citations to stderr whenever `--db_mapping` is used.
|
|
@@ -39,8 +39,8 @@ conda create --name hamronization --channel conda-forge --channel bioconda hamro
|
|
|
39
39
|
|
|
40
40
|
Or to install and run using docker, podman, singularity:
|
|
41
41
|
```
|
|
42
|
-
docker pull
|
|
43
|
-
docker run --rm
|
|
42
|
+
docker pull ghcr.io/pha4ge/hamronization:latest
|
|
43
|
+
docker run --rm ghcr.io/pha4ge/hamronization:latest hamronize --help
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Or to install the latest development version:
|
|
@@ -125,6 +125,50 @@ and they will be concatenated appropriately (i.e. only one header for tsv)
|
|
|
125
125
|
hamronize rgi --input_file_name rgi_report --analysis_software_version 6.0.0 --reference_database_version 3.2.5 test/data/raw_outputs/rgi/rgi.txt test/data/raw_outputs/rgibwt/Kp11_bwtoutput.gene_mapping_data.txt
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
#### Mapping to other AMR databases (RGI, AMRFinderPlus, ResFinder)
|
|
129
|
+
|
|
130
|
+
The results of `rgi` (CARD), `amrfinderplus` (NCBI Reference Gene Database) and
|
|
131
|
+
`resfinder` (ResFinder) can optionally be mapped to the other two of these
|
|
132
|
+
databases with `--db_mapping chamredb` or `--db_mapping argnorm`:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
hamronize amrfinderplus --db_mapping chamredb --analysis_software_version 4.0.3 --reference_database_version 2024-07-22.1 --input_file_name sample1 amrfinderplus_report.tsv
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
This appends a `<database>_mapping` column for each of the other two databases
|
|
139
|
+
(e.g. `card_mapping` and `resfinder_mapping` for AMRFinderPlus) and a
|
|
140
|
+
`database_mapping_source` column recording which resource was used. Multiple
|
|
141
|
+
mapped entries are separated by ` | `, and the columns are left empty where no
|
|
142
|
+
mapping is found.
|
|
143
|
+
|
|
144
|
+
- [chamredb](https://github.com/antunderwood/chamredb) uses a graph of
|
|
145
|
+
reciprocal best hits (RBH) between CARD, NCBI and ResFinder sequences. The
|
|
146
|
+
RBHs are reported for each database, or the one-way hits (OWH) where there is
|
|
147
|
+
no RBH, with their identity and coverage, e.g.
|
|
148
|
+
`ARO:3001022 (TEM-156; RBH; identity=1.0; coverage=1.0)`. Hits are looked up
|
|
149
|
+
by accession, then by gene name.
|
|
150
|
+
- [argNorm](https://github.com/BigDataBiology/argNorm) maps NCBI and ResFinder
|
|
151
|
+
genes onto CARD ARO terms, e.g. `ARO:3001022 (TEM-156; Perfect)`. Mappings
|
|
152
|
+
from CARD, and between NCBI and ResFinder, go via the ARO term, e.g.
|
|
153
|
+
`blaTEM-156 (blaTEM-156_1_AM941159; via ARO:3001022; Perfect)`. argNorm's
|
|
154
|
+
`Loose` matches are not used for these indirect mappings, and only the best
|
|
155
|
+
available cut-off is reported. Alleles sharing a gene name are grouped
|
|
156
|
+
(`+N more`).
|
|
157
|
+
|
|
158
|
+
Pinned copies of chamredb's
|
|
159
|
+
[`graph.json`](https://github.com/antunderwood/chamredb/blob/master/chamredb/data/graph.json)
|
|
160
|
+
(2026-11-09 graph) and argNorm's (v1.1.0)
|
|
161
|
+
[mapping tables](https://github.com/BigDataBiology/argNorm/tree/main/argnorm/data)
|
|
162
|
+
are downloaded, with their checksums verified, when hAMRonization is installed
|
|
163
|
+
(see `hAMRonization/data_sources.py`). This needs network access at install
|
|
164
|
+
time. Set `HAMRONIZATION_SKIP_DATA_DOWNLOAD=1` to install without them. To use
|
|
165
|
+
a different copy, pass `--db_mapping_data` with the path to a `graph.json` or
|
|
166
|
+
an argNorm `data` directory. Both resources were built against specific
|
|
167
|
+
database releases, so genes added more recently may not map.
|
|
168
|
+
|
|
169
|
+
When `--db_mapping` is used, `hamronize` prints what to cite to stderr (see
|
|
170
|
+
[Citation](#citation)).
|
|
171
|
+
|
|
128
172
|
You can summarize hAMRonized reports regardless of format using the 'summarize'
|
|
129
173
|
function:
|
|
130
174
|
|
|
@@ -181,6 +225,17 @@ You can also output a `json` formatted hAMRonized report:
|
|
|
181
225
|
|
|
182
226
|
`parsed_report.write('all_hAMRonized_abricate_report.json', output_format='json')`
|
|
183
227
|
|
|
228
|
+
To add the database mapping columns (see above) when writing an `rgi`,
|
|
229
|
+
`amrfinderplus` or `resfinder` report, pass a mapper; `mapper.map(result)` also
|
|
230
|
+
returns the mapping for a single result as a dict:
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
from hAMRonization.DatabaseMapping import get_mapper
|
|
234
|
+
mapper = get_mapper("argnorm", "rgi") # or get_mapper("chamredb", "rgi", "path/to/graph.json")
|
|
235
|
+
print(mapper.citation_message) # what to cite for this mapping
|
|
236
|
+
hAMRonization.parse("rgi.txt", metadata, "rgi").write(output_location="rgi.tsv", db_mapper=mapper)
|
|
237
|
+
```
|
|
238
|
+
|
|
184
239
|
If you want to write multiple reports to one file, this `.write` method can accept `append_mode=True` to append rather than overwrite the output file and not include the header (in tsv format).
|
|
185
240
|
|
|
186
241
|
`parsed_report.write('all_hAMRonized_abricate_report.tsv', append_mode=True)`
|
|
@@ -190,24 +245,24 @@ If you want to write multiple reports to one file, this `.write` method can acce
|
|
|
190
245
|
|
|
191
246
|
Currently implemented parsers and the last tool version for which they have been validated:
|
|
192
247
|
|
|
193
|
-
1. [abricate](hAMRonization/AbricateIO.py): last updated for v1.
|
|
194
|
-
2. [amrfinderplus](hAMRonization/AmrFinderPlusIO.py): last updated for v4.
|
|
195
|
-
3. [amrplusplus](hAMRonization/AmrPlusPlusIO.py): last updated for
|
|
248
|
+
1. [abricate](hAMRonization/AbricateIO.py): last updated for v1.4.0
|
|
249
|
+
2. [amrfinderplus](hAMRonization/AmrFinderPlusIO.py): last updated for v4.2.7
|
|
250
|
+
3. [amrplusplus](hAMRonization/AmrPlusPlusIO.py): last updated for v4 (MEGARes v4.00)
|
|
196
251
|
4. [ariba](hAMRonization/AribaIO.py): last updated for v2.14.6
|
|
197
252
|
5. [csstar](hAMRonization/CSStarIO.py): last updated for v2.1.0
|
|
198
|
-
6. [deeparg](hAMRonization/DeepArgIO.py): last updated for
|
|
253
|
+
6. [deeparg](hAMRonization/DeepArgIO.py): last updated for v2.0.0
|
|
199
254
|
7. [fargene](hAMRonization/FARGeneIO.py): last updated for v0.1
|
|
200
255
|
8. [groot](hAMRonization/GrootIO.py): last updated for v1.1.2
|
|
201
256
|
9. [kmerresistance](hAMRonization/KmerResistanceIO.py): late updated for v2.2.0
|
|
202
257
|
10. [mykrobe](test/data/raw_outputs/mykrobe/report.json): last updated for v0.8.1
|
|
203
258
|
11. ~pointfinder~ (removed, PointFinder is now integrated in ResFinder)
|
|
204
259
|
12. [resfams](hAMRonization/ResFamsIO.py): last updated for hmmer v3.3.2
|
|
205
|
-
13. [resfinder](hAMRonization/ResFinderIO.py): last updated for v4.
|
|
206
|
-
14. [rgi](hAMRonization/RgiIO.py) (includes RGI-BWT) last updated for
|
|
260
|
+
13. [resfinder](hAMRonization/ResFinderIO.py): last updated for v4.7.3
|
|
261
|
+
14. [rgi](hAMRonization/RgiIO.py) (includes RGI-BWT) last updated for v6.0.8
|
|
207
262
|
15. [srax](hAMRonization/SraxIO.py): last updated for v1.5
|
|
208
263
|
16. [srst2](hAMRonization/Srst2IO.py): last updated for v0.2.0
|
|
209
|
-
17. [staramr](hAMRonization/StarAmrIO.py): last updated for v0.
|
|
210
|
-
18. [
|
|
264
|
+
17. [staramr](hAMRonization/StarAmrIO.py): last updated for v0.12.3
|
|
265
|
+
18. [tbprofiler](hAMRonization/TBProfilerIO.py): last updated for v7.0.0 (also parses v3/v4 output)
|
|
211
266
|
|
|
212
267
|
## Implementation Details
|
|
213
268
|
|
|
@@ -344,6 +399,18 @@ Here are some known issues that we would welcome input on trying to solve!
|
|
|
344
399
|
|
|
345
400
|
- `contig_id` isn't general enough when some tools this ID naturally corresponds to a `read_name` (deepARG), individual ORF (resfams), or protein sequence (AFP with protein input): *change to `query_id_name` or similar?*
|
|
346
401
|
|
|
402
|
+
|
|
403
|
+
#### Limitations of cross-database mapping
|
|
404
|
+
|
|
405
|
+
This is a highly messy and approximate process so any cross-mappings should be taken with a major grain of salt and directly validated if being used for important purposes.
|
|
406
|
+
|
|
347
407
|
## Citation
|
|
348
408
|
If you use hAMRonization please cite the following publication:
|
|
349
409
|
> I Mendes et al. 2024. "hAMRonization: Enhancing antimicrobial resistance prediction using the PHA4GE AMR detection specification and tooling". bioRxiv. https://doi.org/10.1101/2024.03.07.583950
|
|
410
|
+
|
|
411
|
+
If you use `--db_mapping chamredb`, also reference [chamredb](https://github.com/antunderwood/chamredb). It has no separate publication or preprint at this point.
|
|
412
|
+
|
|
413
|
+
If you use `--db_mapping argnorm`, please also cite:
|
|
414
|
+
> S Ugarcina Perovic, V Ramji, H Chong, Y Duan, F Maguire, LP Coelho. 2025. "argNorm: normalization of antibiotic resistance gene annotations to the Antibiotic Resistance Ontology (ARO)". Bioinformatics. https://doi.org/10.1093/bioinformatics/btaf173
|
|
415
|
+
|
|
416
|
+
`hamronize` prints the relevant citations to stderr whenever `--db_mapping` is used.
|
|
@@ -16,6 +16,47 @@ required_metadata = [
|
|
|
16
16
|
"input_file_name",
|
|
17
17
|
]
|
|
18
18
|
|
|
19
|
+
# Subtypes whose element symbol is <gene>_<mutation>. POINT_DISRUPT (v4.2.4+)
|
|
20
|
+
# are frameshifts/stop codons in genes whose disruption causes resistance.
|
|
21
|
+
POINT_SUBTYPES = {"POINT", "POINT_DISRUPT"}
|
|
22
|
+
|
|
23
|
+
# <gene>_<ref><pos>[_<end_ref><end_pos>]<alt>, e.g. gyrA_S83I, mtrR_G-131A,
|
|
24
|
+
# cirA_Y253CfsTer5, pmrB_ALNQLV129del, mexR_D34_F96del, folP_P64PSFLY, see
|
|
25
|
+
# https://github.com/ncbi/amr/wiki/Point-mutation-nomenclature
|
|
26
|
+
POINT_MUTATION_RE = re.compile(
|
|
27
|
+
r"^(?P<gene>.+?)_(?P<ref>[A-Za-z]+)(?P<pos>-?\d+)"
|
|
28
|
+
r"(?:_(?P<end_ref>[A-Za-z]+)(?P<end_pos>-?\d+))?"
|
|
29
|
+
r"(?P<alt>[A-Za-z][A-Za-z0-9]*)$"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _shift(pos, offset):
|
|
34
|
+
"""Offset a coordinate, skipping 0 (c.-1 is followed by c.1)"""
|
|
35
|
+
new = pos + offset
|
|
36
|
+
if pos < 0 <= new:
|
|
37
|
+
new += 1
|
|
38
|
+
return new
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _protein_mutation(m):
|
|
42
|
+
if m["end_pos"]:
|
|
43
|
+
return f"p.{m['ref']}{m['pos']}_{m['end_ref']}{m['end_pos']}{m['alt']}"
|
|
44
|
+
return f"p.{m['ref']}{m['pos']}{m['alt']}"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _nucleotide_mutation(m):
|
|
48
|
+
ref, alt, pos = m["ref"], m["alt"], int(m["pos"])
|
|
49
|
+
end = int(m["end_pos"]) if m["end_pos"] else _shift(pos, len(ref) - 1)
|
|
50
|
+
span = f"{pos}" if end == pos else f"{pos}_{end}"
|
|
51
|
+
if alt == "del":
|
|
52
|
+
return f"c.{span}del"
|
|
53
|
+
if len(ref) == 1 and len(alt) == 1:
|
|
54
|
+
return f"c.{pos}{ref}>{alt}"
|
|
55
|
+
if len(ref) == 1 and alt.startswith(ref):
|
|
56
|
+
# e.g. ampC_T-14TGT: GT inserted after the T at -14
|
|
57
|
+
return f"c.{pos}_{_shift(pos, 1)}ins{alt[1:]}"
|
|
58
|
+
return f"c.{span}delins{alt}"
|
|
59
|
+
|
|
19
60
|
|
|
20
61
|
class AmrFinderPlusIterator(hAMRonizedResultIterator):
|
|
21
62
|
|
|
@@ -93,25 +134,29 @@ class AmrFinderPlusIterator(hAMRonizedResultIterator):
|
|
|
93
134
|
skipped_truncated += 1
|
|
94
135
|
continue
|
|
95
136
|
|
|
96
|
-
# "POINT"
|
|
137
|
+
# "POINT"/"POINT_DISRUPT" indicate mutational resistance
|
|
97
138
|
# amrfinderplus has no special fields but the mutation itself is
|
|
98
139
|
# appended to the symbol name so we want to split this
|
|
99
140
|
result['amino_acid_mutation'] = None
|
|
100
141
|
result['nucleotide_mutation'] = None
|
|
101
142
|
result['genetic_variation_type'] = GENE_PRESENCE
|
|
102
143
|
|
|
103
|
-
if result['Subtype']
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
result['
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
144
|
+
if result['Subtype'] in POINT_SUBTYPES:
|
|
145
|
+
match = POINT_MUTATION_RE.match(result['Element symbol'])
|
|
146
|
+
if match is None:
|
|
147
|
+
warnings.warn(f"Could not parse mutation from element symbol "
|
|
148
|
+
f"{result['Element symbol']} in "
|
|
149
|
+
f"{self.metadata['input_file_name']}")
|
|
150
|
+
else:
|
|
151
|
+
result['Element symbol'] = match['gene']
|
|
152
|
+
# this means it is a protein mutation
|
|
153
|
+
if result['Method'] in ["POINTX", "POINTP"]:
|
|
154
|
+
result['amino_acid_mutation'] = _protein_mutation(match)
|
|
155
|
+
result['genetic_variation_type'] = AMINO_ACID_VARIANT
|
|
156
|
+
elif result['Method'] == "POINTN":
|
|
157
|
+
# e.g., 23S_G2032G -> c.2032G>G, ampC_C-11C -> c.-11C>C
|
|
158
|
+
result['nucleotide_mutation'] = _nucleotide_mutation(match)
|
|
159
|
+
result['genetic_variation_type'] = NUCLEOTIDE_VARIANT
|
|
115
160
|
|
|
116
161
|
# Determine the field_map to use depending on the method used
|
|
117
162
|
# The following seems to cover all bases with a minimum of fuss
|