Ejemplo n.º 1
0
def test_string_ends_with__default_set__must_meet_spec():
    with pytest.raises(ValueError):
        StringEndsWith("FooBar", default="BarFoo")
Ejemplo n.º 2
0
    defaults = msa.pop("Defaults")
    defaults.setdefault("Program", "MAFFT")
    defaults["MAFFT"].setdefault("Algorithm", "MAFFT")

    for key in mkfile["Project"]["Regions"]:
        msa[key] = fill_dict(msa.get(key, {}), defaults)

    unknown_regions = set(msa) - set(mkfile["Project"]["Regions"])
    if unknown_regions:
        raise MakefileError("Unknown Regions of Interest in Genotyping: %s" \
                            % (", ".join(unknown_regions),))


# Recursive definition of sample tree
_VALIDATION_SUBSAMPLE_KEY = And(StringStartsWith("<"),
                                StringEndsWith(">"))
_VALIDATION_SAMPLES_KEY = And(IsStr, Not(_VALIDATION_SUBSAMPLE_KEY))
_VALIDATION_SAMPLES = {
    _VALIDATION_SAMPLES_KEY: {
        "GenotypingMethod": StringIn(("reference sequence",
                                      "random sampling",
                                      "samtools"),
                                     default="samtools"),
        "SpeciesName": IsStr,  # Not used; left for backwards compatibility
        "CommonName": IsStr,   # Not used; left for backwards compatibility
        "Sex": IsStr(),
        "Gender": IsStr(),
    }
}
_VALIDATION_SAMPLES[_VALIDATION_SUBSAMPLE_KEY] = _VALIDATION_SAMPLES
Ejemplo n.º 3
0
def test_string_ends_with__default_not_set():
    spec = StringEndsWith("Foo")
    assert spec.default is DEFAULT_NOT_SET
Ejemplo n.º 4
0
def test_string_ends_with__default_set__valid_value():
    spec = StringEndsWith("Bar", default="FooBar")
    assert spec.default == "FooBar"
Ejemplo n.º 5
0
def test_string_ends_with__rejects_not_uppercase_str(value):
    spec = StringEndsWith("Foo")
    with pytest.raises(MakefileError,
                       match="Expected value: a string with postfix 'Foo'"):
        spec(_DUMMY_PATH, value)
Ejemplo n.º 6
0
def test_string_ends_with__rejects_string_without_prefix():
    spec = StringEndsWith("_A")
    with pytest.raises(MakefileError):
        spec(_DUMMY_PATH, "GHI_B")
Ejemplo n.º 7
0
def test_string_ends_with__accepts_standard_str():
    spec = StringEndsWith("_A")
    spec(_DUMMY_PATH, "BC_A")
Ejemplo n.º 8
0
    (IsInt(), "foo"),
    (IsUnsignedInt(), -1),
    (IsFloat(), "abc"),
    (IsBoolean(), 1),
    (IsStr(), 1),
    (IsNone(), 1),
    (ValueIn([1]), 2),
    (ValuesIntersect([1]), [2]),
    (ValuesSubsetOf([1]), [2]),
    (ValueMissing(), True),
    (And(IsStr), 1),
    (Or(IsStr), 1),
    (Not(IsInt), 1),
    (StringIn("abc"), 1),
    (StringStartsWith("FOO"), 1),
    (StringEndsWith("FOO"), 1),
    (IsListOf(IsInt), "foo"),
    (IsDictOf(IsInt, IsInt), 1),
)


@pytest.mark.parametrize("spec, value", _PATH_IN_EXCEPTION_VALUES)
def test_specs__path_is_displayed_in_exception(spec, value):
    with pytest.raises(MakefileError, match=_DUMMY_PATH_STR):
        spec(_DUMMY_PATH, value)


###############################################################################
###############################################################################
# process_makefile
Ejemplo n.º 9
0
    msa = mkfile["MultipleSequenceAlignment"]
    defaults = msa.pop("Defaults")
    defaults.setdefault("Program", "MAFFT")
    defaults["MAFFT"].setdefault("Algorithm", "MAFFT")

    for key in mkfile["Project"]["Regions"]:
        msa[key] = fill_dict(msa.get(key, {}), defaults)

    unknown_regions = set(msa) - set(mkfile["Project"]["Regions"])
    if unknown_regions:
        raise MakefileError("Unknown Regions of Interest in Genotyping: %s" %
                            (", ".join(unknown_regions), ))


# Recursive definition of sample tree
_VALIDATION_SUBSAMPLE_KEY = And(StringStartsWith("<"), StringEndsWith(">"))
_VALIDATION_SAMPLES_KEY = And(IsStr, Not(_VALIDATION_SUBSAMPLE_KEY))
_VALIDATION_SAMPLES = {
    _VALIDATION_SAMPLES_KEY: {
        "GenotypingMethod": RemovedOption(),
        "SpeciesName": RemovedOption(),
        "CommonName": RemovedOption(),
        "Sex": IsStr(),
        "Gender": RemovedOption(),
    }
}
_VALIDATION_SAMPLES[_VALIDATION_SUBSAMPLE_KEY] = _VALIDATION_SAMPLES

# Genotyping settings; note that explicit lists must not be used here, to allow
# proper inheritance of default values. Use IsListOf instead.
_VALIDATION_GENOTYPES = {