Beispiel #1
0
            # Mapping algorithm; availability depends on BWA version
            "Algorithm":
            StringIn(("backtrack", "mem", "bwasw"), default="backtrack"),

            # Minimum mapping quality (PHREAD) of reads to retain
            "MinQuality":
            IsUnsignedInt(default=0),
            # Remove unmapped reads or not
            "FilterUnmappedReads":
            IsBoolean(default=True),
            # Use seed region during mapping
            # Verbose name for command-line option "-l 65535"
            "UseSeed":
            IsBoolean(default=True),
            # Any number of user specific options
            StringStartsWith("-"):
            Or(IsListOf(IsStr, IsInt, IsFloat),
               Or(IsStr, IsInt, IsFloat, IsNone)),
        },
        "Bowtie2": {
            # Minimum mapping quality (PHREAD) of reads to retain
            "MinQuality":
            IsUnsignedInt(default=0),
            # Remove unmapped reads or not
            "FilterUnmappedReads":
            IsBoolean(default=True),
            # Any number of user specific options
            StringStartsWith("-"):
            Or(IsListOf(IsStr, IsInt, IsFloat),
               Or(IsStr, IsInt, IsFloat, IsNone)),
        },
Beispiel #2
0
def test_string_starts_with__default_set__must_meet_spec():
    with pytest.raises(ValueError):
        StringStartsWith("FooBar", default="BarFoo")
Beispiel #3
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": 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
Beispiel #4
0
def test_string_starts_with__default_not_set():
    spec = StringStartsWith("Foo")
    assert spec.default is DEFAULT_NOT_SET
Beispiel #5
0
def test_string_starts_with__default_set__valid_value():
    spec = StringStartsWith("Foo", default="FooBar")
    assert spec.default == "FooBar"
Beispiel #6
0
def test_string_starts_with__rejects_not_uppercase_str(value):
    spec = StringStartsWith("Foo")
    with pytest.raises(MakefileError,
                       match="Expected value: a string with prefix 'Foo'"):
        spec(_DUMMY_PATH, value)
Beispiel #7
0
def test_string_starts_with__rejects_string_without_prefix():
    spec = StringStartsWith("A_")
    with pytest.raises(MakefileError):
        spec(_DUMMY_PATH, "B_GHI")
Beispiel #8
0
def test_string_starts_with__accepts_standard_str():
    spec = StringStartsWith("A_")
    spec(_DUMMY_PATH, "A_BC")
Beispiel #9
0
_PATH_IN_EXCEPTION_VALUES = (
    (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
Beispiel #10
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 = {