Skip to content

Commit

Permalink
Update ResFinderIO.py
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
DanyMatute authored May 17, 2024
1 parent c54390e commit 4dcdb9d
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions hAMRonization/ResFinderIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down

0 comments on commit 4dcdb9d

Please sign in to comment.