Skip to content

Commit

Permalink
parse_influenza_blast_results.py: fix missing var, remove unused thre…
Browse files Browse the repository at this point in the history
…ads cli opt
  • Loading branch information
peterk87 committed Jul 10, 2023
1 parent 78c5c4b commit f7acaba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 11 additions & 3 deletions bin/parse_influenza_blast_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def find_h_or_n_type(df_merge, seg, is_iav):
if is_iav:
type_counts = df_segment["Genotype"].value_counts(sort=True)
type_counts = type_counts.filter(~pl.col("Genotype").is_null())
reg_h_or_n_type = "[Hh]" if h_or_n == "H" else "[Nn]"
df_type_counts = type_counts.with_columns(pl.lit(type_counts["Genotype"].str.extract(reg_h_or_n_type + r"(\d+)").alias(type_name)))
df_type_counts = df_type_counts.filter(~pl.col(type_name).is_null())
logging.debug(f"{df_type_counts}")
Expand Down Expand Up @@ -355,12 +356,19 @@ def find_h_or_n_type(df_merge, seg, is_iav):
"--pident-threshold", default=0.85, help="BLAST percent identity threshold"
)
@click.option('--min-aln-length', default=50, help="Min BLAST alignment length threshold")
@click.option("--threads", default=4, help="Number of BLAST result parsing threads.")
@click.option("--get-top-ref", default=False, help="Get top ref accession id from ncbi database.")
@click.option("--sample-name", default="", help="Sample Name.")
@click.argument("blast_results", nargs=-1)
def report(flu_metadata, blast_results, excel_report, top, pident_threshold,
min_aln_length, threads, get_top_ref, sample_name):
def report(
flu_metadata,
blast_results,
excel_report,
top,
pident_threshold,
min_aln_length,
get_top_ref,
sample_name
):
from rich.traceback import install
install(show_locals=True, width=120, word_wrap=True)
logging.basicConfig(
Expand Down
11 changes: 2 additions & 9 deletions modules/local/subtyping_report.nf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'

params.options = [:]
options = initOptions(params.options)

process SUBTYPING_REPORT {
memory {
// Dynamically determine how much memory is required for this task based on
Expand Down Expand Up @@ -33,17 +27,16 @@ process SUBTYPING_REPORT {
path(blastn_results)

output:
path('iav-subtyping-report.xlsx'), emit: report
path('nf-flu-subtyping-report.xlsx'), emit: report
path('parse_influenza_blast_results.log'), emit: log
path "versions.yml", emit: versions

script:
"""
parse_influenza_blast_results.py \\
--threads ${task.cpus} \\
--flu-metadata $genomeset \\
--top ${params.max_top_blastn} \\
--excel-report iav-subtyping-report.xlsx \\
--excel-report nf-flu-subtyping-report.xlsx \\
--pident-threshold $params.pident_threshold \\
$blastn_results
ln -s .command.log parse_influenza_blast_results.log
Expand Down

0 comments on commit f7acaba

Please sign in to comment.