Example #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
Example #2
0
def test_string_in__default_set__valid_value():
    spec = StringIn("ABCDEFGH", default="e")
    assert_equal(spec.default, "e")
Example #3
0
def test_string_in__case_insensitive__mixed_string__string_found():
    spec = StringIn(("A", "c", "B", 1, 2, 3))
    spec(_DUMMY_PATH, "a")
Example #4
0
def test_string_in__default_not_set():
    spec = StringIn("ABCDEFGH")
    assert_is(spec.default, DEFAULT_NOT_SET)
Example #5
0
def test_string_in__case_insensitive__value_not_set():
    spec = StringIn(("Abc", "bCe", "cdE"))
    assert_raises(MakefileError, spec, _DUMMY_PATH, "ABce")
Example #6
0
def test_string_in__case_insensitive__value_in_set():
    spec = StringIn(("Abc", "bCe", "cdE"))
    spec(_DUMMY_PATH, "Bce")
Example #7
0
    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

# Genotyping settings; note that explicit lists must not be used here, to allow
# proper inheritance of default values. Use IsListOf instead.
_VALIDATION_GENOTYPES = {
    "Padding": IsUnsignedInt,
    "GenotypeEntirePrefix": IsBoolean(default=False),
Example #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",
Example #9
0
_VALIDATION_NUCLEO = {
    "Enabled": IsBoolean(default=False),
    "Apply_GC_Correction": IsBoolean(default=True),
    "ExcludeBed": EXCLUDEBED,
    "--NucleosomeFlanks": IsUnsignedInt(default=25),
    "--NucleosomeSize": IsUnsignedInt(default=147),
    "--NucleosomeOffset": IsUnsignedInt(default=12)
}
_VALIDATION_METHYL = {
    "Enabled": IsBoolean(default=False),
    "ExcludeBed": EXCLUDEBED,
    "--ReadBases": IsUnsignedInt(default=15),
    "--MinBaseQuality": IsUnsignedInt(default=20),
    "--SkipThreePrime": IsUnsignedInt(default=0),
    "--SkipFivePrime": IsUnsignedInt(default=0),
    "--Primes": StringIn(('five', 'three', 'both'), default='five')
}
_VALIDATION_PHASO = {
    "Enabled": IsBoolean(default=False),
    "ExcludeBed": EXCLUDEBED,
    "Apply_GC_Correction": IsBoolean(default=False),
    "--SubsetPileup": IsUnsignedInt(default=1),
    "--MaxRange": IsUnsignedInt(default=1500)
}
_VALIDATION_WRITEDEPTH = {
    "Enabled": IsBoolean(default=False),
    "ExcludeBed": EXCLUDEBED,
    "Apply_GC_Correction": IsBoolean(default=True)
}

_VALIDATION_TOOLS = {