# AMRFinderPlus 4.2.7 audit from the raw per-genome TSVs (R2-V32-007/008)
# Date: 2026-11-06. Source: amr_v427_raw.zip uploaded by the user (602 TSVs,
# extracted to /tmp/amr_v427/amr_v427/). Verified on the VM.
#
# FILE VERIFICATION
# - 602 files, all .tsv, named GCA_<accession>_<assembly>_genomic.tsv.
# - GCA prefix matches S1 (Table_S1_genome_accessions.tsv): 602/602.
# - Columns (AMRFinderPlus 4.x): Protein id, Contig id, Start, Stop, Strand,
#   Element symbol, Element name, Scope, Type, Subtype, Class, Subclass, Method,
#   Target length, Reference sequence length, % Coverage of reference,
#   % Identity to reference, Alignment length, Closest reference accession,
#   Closest reference name, HMM accession, HMM description.
# - Total rows: 28,368. Type: VIRULENCE 22,013 / AMR 3,317 / STRESS 3,038.
#
# AMR ROWS (Type == AMR): 3,317 (reproduces the published number exactly)
# - Scope: core 2,196 / plus 1,121.
# - Unique genes: 116 (core 113, plus 3). No gene appears in both scopes.
# - Plus-only genes (exactly 3): mdsA (560 rows, EFFLUX), mdsB (560 rows, EFFLUX),
#   mcr-9.2 (1 row, COLISTIN).
# - Mean AMR rows/genome: 5.51 (published 5.51). Genomes with >=1 AMR row: 579.
# - Classes: 21 (incl. multi-class entries split on '/': e.g.
#   NITROFURAN/PHENICOL/QUINOLONE/TETRACYCLINE, QUINOLONE/TRICLOSAN,
#   AMINOGLYCOSIDE/QUINOLONE, LINCOSAMIDE/MACROLIDE, PHENICOL/QUINOLONE).
#
# GENE-TO-CATEGORY MAPPING (audited)
# - Table_S12d_amr_gene_mapping.tsv (116 rows, one per AMR gene):
#   Element symbol, Class, Subclass, Scope, Type, n_genomes, n_rows.
# - EVERY gene maps to exactly ONE Class and ONE Subclass (0 genes with >1).
#   The mapping is clean and unambiguous.
#
# TWO-TIER MDR ANALYSIS (MDR = >=3 distinct classes, EFFLUX excluded)
# Method: identical to mdr_recalc_v427.py (Type==AMR only, Class split on '/',
 
# EFFLUX excluded, denominator 602 genomes).
# - ALL rows: MDR 149/602 = 24.8% (reproduces the published number exactly).
#   With efflux: 180/602 = 29.9%.
# - CORE-only rows: MDR 149/602 = 24.8%. With efflux: 149/602 = 24.8%.
# - ZERO genomes change MDR status between all-rows and core-only.
# - QC (542): MDR 132/542 = 24.4% (all and core, identical).
# - PP1 (cluster 1, QC): 63/184 = 34.2% (all and core, identical).
# - PP2 (cluster 2, QC): 16/141 = 11.3% (all and core, identical).
# - PP3 (cluster 3, QC): 3/34 = 8.8% (all and core, identical).
# - Why identical: the only plus-only genes are mdsA/mdsB (EFFLUX, excluded
#   from MDR anyway) and mcr-9.2 (1 genome, P311, already MDR via 5 core
#   classes). So Scope filtering cannot change any MDR call.
#
# mcr-9.2 CARRIER
# - P311 (GCA_051914145.1, Monophasic Typhimurium, ST34, PP1/FastBAPS 8).
# - Genes: mdsB, mdsA, blaTEM-1, aph(3')-Ia, tet(B), blaCTX-M-9, sul1, aadA2,
#   dfrA16, mcr-9.2. Classes (all): 7; classes (core only): 5. MDR under both.
# - mcr-9.2 is a plasmid-borne colistin-resistance gene; worth one sentence in
#   the manuscript (single-genome finding, does not affect the MDR analysis).
#
# CONCLUSION (R2-V32-007/008)
# - The MDR classification is FULLY ROBUST to Scope: core-only and all-rows
#   give identical MDR calls for every genome and every cluster.
# - The audited gene-to-category mapping (S12d) is complete: 116 genes, each
#   with a single Class/Subclass/Scope/Type.
# - v3.3 action: add S12d to the supplementary list + Methods; add one
#   paragraph reporting the two-tier result (identical MDR) and the mcr-9.2
#   single-genome note. No change to any published MDR number.
