From ea0e4d27c77deee335da1f6ac48af73bf26ad1f1 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 15 Mar 2024 17:06:32 +0000 Subject: [PATCH] Add new meta_min_reads CLI param --- ribotricer/cli.py | 8 ++++++++ ribotricer/const.py | 2 ++ ribotricer/detect_orfs.py | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ribotricer/cli.py b/ribotricer/cli.py index cc0fc26..2700bf2 100644 --- a/ribotricer/cli.py +++ b/ribotricer/cli.py @@ -197,6 +197,13 @@ def prepare_orfs_cmd( help=("Whether output all ORFs including those " "non-translating ones"), is_flag=True, ) +@click.option( + "--meta-min-reads", + type=int, + default=META_MIN_READS, + show_default=True, + help="Minimum number of reads for a read length to be considered", +) def detect_orfs_cmd( bam, ribotricer_index, @@ -210,6 +217,7 @@ def detect_orfs_cmd( min_valid_codons_ratio, min_read_density, report_all, + meta_min_reads, ): if not os.path.isfile(bam): sys.exit("Error: BAM file not found") diff --git a/ribotricer/const.py b/ribotricer/const.py index 6b3a1f7..5a49f72 100644 --- a/ribotricer/const.py +++ b/ribotricer/const.py @@ -29,3 +29,5 @@ # Minimum read density over ORF # defined as the number of reads per unit length of the ORF MINIMUM_DENSITY_OVER_ORF = 0.0 +# Minimum number of reads for a read length to be considered +META_MIN_READS=100000 diff --git a/ribotricer/detect_orfs.py b/ribotricer/detect_orfs.py index 3af7b0b..d5dd940 100644 --- a/ribotricer/detect_orfs.py +++ b/ribotricer/detect_orfs.py @@ -344,6 +344,7 @@ def detect_orfs( min_valid_codons_ratio, min_density_over_orf, report_all, + meta_min_reads=100000, ): """ Parameters @@ -371,6 +372,8 @@ def detect_orfs( report_all: bool Whether to output all ORFs' scores regardless of translation status + meta_min_reads: int + minimum number of reads for a read length to be considered. Passed to metagene_coverage(). """ now = datetime.datetime.now() print(now.strftime("%b %d %H:%M:%S ..... started ribotricer detect-orfs")) @@ -416,7 +419,7 @@ def detect_orfs( "started calculating metagene profiles. This may take a long time...", ) ) - metagenes = metagene_coverage(annotated, alignments, read_length_counts, prefix) + metagenes = metagene_coverage(annotated, alignments, read_length_counts, prefix, meta_min_reads = meta_min_reads) # plot metagene profiles now = datetime.datetime.now()