From 14af63f1cf6780a94b81b689b4ad1c9d0b0fa76c Mon Sep 17 00:00:00 2001 From: Sage Wright Date: Fri, 19 Jul 2024 13:51:42 +0000 Subject: [PATCH] immediately exclude mutations with failed quality in the position warnings --- Dockerfile | 4 ++-- README.md | 6 +++--- tbp_parser/LIMS.py | 10 +++++++++- tbp_parser/__init__.py | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7f13a29..2cc1783 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # Shelby Bennett, Erin Young, Curtis Kapsak, & Kutluhan Incekara ARG SAMTOOLS_VER="1.18" -ARG TBP_PARSER_VER="1.5.10" +ARG TBP_PARSER_VER="2.0.0" FROM ubuntu:jammy as builder @@ -42,7 +42,7 @@ ARG TBP_PARSER_VER LABEL base.image="ubuntu:jammy" LABEL dockerfile.version="1" LABEL software="tbp-parser" -LABEL software.version="1.5.10" +LABEL software.version="2.0.0" LABEL description="tbp-parser and samtools" LABEL website="https://github.com/theiagen/tbp-parser" LABEL license="https://github.com/theiagen/tbp-parser/blob/main/LICENSE" diff --git a/README.md b/README.md index b20e611..b5dc74d 100644 --- a/README.md +++ b/README.md @@ -22,16 +22,16 @@ See also [this page](https://theiagen.notion.site/tbp-parser-b02bef0cbc814b12987 We highly recommend using the following Docker image to run tbp-parser: ```markdown -docker pull us-docker.pkg.dev/general-theiagen/theiagen/tbp-parser:1.5.10 +docker pull us-docker.pkg.dev/general-theiagen/theiagen/tbp-parser:2.0.0 ``` The entrypoint for this Docker image is the tbp-parser help message. To run this container interactively, use the following command: ```markdown -docker run -it --entrypoint=/bin/bash us-docker.pkg.dev/general-theiagen/theiagen/tbp-parser:1.5.10 +docker run -it --entrypoint=/bin/bash us-docker.pkg.dev/general-theiagen/theiagen/tbp-parser:2.0.0 # Once inside the container interactively, you can run the tbp-parser tool python3 /tbp-parser/tbp_parser/tbp_parser.py -v -# v1.5.10 +# v2.0.0 ``` ### Locally with Python diff --git a/tbp_parser/LIMS.py b/tbp_parser/LIMS.py index 22f6b62..558bf77 100644 --- a/tbp_parser/LIMS.py +++ b/tbp_parser/LIMS.py @@ -241,6 +241,10 @@ def apply_lims_rules(self, gene_dictionary, DF_LIMS, max_mdl_resistance, antimic self.logger.debug("LIMS:Since this MDL interpretation changed, we are now potentially recalculating max_mdl_resistance (currently {})".format(max_mdl_resistance[0])) + if (len(all_responsible_mdl_interpretations) == 0): + self.logger.debug("LIMS:There are no more potential MDL interpretations; exiting loop") + break + if (max([globals.RESISTANCE_RANKING[interpretation] for gene_set in all_responsible_mdl_interpretations.values() for interpretation in gene_set]) != globals.RESISTANCE_RANKING[max_mdl_resistance[0]]) and gene in responsible_gene: max_mdl_resistance = [annotation for annotation, rank in globals.RESISTANCE_RANKING.items() if rank == max([globals.RESISTANCE_RANKING[interpretation] for gene_set in all_responsible_mdl_interpretations.values() for interpretation in gene_set])] self.logger.debug("LIMS:The maximum needed to be reevaluated; the potential new max_mdl_resistance is now {}".format(max_mdl_resistance[0])) @@ -353,7 +357,11 @@ def create_lims_report(self): for antimicrobial_code, gene_dictionary in globals.ANTIMICROBIAL_CODE_TO_GENES.items(): drug_name = globals.ANTIMICROBIAL_CODE_TO_DRUG_NAME[antimicrobial_code] # get the MDL interpretations for all genes **FOR THE LIMS REPORT** associated with this drug - potential_mdl_resistances = globals.DF_LABORATORIAN[globals.DF_LABORATORIAN["antimicrobial"] == drug_name].loc[globals.DF_LABORATORIAN["tbprofiler_gene_name"].isin(gene_dictionary.keys())]["mdl_interpretation"] + potential_mdl_resistances = globals.DF_LABORATORIAN[globals.DF_LABORATORIAN["antimicrobial"] == drug_name].loc[globals.DF_LABORATORIAN["tbprofiler_gene_name"].isin(gene_dictionary.keys())] + + # remove any interpretations with failed quality warnings + potential_mdl_resistances = potential_mdl_resistances.loc[~potential_mdl_resistances["warning"].str.contains("Failed quality in the mutation position")] + potential_mdl_resistances = potential_mdl_resistances["mdl_interpretation"].tolist() # initalize list of genes responsible for the max resistance responsible_gene = set() diff --git a/tbp_parser/__init__.py b/tbp_parser/__init__.py index 5f5bf9a..e20a8c8 100644 --- a/tbp_parser/__init__.py +++ b/tbp_parser/__init__.py @@ -1 +1 @@ -__VERSION__ = "v1.5.10" \ No newline at end of file +__VERSION__ = "v2.0.0" \ No newline at end of file