Exemple #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
Exemple #2
0
def test_or__default_set__valid_value():
    spec = Or(IsInt, ValueGT(10), default=17)
    assert_equal(spec.default, 17)
Exemple #3
0
def test_or__default_not_set():
    spec = Or(IsInt, ValueGT(10))
    assert_is(spec.default, DEFAULT_NOT_SET)
Exemple #4
0
def test_or__rejects_if_both_specs_fail():
    spec = Or(IsStr, IsBoolean)
    assert_raises(MakefileError, spec, _DUMMY_PATH, 1)
Exemple #5
0
def test_or__accepts_second_test():
    spec = Or(IsStr, IsBoolean)
    spec(_DUMMY_PATH, False)
Exemple #6
0
def test_or__accepts_first_test():
    spec = Or(IsStr, IsBoolean)
    spec(_DUMMY_PATH, "Foo")
Exemple #7
0
        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),
    "MPileup": {
        StringStartsWith("-"): Or(IsInt, IsStr, IsNone),
    },
    "BCFTools": {
        StringStartsWith("-"): Or(IsInt, IsStr, IsNone),
    },
    "Random": {
        "--min-distance-to-indels": IsUnsignedInt,
    },
    "VCF_Filter": {
        "MaxReadDepth":
        Or(IsUnsignedInt, IsDictOf(IsStr, IsUnsignedInt), StringIn(
            ("auto", ))),
        "--keep-ambigious-genotypes":
        IsNone,
        "--min-quality":
        IsUnsignedInt,
Exemple #8
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),
Exemple #9
0
import sys
import pprint

from pypeline.common.makefile import \
     MakefileError, \
     read_makefile, \
     WithoutDefaults, \
     Or, \
     IsInt, \
     IsFloat, \
     IsStr, \
     StringStartsWith


_SPECIFICATION_OF_OPTIONS = {
    StringStartsWith("--") : Or(IsInt, IsFloat),
    "--min-depth"          : IsInt(default = 8),
    "--max-depth"          : IsInt(default = 100),
}


_MAKEFILE_SPECIFICATION = {
    "Defaults"  : _SPECIFICATION_OF_OPTIONS,

    "VCF_Files" : {
        IsStr : {
            "Output_File" : IsStr,
            "Options" : WithoutDefaults(_SPECIFICATION_OF_OPTIONS),
        }
    }
}
Exemple #10
0
             },
         },
     "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" : {
         "Mappability"   : IsStr,
         "MaxReadDepth"  : Or(IsUnsignedInt, IsDictOf(IsStr, IsInt)),
         IsStrWithPrefix("-") : CLI_PARAMETERS,
         },
     },
 "MSAlignment" : {
     "Enabled"   : IsBoolean,
     "Default"   : AnyOf("mafft", case_sensitive = False),
     "MAFFT" : {
         "Algorithm" : AnyOf("auto", "g-ins-i", case_sensitive = False), # TODO
         },
     },
 "Phylogenetic Inference" : {
     "ExcludeGroups" : IsListOf(IsStr),
     "Default" : AnyOf("raxml", "raxml-light", "examl", case_sensitive = False),
     "ExaML" : {
         "Threads"    : IsInt,
Exemple #11
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"))