Skip to content

Commit

Permalink
ENH add argNorm version to tsv output to the top of tables as comments
Browse files Browse the repository at this point in the history
Tsv outputs will now have the argNorm version on the top as a comment, such as: "# argNorm version: 0.6.0".

Tests in test_normalizers.py now skip the first row of the golden files that contain the argNorm version. `get_golden_file` function was added to test_normalizers.py to make changing the procurement of golden files easier.
  • Loading branch information
Vedanth-Ramji authored and luispedro committed Oct 8, 2024
1 parent 2992163 commit 737e414
Show file tree
Hide file tree
Showing 31 changed files with 12,949 additions and 12,918 deletions.
2 changes: 2 additions & 0 deletions argnorm/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
from .argnorm_version import __version__
from .atomicwrite import atomic_write

def main():
Expand Down Expand Up @@ -48,4 +49,5 @@ def main():
prop_unmapped = ((result.ARO == 'ARO:nan').sum() + result.ARO.isna().sum()) / result.shape[0]
print(f'{args.output}:', f'{round(1 - prop_unmapped, 3):.2%} ARGs mapped.')
with atomic_write(args.output, mode='w', overwrite=True) as out:
out.write(f'# argNorm version: {__version__}\n')
result.to_csv(out, sep='\t', index=False)
2 changes: 0 additions & 2 deletions argnorm/normalizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .drug_categorization import confers_resistance_to, drugs_to_drug_classes
from .lib import get_aro_mapping_table
from .lib import MAPPING_TABLE_ARO_COL, TARGET_ARO_COL
from .argnorm_version import __version__

# Column headings for drug categorization output
CONFERS_RESISTANCE_TO_COL = 'confers_resistance_to'
Expand Down Expand Up @@ -42,7 +41,6 @@ def run(self, input_file : str):
original_annot[RESISTANCE_TO_DRUG_CLASSES_COL] = original_annot[TARGET_ARO_COL].map(
lambda a: ','.join(drugs_to_drug_classes(confers_resistance_to(a))),
na_action='ignore')
original_annot['argNorm_version'] = __version__

return original_annot

Expand Down
2,001 changes: 1,001 additions & 1,000 deletions outputs/hamronized/abricate.argannot.tsv

Large diffs are not rendered by default.

2,001 changes: 1,001 additions & 1,000 deletions outputs/hamronized/abricate.megares.tsv

Large diffs are not rendered by default.

2,001 changes: 1,001 additions & 1,000 deletions outputs/hamronized/abricate.ncbi.tsv

Large diffs are not rendered by default.

2,001 changes: 1,001 additions & 1,000 deletions outputs/hamronized/abricate.resfinder.tsv

Large diffs are not rendered by default.

9,079 changes: 4,540 additions & 4,539 deletions outputs/hamronized/abricate.resfinderfg.tsv

Large diffs are not rendered by default.

45 changes: 23 additions & 22 deletions outputs/hamronized/amrfinderplus.ncbi.orfs.tsv

Large diffs are not rendered by default.

2,001 changes: 1,001 additions & 1,000 deletions outputs/hamronized/args-oap.sarg.reads.tsv

Large diffs are not rendered by default.

2,001 changes: 1,001 additions & 1,000 deletions outputs/hamronized/deeparg.deeparg.orfs.tsv

Large diffs are not rendered by default.

