Beispiel #1
0
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
Beispiel #2
0
def test_is_dict_of__default_not_set():
    spec = IsDictOf(IsInt, IsInt)
    assert_is(spec.default, DEFAULT_NOT_SET)
Beispiel #3
0
def test_is_dict_of__default_set__valid_value():
    spec = IsDictOf(IsInt, IsInt, default={1: 2})
    assert_equal(spec.default, {1: 2})
Beispiel #4
0
def test_is_dict_of__default_description():
    spec = IsDictOf(IsInt, IsStr)
    assert_equal(spec.description, "{(an integer) : (a non-empty string)}")
Beispiel #5
0
def test_is_dict_of__rejects_non_dict():
    spec = IsDictOf(IsInt, IsStr)
    assert_raises(MakefileError, spec, _DUMMY_PATH, [])
Beispiel #6
0
def test_is_dict_of__correct_key_and_wrong_value_rejected():
    spec = IsDictOf(IsInt, IsStr)
    assert_raises(MakefileError, spec, _DUMMY_PATH, {1: 1})
Beispiel #7
0
def test_is_dict_of__mixed_rejected():
    spec = IsDictOf(IsInt, IsStr)
    assert_raises(MakefileError, spec, _DUMMY_PATH, {1: 1, 2: "foo"})
Beispiel #8
0
def test_is_dict_of__correct_key_and_value_accepted():
    spec = IsDictOf(IsInt, IsStr)
    spec(_DUMMY_PATH, {1: "foo"})
Beispiel #9
0
def test_is_dict_of__empty_dict_always_ok():
    spec = IsDictOf(IsInt, IsStr)
    spec(_DUMMY_PATH, {})
Beispiel #10
0
# proper inheritance of default values. Use IsListOf instead.
_VALIDATION_GENOTYPES = {
    "Padding": IsUnsignedInt,
    "GenotypeEntirePrefix": IsBoolean(default=False),
    "MPileup": {
        StringStartsWith("-"): Or(IsInt, IsStr, IsNone),
    },
    "BCFTools": {
        StringStartsWith("-"): Or(IsInt, IsStr, IsNone),
    },
    "Random": {
        "--min-distance-to-indels": IsUnsignedInt,
    },
    "VCF_Filter": {
        "MaxReadDepth":
        Or(IsUnsignedInt, IsDictOf(IsStr, IsUnsignedInt), StringIn(
            ("auto", ))),
        "--keep-ambigious-genotypes":
        IsNone,
        "--min-quality":
        IsUnsignedInt,
        "--min-allele-frequency":
        IsFloat,
        "--min-mapping-quality":
        IsUnsignedInt,
        "--min-read-depth":
        IsUnsignedInt,
        "--max-read-depth":
        IsUnsignedInt,
        "--min-num-alt-bases":
        IsUnsignedInt,
Beispiel #11
0
       ValuesSubsetOf(("Raw BAM", "Realigned BAM", "Coverage", "Summary",
                       "mapDamage", "Depths", "DuplicateHist")),
       default=["Realigned BAM", "Coverage", "Summary", "mapDamage",
                "Depths"]),
}


_VALIDATION = {
    "Options": _VALIDATION_OPTIONS,

    "Prefixes": {
        _VALID_PREFIX_NAME: {
            "Path": _VALID_PREFIX_PATH,
            "Label": ValueIn(("nuclear", "mitochondrial", "chloroplast",
                              "plasmid", "bacterial", "viral")),
            "RegionsOfInterest": IsDictOf(IsStr, IsStr),
        },
    },

    _VALID_TARGET_NAME: {  # Target
        _VALID_TARGET_NAME: {  # Sample
            _VALID_TARGET_NAME: {  # Library
                _VALID_TARGET_NAME: Or(IsStr, IsDictOf(IsStr, IsStr)),

                "Options": WithoutDefaults(_VALIDATION_OPTIONS),
            },

            "Options": WithoutDefaults(_VALIDATION_OPTIONS),
        },

        "Options": WithoutDefaults(_VALIDATION_OPTIONS),
Beispiel #12
0
             },
         },
     "Filter Singletons" : {
         IsStr : IsListOf(IsStr),
         },
     },
 "Genotyping" : {
     "Default"  : OneOf("random", "samtools", case_sensitive = False),
     "Padding"  : IsInt,
     "Indels"   : IsBoolean,
     AnyOf("MPileup", "BCFTools", "Random") : {
         IsStrWithPrefix("-") : CLI_PARAMETERS,
         },
     "VCF_Filter" : {
         "Mappability"   : IsStr,
         "MaxReadDepth"  : Or(IsUnsignedInt, IsDictOf(IsStr, IsInt)),
         IsStrWithPrefix("-") : CLI_PARAMETERS,
         },
     },
 "MSAlignment" : {
     "Enabled"   : IsBoolean,
     "Default"   : AnyOf("mafft", case_sensitive = False),
     "MAFFT" : {
         "Algorithm" : AnyOf("auto", "g-ins-i", case_sensitive = False), # TODO
         },
     },
 "Phylogenetic Inference" : {
     "ExcludeGroups" : IsListOf(IsStr),
     "Default" : AnyOf("raxml", "raxml-light", "examl", case_sensitive = False),
     "ExaML" : {
         "Threads"    : IsInt,