Skip to content

Commit

Permalink
workflow: don't use metadata for sc2rf_recombinants when exclude_nega…
Browse files Browse the repository at this point in the history
…tives is true
  • Loading branch information
Katherine Eaton committed Oct 3, 2022
1 parent cdf4540 commit 8e5b90f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions sc2rf/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,12 @@ def main(

if nextclade and nextclade_auto_pass:

logger.info(
"Auto-passing lineages through sc2rf: {}".format(
",".join(nextclade_auto_pass_lineages)
)
)

# Identify negative samples to auto-pass
auto_pass_df = nextclade_df[
(nextclade_df["Nextclade_pango"] != NO_DATA_CHAR)
Expand Down Expand Up @@ -860,7 +866,9 @@ def main(

# ---------------------------------------------------------------------
# Write exclude strains (false positives)

outpath_exclude = os.path.join(outdir, prefix + ".exclude.tsv")
logger.info("Writing strains to exclude: {}".format(outpath_exclude))
if len(false_positives) > 0:
with open(outpath_exclude, "w") as outfile:
for strain, reason in false_positives.items():
Expand Down Expand Up @@ -889,6 +897,7 @@ def main(
# write output table

# Drop old columns, if there were only negative samples, these columns don't exist
logger.info("Formatting output columns.")
if set(df["sc2rf_status"]) != set(["negative"]):
df.drop(
[
Expand Down
9 changes: 8 additions & 1 deletion workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,12 @@ def _params_sc2rf_recombinants(build):
if auto_pass: params["auto_pass"] = "--nextclade-auto-pass {}".format(",".join(auto_pass))
else: params["auto_pass"] = ""

# The metadata param will not be used if we are excluding negatives
metadata = _inputs(build)["metadata"]
exclude_negatives = config["builds"][build]["sc2rf"]["exclude_negatives"]
if not exclude_negatives: params["metadata"] = "--metadata {}".format(metadata)
else: params["metadata"] = ""

return params


Expand Down Expand Up @@ -636,6 +642,7 @@ rule sc2rf_recombinants:
max_breakpoints = lambda wildcards: _params_sc2rf_recombinants(wildcards.build)["max_breakpoints"],
motifs = lambda wildcards: _params_sc2rf_recombinants(wildcards.build)["motifs"],
auto_pass = lambda wildcards: _params_sc2rf_recombinants(wildcards.build)["auto_pass"],
metadata = lambda wildcards: _params_sc2rf_recombinants(wildcards.build)["metadata"],
# Join inputs together with commas
ansi = lambda wildcards: ",".join(_inputs_sc2rf_recombinants(wildcards.build)["ansi"]),
csv = lambda wildcards: ",".join(_inputs_sc2rf_recombinants(wildcards.build)["csv"]),
Expand All @@ -658,7 +665,7 @@ rule sc2rf_recombinants:
--nextclade {input.nextclade} \
--nextclade-no-recomb {input.nextclade_no_recomb} \
--lineage-tree {input.lineage_tree} \
--metadata {input.metadata} \
{params.metadata} \
{params.auto_pass} \
{params.motifs} \
{params.min_len} \
Expand Down

0 comments on commit 8e5b90f

Please sign in to comment.