From 4dcdb9dab9124aa9f12e545923597f2907fba4c7 Mon Sep 17 00:00:00 2001 From: Dany Matute Date: Fri, 17 May 2024 17:42:44 -0400 Subject: [PATCH] Update ResFinderIO.py The newer version of Resfinder 4.5.0 produces NA and NA..NA when --inputfastq flag is implemented, and this flag is used to run the KMA. These are removed as it clashes with the expected variable type "int" --- hAMRonization/ResFinderIO.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/hAMRonization/ResFinderIO.py b/hAMRonization/ResFinderIO.py index 54e74c1..828f51e 100644 --- a/hAMRonization/ResFinderIO.py +++ b/hAMRonization/ResFinderIO.py @@ -56,14 +56,29 @@ def parse(self, handle): reader = csv.DictReader(handle, delimiter="\t") for result in reader: result["_gene_name"] = result["Resistance gene"] - _start, _stop = result["Position in contig"].split("..") - if _start > _stop: - _strand = "-" + # Removes fields that have NA and NA..NA this is typical in the 4.5.0 resfinder when the --inputfastq is implimented + for field, value in result.items(): + if value == "NA": + result[field] = None + if value == "NA..NA": + result[field] = None + # If result["Position in contig"] == None then make _start, _stop and _strand = None + if result["Position in contig"] != None: + _start, _stop = result["Position in contig"].split("..") + if _start > _stop : + _strand = "-" + else: + _strand = "+" + + result["_start"] = _start + result["_stop"] = _stop + result["_strand"] = _strand else: - _strand = "+" - result["_start"] = _start - result["_stop"] = _stop - result["_strand"] = _strand + _strand = None + result["_start"] = None + result["_stop"] = None + result["_strand"] = None + _reference_gene_length = result["Alignment Length/Gene Length"].split("/")[ 0 ]