Esempio 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
Esempio n. 2
0
def test_process_makefile__missing_list_default_value():
    current = {"A": 1}
    expected = {"A": 1, "B": [1, 2, 3]}
    specs = {"A": IsInt, "B": IsListOf(IsInt, default=[1, 2, 3])}
    result = process_makefile(current, specs)
    assert_equal(result, expected)
Esempio n. 3
0
def test_is_list_of__default_set__valid_value():
    spec = IsListOf(IsInt, default=range(5))
    assert_equal(spec.default, range(5))
Esempio n. 4
0
def test_is_list_of__non_list_rejected():
    spec = IsListOf(IsInt)
    assert_raises(MakefileError, spec, _DUMMY_PATH, {1: 2})
Esempio n. 5
0
def test_is_list_of__default_not_set():
    spec = IsListOf(IsInt)
    assert_is(spec.default, DEFAULT_NOT_SET)
Esempio n. 6
0
def test_is_list_of__mixed_list_rejected():
    spec = IsListOf(IsInt)
    assert_raises(MakefileError, spec, _DUMMY_PATH, [1, 'b', 3])
Esempio n. 7
0
def test_is_list_of__default_description():
    spec = IsListOf(IsInt, IsFloat)
    assert_equal(spec.description, "[(an integer) or (a float), ...]")
Esempio n. 8
0
def test_is_list_of__list_of_ints_accepted():
    spec = IsListOf(IsInt)
    spec(_DUMMY_PATH, [1, 2, 3])
Esempio n. 9
0
def test_is_list_of__list_of_non_ints_rejected():
    spec = IsListOf(IsInt)
    assert_raises(MakefileError, spec, _DUMMY_PATH, ['a', 'b', 'c'])
Esempio n. 10
0
def test_is_list_of__empty_list_always_ok():
    spec = IsListOf(IsInt)
    spec(_DUMMY_PATH, [])
Esempio n. 11
0
        CLI_PARAMETERS,
    },
}

_VALIDATION = {
    "Project": {
        "Title": IsStr(default="Untitled"),
        "Samples": _VALIDATION_SAMPLES,
        "RegionsOfInterest": {
            IsStr: {
                "Prefix": IsStr(default=REQUIRED_VALUE),
                "Realigned": IsBoolean(default=False),
                "ProteinCoding": IsBoolean(default=False),
                "IncludeIndels": IsBoolean(default=True),
                "HomozygousContigs": {
                    IsStr: Or(IsNone, IsListOf(IsStr))
                },
            },
        },
        "FilterSingletons": {
            IsStr: [IsStr],
        },
    },
    "Genotyping": {
        "Defaults": _VALIDATION_GENOTYPES,
        IsStr: _VALIDATION_GENOTYPES,
    },
    "MultipleSequenceAlignment": {
        "Defaults": _VALIDATION_MSA,
        IsStr: _VALIDATION_MSA,
    },
Esempio n. 12
0
_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",
              "IONTORRENT", "PACBIO"),
             default="ILLUMINA"),
    # Offset for quality scores in FASTQ files.
    "QualityOffset":
    ValueIn((33, 64, "Solexa"), default=33),
    # Split a lane into multiple entries, one for each (pair of) file(s)
    "SplitLanesByFilenames":
    Or(IsBoolean, IsListOf(IsStr), default=True),
    # Format to use when compressing FASTQ files ("gz" or "bz2")
    "CompressionFormat":
    ValueIn(("gz", "bz2"), default="bz2"),
    "AdapterRemoval": {
        "Version": ValueIn(("v1.4", "v1.5+"), default="v1.5+"),
        "--pcr1": IsStr,
        "--pcr2": IsStr,
        "--adapter1": IsStr,
        "--adapter2": IsStr,
        "--maxns": IsUnsignedInt,
        "--minquality": IsUnsignedInt,
        "--trimns": Or(IsNone, IsBoolean),
        "--trimqualities": Or(IsNone, IsBoolean),
        "--collapse": Or(IsNone, IsBoolean, default=True),
        "--mm": Or(IsFloat, IsUnsignedInt, default=3),
Esempio n. 13
0
        },
    },
}


_VALIDATION = {
    "Project" : {
        "Title" : IsStr,
        "Taxa" : _validate_taxa,
        "Intervals" : {
            IsStr : {
                "Genome"         : IsStr,
                "Protein coding" : IsBoolean,
                "Orthology map"  : IsStr,
                "Homozygous Contigs" : {
                    IsStr : IsListOf(IsStr),
                    },
                },
            },
        "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" : {
Esempio n. 14
0
from pypeline.common.makefile import \
    read_makefile, \
    IsUnsignedInt, \
    IsFloat, \
    IsStr, \
    IsBoolean, \
    And, \
    Or, \
    ValueIn, \
    IsNone, \
    StringIn, \
    ValueGE, \
    ValuesSubsetOf, \
    IsListOf

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