Beispiel #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
Beispiel #2
0
def test_is_value_in__default_set__valid_value():
    spec = ValueIn(range(5), default=4)
    assert_equal(spec.default, 4)
Beispiel #3
0
def test_is_value_in__default_not_set():
    spec = ValueIn(range(5))
    assert_is(spec.default, DEFAULT_NOT_SET)
Beispiel #4
0
def test_value_in__custom_description():
    spec = ValueIn(("Abc", "bCe", "cdE"), description="One of {rvalue}")
    assert_equal(spec.description, "One of 'Abc', 'bCe', or 'cdE'")
Beispiel #5
0
def test_value_in__default_description():
    spec = ValueIn(("Abc", "bCe", "cdE"))
    assert_equal(spec.description, "value in 'Abc', 'bCe', or 'cdE'")
Beispiel #6
0
def test_value_in__case_sensitive__value_in_not_set():
    spec = ValueIn(("Abc", "bCe", "cdE"))
    assert_raises(MakefileError, spec, _DUMMY_PATH, "Bce")
Beispiel #7
0
def test_value_in__case_sensitive__value_in_set():
    spec = ValueIn(("Abc", "bCe", "cdE"))
    spec(_DUMMY_PATH, "bCe")
Beispiel #8
0
def test_value_in__single_value_not_in_set__with_key():
    spec = ValueIn(range(5), key=len)
    assert_raises(MakefileError, spec, _DUMMY_PATH, "abcde")
Beispiel #9
0
def test_value_in__single_value_in_set__with_key():
    spec = ValueIn(range(5), key=len)
    spec(_DUMMY_PATH, "a")
Beispiel #10
0
def test_value_in__single_value_not_in_set():
    spec = ValueIn(range(5))
    assert_raises(MakefileError, spec, _DUMMY_PATH, 5)
Beispiel #11
0
def test_value_in__single_value_in_set():
    spec = ValueIn(range(5))
    spec(_DUMMY_PATH, 1)
Beispiel #12
0
     IsStr: {
         # Which program to use; TODO: Add support for other programs
         "Program": StringIn(("examl", ), default="examl"),
         # Exclude one or more samples from the phylogeny
         "ExcludeSamples": [IsStr],
         # Which samples to root the final trees on / or midpoint rooting
         "RootTreesOn": [IsStr],
         # Create a tree per gene, for each region of interest,
         # or create a supermatrix tree from all regions specified.
         "PerGeneTrees": IsBoolean(default=False),
         # Selection of regions of interest / settings per region
         "RegionsOfInterest": {
             IsStr: {
                 "Partitions":
                 Or(And(IsStr, ValuesSubsetOf("123456789X")),
                    ValueIn([False]),
                    default=REQUIRED_VALUE),
                 "SubsetRegions":
                 Or(IsStr, IsNone, default=None),
             },
         },
         "SubsetRegions": {
             IsStr: IsStr,
         },
         "ExaML": {
             "Bootstraps": IsUnsignedInt(default=100),
             "Replicates": IsUnsignedInt(default=1),
             "Model": StringIn(("GAMMA", "PSR"), default="gamma"),
         }
     }
 },
Beispiel #13
0
        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":
    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),