From 2e5d69e10c6c108ec3b5708272bbeec950e89346 Mon Sep 17 00:00:00 2001 From: Tom Smith Date: Mon, 4 Mar 2024 15:23:05 +0000 Subject: [PATCH] updates unpaired/unmapped/chimeric options --- umi_tools/Utilities.py | 73 ++++++++++++++++++++++++++++++------------ umi_tools/count.py | 2 +- umi_tools/dedup.py | 2 +- umi_tools/group.py | 2 +- 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/umi_tools/Utilities.py b/umi_tools/Utilities.py index cee29e1..788c3e0 100644 --- a/umi_tools/Utilities.py +++ b/umi_tools/Utilities.py @@ -599,6 +599,8 @@ def Start(parser=None, add_extract_options=False, add_group_dedup_options=True, add_sam_options=True, + add_dedup_count_sam_options=False, + add_group_sam_options=False, add_umi_grouping_options=True, return_parser=False): """set up an experiment. @@ -885,27 +887,6 @@ def Start(parser=None, group.add_option("--output-unmapped", dest="output_unmapped", action="store_true", default=False, help=optparse.SUPPRESS_HELP) - group.add_option("--unmapped-reads", dest="unmapped_reads", - type="choice", - choices=("discard", "use", "output"), - default="discard", - help=("How to handle unmapped reads. Options are " - "'discard', 'use' or 'correct' [default=%default]")) - - group.add_option("--chimeric-pairs", dest="chimeric_pairs", - type="choice", - choices=("discard", "use", "output"), - default="use", - help=("How to handle chimeric read pairs. Options are " - "'discard', 'use' or 'correct' [default=%default]")) - - group.add_option("--unpaired-reads", dest="unpaired_reads", - type="choice", - choices=("discard", "use", "output"), - default="use", - help=("How to handle unpaired reads. Options are " - "'discard', 'use' or 'correct' [default=%default]")) - group.add_option("--ignore-umi", dest="ignore_umi", action="store_true", help="Ignore UMI and dedup" " only on position", default=False) @@ -941,6 +922,56 @@ def Start(parser=None, parser.add_option_group(group) + if add_dedup_count_sam_options: + group = OptionGroup(parser, "Dedup and Count SAM/BAM options") + + group.add_option("--unmapped-reads", dest="unmapped_reads", + type="choice", + choices=("discard", "use"), + default="discard", + help=("How to handle unmapped reads. Options are " + "'discard' or 'use'' [default=%default]")) + + group.add_option("--chimeric-pairs", dest="chimeric_pairs", + type="choice", + choices=("discard", "use"), + default="use", + help=("How to handle chimeric read pairs. Options are " + "'discard' or 'use' [default=%default]")) + + group.add_option("--unpaired-reads", dest="unpaired_reads", + type="choice", + choices=("discard", "use"), + default="use", + help=("How to handle unpaired reads. Options are " + "'discard'or 'use' [default=%default]")) + parser.add_option_group(group) + + if add_group_sam_options: + group = OptionGroup(parser, "Group SAM/BAM options") + + group.add_option("--unmapped-reads", dest="unmapped_reads", + type="choice", + choices=("discard", "use", "output"), + default="discard", + help=("How to handle unmapped reads. Options are " + "'discard', 'use' or 'output' [default=%default]")) + + group.add_option("--chimeric-pairs", dest="chimeric_pairs", + type="choice", + choices=("discard", "use", "output"), + default="use", + help=("How to handle chimeric read pairs. Options are " + "'discard', 'use' or 'output' [default=%default]")) + + group.add_option("--unpaired-reads", dest="unpaired_reads", + type="choice", + choices=("discard", "use", "output"), + default="use", + help=("How to handle unpaired reads. Options are " + "'discard', 'use' or 'output' [default=%default]")) + parser.add_option_group(group) + if add_pipe_options: group = OptionGroup(parser, "input/output options") group.add_option("-I", "--stdin", dest="stdin", type="string", diff --git a/umi_tools/count.py b/umi_tools/count.py index 6d0d609..4439e9a 100644 --- a/umi_tools/count.py +++ b/umi_tools/count.py @@ -91,7 +91,7 @@ def main(argv=None): parser.add_option_group(group) # add common options (-h/--help, ...) and parse command line - (options, args) = U.Start(parser, argv=argv, add_group_dedup_options=False) + (options, args) = U.Start(parser, argv=argv, add_group_dedup_options=False, add_dedup_count_sam_options=True) options.per_gene = True # hardcodes counting to per-gene only diff --git a/umi_tools/dedup.py b/umi_tools/dedup.py index a518fc6..e5acc9f 100644 --- a/umi_tools/dedup.py +++ b/umi_tools/dedup.py @@ -201,7 +201,7 @@ def main(argv=None): parser.add_option_group(group) # add common options (-h/--help, ...) and parse command line - (options, args) = U.Start(parser, argv=argv) + (options, args) = U.Start(parser, argv=argv, add_dedup_count_sam_options=True) U.validateSamOptions(options, group=False) diff --git a/umi_tools/group.py b/umi_tools/group.py index 8780800..9767ace 100644 --- a/umi_tools/group.py +++ b/umi_tools/group.py @@ -150,7 +150,7 @@ def main(argv=None): parser.add_option_group(group) # add common options (-h/--help, ...) and parse command line - (options, args) = U.Start(parser, argv=argv) + (options, args) = U.Start(parser, argv=argv, add_group_sam_options=True) U.validateSamOptions(options, group=True)