Skip to content

Commit 7c09199

Browse files
committed
Fix tests for ResFinderIO change
1 parent 1c5ac5f commit 7c09199

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

hAMRonization/ResFinderIO.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def set_variation_fields(r, vs):
156156

157157
# Set the fields collected from the phenotypes and from the region object
158158
res.genetic_variation_type = GENE_PRESENCE
159-
res.drug_class = ", ".join(amr_cls)
160-
res.antimicrobial_agent = ", ".join(amr_res)
159+
res.drug_class = ", ".join(sorted(amr_cls))
160+
res.antimicrobial_agent = ", ".join(sorted(amr_res))
161161
set_shared_fields(r)
162162

163163
# Yield a new hAMRonizedResult using super's method as that may do the needful
@@ -187,8 +187,8 @@ def set_variation_fields(r, vs):
187187

188188
# Set fields we collected plus the region and variant ones as above
189189
res.genetic_variation_type = NUCLEOTIDE_VARIANT # default may be overridden
190-
res.drug_class = ", ".join(amr_cls)
191-
res.antimicrobial_agent = ", ".join(amr_res)
190+
res.drug_class = ", ".join(sorted(amr_cls))
191+
res.antimicrobial_agent = ", ".join(sorted(amr_res))
192192
set_shared_fields(r)
193193
set_variation_fields(r, vs_dict.values())
194194

@@ -228,7 +228,7 @@ def _condense_notes(notes, pmids):
228228
lines += filter(None, notes)
229229
pmids = list(filter(None, pmids))
230230
if pmids:
231-
lines.append("PMIDs: " + ", ".join(set(pmids)))
231+
lines.append("PMIDs: " + ", ".join(sorted(set(pmids))))
232232
return ". ".join(lines) if lines else None
233233

234234

test/test_parsing_validity.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,8 @@ def test_resfinder():
315315
seen_genes += 1
316316

317317
# it reports these 4 agents separately (even if all on one gene)
318-
assert (result.antimicrobial_agent, result.drug_class) in [
319-
('ciprofloxacin', 'quinolone'),
320-
('nalidixic acid', 'quinolone'),
321-
('trimethoprim', 'folate pathway antagonist'),
322-
('chloramphenicol', 'amphenicol')]
318+
assert result.antimicrobial_agent == 'chloramphenicol, ciprofloxacin, nalidixic acid, trimethoprim'
319+
assert result.drug_class == 'amphenicol, folate pathway antagonist, quinolone'
323320

324321
# assert mandatory fields (5)
325322
assert result.gene_symbol == "OqxA"
@@ -329,7 +326,7 @@ def test_resfinder():
329326
assert result.reference_accession == "EU370913"
330327

331328
# optional fields (12)
332-
assert result.predicted_phenotype == "ciprofloxacin, nalidixic acid, trimethoprim, chloramphenicol"
329+
assert result.predicted_phenotype == "antimicrobial resistance"
333330
assert result.predicted_phenotype_confidence_level == (
334331
"Must be in an operon with oqxB," +
335332
"phenotype differs based on genomic location of the operon PMID 25801572," +
@@ -374,7 +371,7 @@ def test_resfinder():
374371
# optional fields (14)
375372
assert result.antimicrobial_agent == "ampicillin"
376373
assert result.drug_class == "beta-lactam"
377-
assert result.predicted_phenotype == "ampicillin"
374+
assert result.predicted_phenotype == "antimicrobial resistance"
378375
assert result.predicted_phenotype_confidence_level == (
379376
"The nineteen pbp5 mutations must be present simultaneously " +
380377
"for resistance phenotype. PMIDs: 25182648")
@@ -414,7 +411,7 @@ def test_resfinder():
414411
assert result.genetic_variation_type is False # just to stop
415412

416413
# Check that we saw all
417-
assert seen_genes == 4
414+
assert seen_genes == 1
418415
assert seen_variants == 1
419416

420417

0 commit comments

Comments
 (0)