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
def test_is_value_ge__default_set__valid_value(): spec = ValueGE(10, default=10) assert_equal(spec.default, 10)
def test_is_value_ge__default_not_set(): spec = ValueGE(10) assert_is(spec.default, DEFAULT_NOT_SET)
def test_value_ge__custom_description(): spec = ValueGE('Bar', description='no less than {rvalue}') assert_equal(spec.description, "no less than 'Bar'")
def test_value_ge__default_description(): spec = ValueGE('Foo') assert_equal(spec.description, "value >= 'Foo'")
def test_value_ge__accepts_value_gt__with_key(): spec = ValueGE(7, key=len) spec(_DUMMY_PATH, "abcdefgh")
def test_value_ge__accepts_value_lt__with_key(): spec = ValueGE(7, key=len) assert_raises(MakefileError, spec, _DUMMY_PATH, "abcdef")
def test_value_ge__accepts_value_gt(): spec = ValueGE(7) spec(_DUMMY_PATH, 8)
def test_value_ge__rejects_value_lt(): spec = ValueGE(7) assert_raises(MakefileError, spec, _DUMMY_PATH, 6)
# 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", "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":