Exemplo n.º 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
Exemplo n.º 2
0
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))
Exemplo n.º 3
0
def test_and__default_set__valid_value():
    spec = And(IsInt, ValueGT(10), default=20)
    assert_equal(spec.default, 20)
Exemplo n.º 4
0
def test_and__default_not_set():
    spec = And(IsInt, ValueGT(10))
    assert_is(spec.default, DEFAULT_NOT_SET)
Exemplo n.º 5
0
def test_and__rejects_when_both_is_false():
    spec = And(IsFloat, ValueLT(1.5))
    assert_raises(MakefileError, spec, _DUMMY_PATH, 2)
Exemplo n.º 6
0
def test_and__accepts_when_all_true():
    spec = And(IsFloat, ValueLT(1.5))
    spec(_DUMMY_PATH, 0.0)
Exemplo n.º 7
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
        "Gender":
        IsStr(default=REQUIRED_VALUE),
    }
}
_VALIDATION_SAMPLES[_VALIDATION_SUBSAMPLE_KEY] = _VALIDATION_SAMPLES
Exemplo n.º 8
0
    return _validate_makefiles(config, makefiles)


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))


# Valid names for prefixes
_VALID_PREFIX_NAME = \
    And(_alphanum_check(whitelist="._-*"),
        Not(StringIn(["Options"] + [(s + "Reads") for s in _READ_TYPES])))

# Valid paths for prefixes; avoids some problems with e.g. Bowtie2
_VALID_PREFIX_PATH = \
    And(IsStr(), Not(ValuesIntersect("\\:?\"<>|() \t\n\v\f\r")),
        default=REQUIRED_VALUE)

# Valid strings for targets / samples / libraries / lanes
_VALID_TARGET_NAME = \
    And(_alphanum_check(whitelist="._-"),
        ValueGE(2, key=len, description="at least two characters long"))

_VALIDATION_OPTIONS = {
    # Sequencing platform, used to tag read-groups.
    "Platform":
    StringIn(("CAPILLARY", "LS454", "ILLUMINA", "SOLID", "HELICOS",
Exemplo n.º 9
0
EXCLUDEBED = Or(IsListOf(IsStr), IsStr, IsNone, default=None)


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))



_VALID_BED_NAME = _VALID_TARGET_NAME = \
    And(_alphanum_check(whitelist=".-"),
        ValueGE(2, key=len, description="at least two characters long"))

_VALIDATION_OPTIONS = {
    "BamPath": IsStr,
    "--MinMappingQuality": IsUnsignedInt(default=25),
    "--MinAlignmentLength": IsUnsignedInt(default=25),
    "--NoReadsChecked": IsUnsignedInt(default=5000)
}

_VALIDATION_GCCORRECT = {
    "Enabled": IsBoolean(default=False),
    "--NoRegions": Or(IsUnsignedInt, IsStr, default=200),
    "--ChromUsed": Or(IsStr, IsUnsignedInt, default="all"),  ## the is new
    "--MappaUniqueness": IsFloat(default=0.9)
}