Skip to content

Commit

Permalink
ex-274 (dkriti/cgates) updating include_all in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dkriti committed Jun 15, 2015
1 parent 702fd5c commit ddd5eb8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
24 changes: 12 additions & 12 deletions jacquard/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import re

import natsort
import textwrap

import jacquard.utils.logger as logger
import jacquard.utils.utils as utils
Expand Down Expand Up @@ -172,11 +173,11 @@ def __init__(self, args):
"at_least_one_somatic": _Filter.\
_include_row_if_any_somatic}
self._args = args
if args.include_all and (args.include_cells or args.include_rows):
msg = ('Unable to process command-line arguments. Neither '
'--include_cells nor --include_rows can be specified if '
'--include_all is specified.')
raise utils.UsageError(msg)
# if args.include_all and (args.include_cells or args.include_rows):
# msg = ('Unable to process command-line arguments. Neither '
# '--include_cells nor --include_rows can be specified if '
# '--include_all is specified.')
# raise utils.UsageError(msg)

if args.include_all:
cell_filter_strategy = self._cell_filters["all"]
Expand Down Expand Up @@ -709,7 +710,7 @@ def _merge_records(vcf_readers,

def _get_format_tag_regex(args):
if args.tags and args.include_all:
msg =("Unable to process command-line arguments. --include_tags cannot "
msg =("Unable to process command-line arguments. --include_format_tags cannot "
"be specified if --include_all is specified.")
raise utils.UsageError(msg)

Expand All @@ -727,14 +728,13 @@ def add_subparser(subparser):

parser = subparser.add_parser("merge",
formatter_class=utils._JacquardHelpFormatter,
usage=["[--include_format_tags=JQ_.*] [--include_cells=valid] [--include_rows=at_least_one_somatic]"],
description=('\n\n'
'Arguments in the [] are DEFAULT\n'
'\n'),
usage=[" [--include_format_tags=JQ_.*]\n"
"\t\t\t\t\t[--include_cells=valid]\n"
"\t\t\t\t\t[--include_rows=at_least_one_somatic]"],
help="Accepts a directory of VCFs and returns a single merged VCF file.")
parser.add_argument("input", help="Directory containing VCF files. Other file types ignored")
parser.add_argument("output", help="VCF file")
parser.add_argument("--include_all", action="store_true", help="Useful when merging untranslated VCFs which have already been filtered to passing variants. Equivalent to --include_tags='.*' --include_cells=all --include_rows=all")
parser.add_argument("--include_all", action="store_true", help=textwrap.fill("Useful when merging untranslated VCFs which have already been filtered to passing variants. Equivalent to --include_format_tags='.*' --include_cells=all --include_rows=all"))
parser.add_argument("--include_cells",
choices=["all", "valid", "passed", "somatic"],
default="valid",
Expand All @@ -752,7 +752,7 @@ def add_subparser(subparser):
"all_passed: Include loci where all variants passed\n"
"all_somatic: Include loci where all variants were somatic\n"),
metavar="")
parser.add_argument("--include_format_tags", dest='tags', help="Comma-separated user-defined list of regular expressions for format tags to be included in output", metavar="")
parser.add_argument("--include_format_tags", dest='tags', help=textwrap.fill("Comma-separated user-defined list of regular expressions for format tags to be included in output"), metavar="")
parser.add_argument("--force", action='store_true', help="Overwrite contents of output directory")
parser.add_argument("--log_file", help="Log file destination", metavar="")
parser.add_argument("-v", "--verbose", action='store_true')
Expand Down
38 changes: 19 additions & 19 deletions test/merge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,24 @@ def test_init_includeAllFlag(self):
self.assertEquals(merge._Filter._include_row_if_all,
record_filter._row_filter_strategy)

def test_init_includeAllFlag_raisesError(self):
args = Namespace(include_all=True, include_cells=True, include_rows=True)
self.assertRaisesRegexp(utils.UsageError,
"Unable to process command-line arguments. Neither --include_cells nor --include_rows can be specified if --include_all is specified.",
merge._Filter,
args)

args = Namespace(include_all=True, include_cells=False, include_rows=True)
self.assertRaisesRegexp(utils.UsageError,
"Unable to process command-line arguments. Neither --include_cells nor --include_rows can be specified if --include_all is specified.",
merge._Filter,
args)

args = Namespace(include_all=True, include_cells=True, include_rows=False)
self.assertRaisesRegexp(utils.UsageError,
"Unable to process command-line arguments. Neither --include_cells nor --include_rows can be specified if --include_all is specified.",
merge._Filter,
args)
# def test_init_includeAllFlag_raisesError(self):
# args = Namespace(include_all=True, include_cells=True, include_rows=True)
# self.assertRaisesRegexp(utils.UsageError,
# "Unable to process command-line arguments. Neither --include_cells nor --include_rows can be specified if --include_all is specified.",
# merge._Filter,
# args)
#
# args = Namespace(include_all=True, include_cells=False, include_rows=True)
# self.assertRaisesRegexp(utils.UsageError,
# "Unable to process command-line arguments. Neither --include_cells nor --include_rows can be specified if --include_all is specified.",
# merge._Filter,
# args)
#
# args = Namespace(include_all=True, include_cells=True, include_rows=False)
# self.assertRaisesRegexp(utils.UsageError,
# "Unable to process command-line arguments. Neither --include_cells nor --include_rows can be specified if --include_all is specified.",
# merge._Filter,
# args)

def test_init_includeValidAnysomaticByDefault(self):
args = Namespace(include_all=False, include_cells="valid", include_rows="at_least_one_somatic")
Expand Down Expand Up @@ -579,7 +579,7 @@ def test_get_format_tag_regex_includeAll(self):
def test_get_format_tag_regex_raisesError(self):
args = Namespace(include_all=True, tags=True)
self.assertRaisesRegexp(utils.UsageError,
"Unable to process command-line arguments. --include_tags cannot be specified if --include_all is specified.",
"Unable to process command-line arguments. --include_format_tags cannot be specified if --include_all is specified.",
merge._get_format_tag_regex,
args)

Expand Down

0 comments on commit ddd5eb8

Please sign in to comment.