27 changes: 14 additions & 13 deletions outputs/hamronized/groot.argannot.tsv
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
input_file_name gene_symbol gene_name reference_database_name reference_database_version reference_accession analysis_software_name analysis_software_version genetic_variation_type antimicrobial_agent coverage_percentage coverage_depth coverage_ratio drug_class input_gene_length input_gene_start input_gene_stop input_protein_length input_protein_start input_protein_stop input_sequence_id nucleotide_mutation nucleotide_mutation_interpretation predicted_phenotype predicted_phenotype_confidence_level amino_acid_mutation amino_acid_mutation_interpretation reference_gene_length reference_gene_start reference_gene_stop reference_protein_length reference_protein_start reference_protein_stop resistance_mechanism strand_orientation sequence_identity ARO confers_resistance_to resistance_to_drug_classes argNorm_version
groot.argannot.tsv argannot~~~(Bla)cfiA9~~~AB087234:1-750 argannot~~~(Bla)cfiA9~~~AB087234:1-750 groot v argannot~~~(Bla)cfiA9~~~AB087234:1-750 groot v gene_presence_detected 79.0 750 ARO:3006921 ARO:0000020 ARO:3000007 0.6.0
groot.argannot.tsv argannot~~~(Tet)Tet-40~~~AM419751:14211-15431 argannot~~~(Tet)Tet-40~~~AM419751:14211-15431 groot v argannot~~~(Tet)Tet-40~~~AM419751:14211-15431 groot v gene_presence_detected 315.0 1221 ARO:3000567 ARO:0000051 ARO:3000050 0.6.0
groot.argannot.tsv argannot~~~(MLS)ErmF~~~M14730:241-1041 argannot~~~(MLS)ErmF~~~M14730:241-1041 groot v argannot~~~(MLS)ErmF~~~M14730:241-1041 groot v gene_presence_detected 321.0 801 ARO:3000498 ARO:0000006,ARO:0000027,ARO:0000046,ARO:0000057,ARO:0000065,ARO:0000066,ARO:3000145,ARO:3000156,ARO:3000158,ARO:3000176,ARO:3000583,ARO:3000584,ARO:3000669,ARO:3000672,ARO:3000673,ARO:3000674,ARO:3000675,ARO:3000677,ARO:3000678,ARO:3000679,ARO:3000680,ARO:3000681,ARO:3000682,ARO:3000867 ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000017,ARO:0000017,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026 0.6.0
groot.argannot.tsv argannot~~~(AGly)Aph7~~~GG774704:686456-687373 argannot~~~(AGly)Aph7~~~GG774704:686456-687373 groot v argannot~~~(AGly)Aph7~~~GG774704:686456-687373 groot v gene_presence_detected 254.0 918 ARO:3002655 ARO:3000214 ARO:0000016 0.6.0
groot.argannot.tsv argannot~~~(Bla)cfxA2~~~AF504910:1-966 argannot~~~(Bla)cfxA2~~~AF504910:1-966 groot v argannot~~~(Bla)cfxA2~~~AF504910:1-966 groot v gene_presence_detected 338.0 966 ARO:3003002 ARO:0000044 ARO:3000007 0.6.0
groot.argannot.tsv argannot~~~(MLS)ErmB~~~M11180:714-1451 argannot~~~(MLS)ErmB~~~M11180:714-1451 groot v argannot~~~(MLS)ErmB~~~M11180:714-1451 groot v gene_presence_detected 178.0 738 ARO:3000375 ARO:0000006,ARO:0000027,ARO:0000046,ARO:0000057,ARO:0000065,ARO:0000066,ARO:3000145,ARO:3000156,ARO:3000158,ARO:3000176,ARO:3000583,ARO:3000584,ARO:3000669,ARO:3000672,ARO:3000673,ARO:3000674,ARO:3000675,ARO:3000677,ARO:3000678,ARO:3000679,ARO:3000680,ARO:3000681,ARO:3000682,ARO:3000867 ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000017,ARO:0000017,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026 0.6.0
groot.argannot.tsv argannot~~~(Tet)TetQ~~~Z21523:362-2287 argannot~~~(Tet)TetQ~~~Z21523:362-2287 groot v argannot~~~(Tet)TetQ~~~Z21523:362-2287 groot v gene_presence_detected 539.0 1974 ARO:3000191 ARO:0000051,ARO:0000069,ARO:3000152,ARO:3000528,ARO:3000667,ARO:3000668 ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050 0.6.0
groot.argannot.tsv argannot~~~(Bla)cfxA5~~~AY769934:28-993 argannot~~~(Bla)cfxA5~~~AY769934:28-993 groot v argannot~~~(Bla)cfxA5~~~AY769934:28-993 groot v gene_presence_detected 449.0 966 ARO:3003096 ARO:0000044 ARO:3000007 0.6.0
groot.argannot.tsv argannot~~~(Bla)OXA-347~~~JN086160:1583-2407 argannot~~~(Bla)OXA-347~~~JN086160:1583-2407 groot v argannot~~~(Bla)OXA-347~~~JN086160:1583-2407 groot v gene_presence_detected 191.0 825 ARO:3001777 ARO:0000056 ARO:3000007 0.6.0
groot.argannot.tsv argannot~~~(Tet)TetW~~~AJ222769:3687-5606 argannot~~~(Tet)TetW~~~AJ222769:3687-5606 groot v argannot~~~(Tet)TetW~~~AJ222769:3687-5606 groot v gene_presence_detected 203.0 1920 ARO:3000194 ARO:0000051,ARO:0000069,ARO:3000152,ARO:3000528,ARO:3000667,ARO:3000668 ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050 0.6.0
groot.argannot.tsv argannot~~~(Tet)Tet-32~~~DQ647324:181-2100 argannot~~~(Tet)Tet-32~~~DQ647324:181-2100 groot v argannot~~~(Tet)Tet-32~~~DQ647324:181-2100 groot v gene_presence_detected 148.0 1920 ARO:3000196 ARO:0000051,ARO:0000069,ARO:3000152,ARO:3000528,ARO:3000667,ARO:3000668 ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050 0.6.0
groot.argannot.tsv argannot~~~(Bla)cfxA4~~~AY769933:1-966 argannot~~~(Bla)cfxA4~~~AY769933:1-966 groot v argannot~~~(Bla)cfxA4~~~AY769933:1-966 groot v gene_presence_detected 450.0 966 ARO:3003005 ARO:0000044 ARO:3000007 0.6.0
# argNorm version: 0.6.0
input_file_name gene_symbol gene_name reference_database_name reference_database_version reference_accession analysis_software_name analysis_software_version genetic_variation_type antimicrobial_agent coverage_percentage coverage_depth coverage_ratio drug_class input_gene_length input_gene_start input_gene_stop input_protein_length input_protein_start input_protein_stop input_sequence_id nucleotide_mutation nucleotide_mutation_interpretation predicted_phenotype predicted_phenotype_confidence_level amino_acid_mutation amino_acid_mutation_interpretation reference_gene_length reference_gene_start reference_gene_stop reference_protein_length reference_protein_start reference_protein_stop resistance_mechanism strand_orientation sequence_identity ARO confers_resistance_to resistance_to_drug_classes
groot.argannot.tsv argannot~~~(Bla)cfiA9~~~AB087234:1-750 argannot~~~(Bla)cfiA9~~~AB087234:1-750 groot v argannot~~~(Bla)cfiA9~~~AB087234:1-750 groot v gene_presence_detected 79.0 750 ARO:3006921 ARO:0000020 ARO:3000007
groot.argannot.tsv argannot~~~(Tet)Tet-40~~~AM419751:14211-15431 argannot~~~(Tet)Tet-40~~~AM419751:14211-15431 groot v argannot~~~(Tet)Tet-40~~~AM419751:14211-15431 groot v gene_presence_detected 315.0 1221 ARO:3000567 ARO:0000051 ARO:3000050
groot.argannot.tsv argannot~~~(MLS)ErmF~~~M14730:241-1041 argannot~~~(MLS)ErmF~~~M14730:241-1041 groot v argannot~~~(MLS)ErmF~~~M14730:241-1041 groot v gene_presence_detected 321.0 801 ARO:3000498 ARO:0000006,ARO:0000027,ARO:0000046,ARO:0000057,ARO:0000065,ARO:0000066,ARO:3000145,ARO:3000156,ARO:3000158,ARO:3000176,ARO:3000583,ARO:3000584,ARO:3000669,ARO:3000672,ARO:3000673,ARO:3000674,ARO:3000675,ARO:3000677,ARO:3000678,ARO:3000679,ARO:3000680,ARO:3000681,ARO:3000682,ARO:3000867 ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000017,ARO:0000017,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026
groot.argannot.tsv argannot~~~(AGly)Aph7~~~GG774704:686456-687373 argannot~~~(AGly)Aph7~~~GG774704:686456-687373 groot v argannot~~~(AGly)Aph7~~~GG774704:686456-687373 groot v gene_presence_detected 254.0 918 ARO:3002655 ARO:3000214 ARO:0000016
groot.argannot.tsv argannot~~~(Bla)cfxA2~~~AF504910:1-966 argannot~~~(Bla)cfxA2~~~AF504910:1-966 groot v argannot~~~(Bla)cfxA2~~~AF504910:1-966 groot v gene_presence_detected 338.0 966 ARO:3003002 ARO:0000044 ARO:3000007
groot.argannot.tsv argannot~~~(MLS)ErmB~~~M11180:714-1451 argannot~~~(MLS)ErmB~~~M11180:714-1451 groot v argannot~~~(MLS)ErmB~~~M11180:714-1451 groot v gene_presence_detected 178.0 738 ARO:3000375 ARO:0000006,ARO:0000027,ARO:0000046,ARO:0000057,ARO:0000065,ARO:0000066,ARO:3000145,ARO:3000156,ARO:3000158,ARO:3000176,ARO:3000583,ARO:3000584,ARO:3000669,ARO:3000672,ARO:3000673,ARO:3000674,ARO:3000675,ARO:3000677,ARO:3000678,ARO:3000679,ARO:3000680,ARO:3000681,ARO:3000682,ARO:3000867 ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000000,ARO:0000017,ARO:0000017,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026,ARO:0000026
groot.argannot.tsv argannot~~~(Tet)TetQ~~~Z21523:362-2287 argannot~~~(Tet)TetQ~~~Z21523:362-2287 groot v argannot~~~(Tet)TetQ~~~Z21523:362-2287 groot v gene_presence_detected 539.0 1974 ARO:3000191 ARO:0000051,ARO:0000069,ARO:3000152,ARO:3000528,ARO:3000667,ARO:3000668 ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050
groot.argannot.tsv argannot~~~(Bla)cfxA5~~~AY769934:28-993 argannot~~~(Bla)cfxA5~~~AY769934:28-993 groot v argannot~~~(Bla)cfxA5~~~AY769934:28-993 groot v gene_presence_detected 449.0 966 ARO:3003096 ARO:0000044 ARO:3000007
groot.argannot.tsv argannot~~~(Bla)OXA-347~~~JN086160:1583-2407 argannot~~~(Bla)OXA-347~~~JN086160:1583-2407 groot v argannot~~~(Bla)OXA-347~~~JN086160:1583-2407 groot v gene_presence_detected 191.0 825 ARO:3001777 ARO:0000056 ARO:3000007
groot.argannot.tsv argannot~~~(Tet)TetW~~~AJ222769:3687-5606 argannot~~~(Tet)TetW~~~AJ222769:3687-5606 groot v argannot~~~(Tet)TetW~~~AJ222769:3687-5606 groot v gene_presence_detected 203.0 1920 ARO:3000194 ARO:0000051,ARO:0000069,ARO:3000152,ARO:3000528,ARO:3000667,ARO:3000668 ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050
groot.argannot.tsv argannot~~~(Tet)Tet-32~~~DQ647324:181-2100 argannot~~~(Tet)Tet-32~~~DQ647324:181-2100 groot v argannot~~~(Tet)Tet-32~~~DQ647324:181-2100 groot v gene_presence_detected 148.0 1920 ARO:3000196 ARO:0000051,ARO:0000069,ARO:3000152,ARO:3000528,ARO:3000667,ARO:3000668 ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050,ARO:3000050
groot.argannot.tsv argannot~~~(Bla)cfxA4~~~AY769933:1-966 argannot~~~(Bla)cfxA4~~~AY769933:1-966 groot v argannot~~~(Bla)cfxA4~~~AY769933:1-966 groot v gene_presence_detected 450.0 966 ARO:3003005 ARO:0000044 ARO:3000007
Loading

0 comments on commit 737e414

Please sign in to comment.