Skip to content

Commit 4dcdb9d

Browse files
authored
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"
1 parent c54390e commit 4dcdb9d

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

hAMRonization/ResFinderIO.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,29 @@ def parse(self, handle):
5656
reader = csv.DictReader(handle, delimiter="\t")
5757
for result in reader:
5858
result["_gene_name"] = result["Resistance gene"]
59-
_start, _stop = result["Position in contig"].split("..")
60-
if _start > _stop:
61-
_strand = "-"
59+
# Removes fields that have NA and NA..NA this is typical in the 4.5.0 resfinder when the --inputfastq is implimented
60+
for field, value in result.items():
61+
if value == "NA":
62+
result[field] = None
63+
if value == "NA..NA":
64+
result[field] = None
65+
# If result["Position in contig"] == None then make _start, _stop and _strand = None
66+
if result["Position in contig"] != None:
67+
_start, _stop = result["Position in contig"].split("..")
68+
if _start > _stop :
69+
_strand = "-"
70+
else:
71+
_strand = "+"
72+
73+
result["_start"] = _start
74+
result["_stop"] = _stop
75+
result["_strand"] = _strand
6276
else:
63-
_strand = "+"
64-
result["_start"] = _start
65-
result["_stop"] = _stop
66-
result["_strand"] = _strand
77+
_strand = None
78+
result["_start"] = None
79+
result["_stop"] = None
80+
result["_strand"] = None
81+
6782
_reference_gene_length = result["Alignment Length/Gene Length"].split("/")[
6883
0
6984
]

0 commit comments

Comments
 (0)