def test_specs__path_is_displayed_in_exception(): def _path_is_displayed_in_exception(spec, value): assert_raises_regexp(MakefileError, _DUMMY_PATH_STR, spec, _DUMMY_PATH, value) yield _path_is_displayed_in_exception, IsInt(), "foo" yield _path_is_displayed_in_exception, IsUnsignedInt(), -1 yield _path_is_displayed_in_exception, IsFloat(), "abc" yield _path_is_displayed_in_exception, IsBoolean(), 1 yield _path_is_displayed_in_exception, IsStr(), 1 yield _path_is_displayed_in_exception, IsNone(), 1 yield _path_is_displayed_in_exception, ValueLT(0), 1 yield _path_is_displayed_in_exception, ValueLE(0), 1 yield _path_is_displayed_in_exception, ValueGE(0), -1 yield _path_is_displayed_in_exception, ValueGT(0), -1 yield _path_is_displayed_in_exception, ValueIn([1]), 2 yield _path_is_displayed_in_exception, ValuesIntersect([1]), [2] yield _path_is_displayed_in_exception, ValuesSubsetOf([1]), [2] yield _path_is_displayed_in_exception, ValueMissing(), True yield _path_is_displayed_in_exception, And(IsStr), 1 yield _path_is_displayed_in_exception, Or(IsStr), 1 yield _path_is_displayed_in_exception, Xor(IsStr, IsInt), True yield _path_is_displayed_in_exception, Not(IsInt), 1 yield _path_is_displayed_in_exception, StringIn("abc"), 1 yield _path_is_displayed_in_exception, StringsIntersect("abc"), [1] yield _path_is_displayed_in_exception, StringsSubsetOf("abc"), [1] yield _path_is_displayed_in_exception, StringIsUppercase(), 1 yield _path_is_displayed_in_exception, StringStartsWith("FOO"), 1 yield _path_is_displayed_in_exception, StringEndsWith("FOO"), 1 yield _path_is_displayed_in_exception, IsListOf(IsInt), "foo" yield _path_is_displayed_in_exception, IsDictOf(IsInt, IsInt), 1
def _alphanum_check(whitelist): description = "characters a-z, A-Z, 0-9%s allowed" description %= (", and %r" % whitelist, ) if whitelist else "" whitelist += string.ascii_letters + string.digits return And(IsStr(), ValuesSubsetOf(whitelist, description=description))
def test_subset_of__default_set__valid_value(): spec = ValuesSubsetOf(range(5), default=[3, 4]) assert_equal(spec.default, [3, 4])
def test_subset_of__default_not_set(): spec = ValuesSubsetOf(range(5)) assert_is(spec.default, DEFAULT_NOT_SET)
def test_subset_of__chars__case_sensitive__rejects_differences_in_case(): spec = ValuesSubsetOf("abcdefghijkl ") assert_raises(MakefileError, spec, _DUMMY_PATH, "A big DEAL")
def test_subset_of__chars__case_sensitive(): spec = ValuesSubsetOf("abcdefghijkl ") spec(_DUMMY_PATH, "a big deal")
def test_subset_of__case_sensitive__value_in_not_set(): spec = ValuesSubsetOf(("Abc", "bCe", "cdE")) assert_raises(MakefileError, spec, _DUMMY_PATH, ["Bce"])
def test_subset_of__case_sensitive__value_in_set(): spec = ValuesSubsetOf(("Abc", "bCe", "cdE")) spec(_DUMMY_PATH, ["bCe"])
def test_subset_of__empty_set(): spec = ValuesSubsetOf(range(5)) spec(_DUMMY_PATH, [])
def test_subset_of__multiple_values_not_in_set(): spec = ValuesSubsetOf(range(5)) assert_raises(MakefileError, spec, _DUMMY_PATH, [4, 5])
def test_subset_of__multiple_values_in_set(): spec = ValuesSubsetOf(range(5)) spec(_DUMMY_PATH, [1, 4])
def test_subset_of__single_value_in_set(): spec = ValuesSubsetOf(range(5)) spec(_DUMMY_PATH, [1])
"PhylogeneticInference": { IsStr: { # Which program to use; TODO: Add support for other programs "Program": StringIn(("examl", ), default="examl"), # Exclude one or more samples from the phylogeny "ExcludeSamples": [IsStr], # Which samples to root the final trees on / or midpoint rooting "RootTreesOn": [IsStr], # Create a tree per gene, for each region of interest, # or create a supermatrix tree from all regions specified. "PerGeneTrees": IsBoolean(default=False), # Selection of regions of interest / settings per region "RegionsOfInterest": { IsStr: { "Partitions": Or(And(IsStr, ValuesSubsetOf("123456789X")), ValueIn([False]), default=REQUIRED_VALUE), "SubsetRegions": Or(IsStr, IsNone, default=None), }, }, "SubsetRegions": { IsStr: IsStr, }, "ExaML": { "Bootstraps": IsUnsignedInt(default=100), "Replicates": IsUnsignedInt(default=1), "Model": StringIn(("GAMMA", "PSR"), default="gamma"), } }
"--adjust": IsUnsignedInt, "--iter": IsUnsignedInt, "--forward": IsNone, "--reverse": IsNone, "--var-disp": IsNone, "--jukes-cantor": IsNone, "--diff-hangs": IsNone, "--fix-nicks": IsNone, "--use-raw-nick-freq": IsNone, "--single-stranded": IsNone, "--seq-length": IsUnsignedInt, }, # Exclude READ_TYPES from alignment/analysis "ExcludeReads": Or(IsNone, ValuesSubsetOf(_READ_TYPES), default=[]), # Features of pipeline "Features": Or(IsNone, ValuesSubsetOf(("Raw BAM", "Realigned BAM", "Coverage", "Summary", "mapDamage", "Depths", "DuplicateHist")), default=["Realigned BAM", "Coverage", "Summary", "mapDamage", "Depths"]), } _VALIDATION = { "Options": _VALIDATION_OPTIONS, "Prefixes": {