コード例 #1
0
ファイル: makefile.py プロジェクト: jelber2/paleomix
_VALID_FEATURES_DICT = {
    "Coverage":
    IsBoolean(default=True),
    "Depths":
    IsBoolean(default=True),
    "DuplicateHist":
    IsBoolean(default=False),
    "RawBAM":
    IsBoolean(default=False),
    "RealignedBAM":
    IsBoolean(default=True),
    "Summary":
    IsBoolean(default=True),
    "mapDamage":
    Or(IsBoolean,
       StringIn(('rescale', 'model', 'plot', 'no', 'yes')),
       default=True)
}

_VALID_FEATURES_LIST = ValuesSubsetOf(
    ("Coverage", "Depths", "DuplicateHist", "mapDamage", "Raw BAM", "RawBAM",
     "Realigned BAM", "RealignedBAM", "Summary"))

_VALID_EXCLUDE_DICT = {
    "Single": IsBoolean(default=False),
    "Collapsed": IsBoolean(default=False),
    "CollapsedTruncated": IsBoolean(default=False),
    "Paired": IsBoolean(default=False),
    "Singleton": IsBoolean(default=False),
}
コード例 #2
0
ファイル: makefile.py プロジェクト: tmancill/paleomix
 ValueIn((33, 64, "Solexa"), default=33),
 # Split a lane into multiple entries, one for each (pair of) file(s)
 "SplitLanesByFilenames":
 RemovedOption(),
 "CompressionFormat":
 RemovedOption(),
 "AdapterRemoval": {
     "Version": RemovedOption(),
     "--pcr1": IsStr,
     "--pcr2": IsStr,
     "--adapter1": IsStr,
     "--adapter2": IsStr,
     "--adapter-list": 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),
     "--minlength": IsUnsignedInt(default=25),
     "--maxlength": IsUnsignedInt,
     "--minalignmentlength": IsUnsignedInt,
     "--minadapteroverlap": IsUnsignedInt,
     "--shift": IsUnsignedInt,
     "--qualitymax": IsUnsignedInt,
     "--mate-separator": IsStr,
 },
 # Which aliger/mapper to use (BWA/Bowtie2)
 "Aligners": {
     "Program": ValueIn(("BWA", "Bowtie2"), default="BWA"),
     "BWA": {
コード例 #3
0
ファイル: makefile.py プロジェクト: jelber2/paleomix
                                     default="samtools"),
        "SpeciesName": IsStr,  # Not used; left for backwards compatibility
        "CommonName": IsStr,   # Not used; left for backwards compatibility
        "Sex": IsStr(),
        "Gender": IsStr(),
    }
}
_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,
        "--min-allele-frequency": IsFloat,
        "--min-mapping-quality": IsUnsignedInt,
コード例 #4
0
def test_or__default_set__must_meet_spec():
    with pytest.raises(ValueError):
        Or(IsInt, ValueIn((10, )), default=5.5)
コード例 #5
0
def test_or__defaults_not_set_in_specs():
    with pytest.raises(ValueError):
        Or(IsInt(default=10), ValueIn((10, )))
コード例 #6
0
def test_or__default_not_set():
    spec = Or(IsInt, ValueIn((10, )))
    assert spec.default is DEFAULT_NOT_SET
コード例 #7
0
def test_or__default_set__valid_value():
    spec = Or(IsInt, ValueIn((10, )), default=17)
    assert spec.default == 17
コード例 #8
0
def test_or__rejects_no_tests():
    with pytest.raises(ValueError):
        Or()
コード例 #9
0
def test_or__rejects_non_spec_tests():
    with pytest.raises(TypeError):
        Or(id)
コード例 #10
0
def test_or__rejects_if_both_specs_fail():
    spec = Or(IsStr, IsBoolean)
    with pytest.raises(MakefileError):
        spec(_DUMMY_PATH, 1)
コード例 #11
0
def test_or__accepts_second_test():
    spec = Or(IsStr, IsBoolean)
    spec(_DUMMY_PATH, False)
コード例 #12
0
def test_or__accepts_first_test():
    spec = Or(IsStr, IsBoolean)
    spec(_DUMMY_PATH, "Foo")
コード例 #13
0
###############################################################################
# Path is displayed in exception

_PATH_IN_EXCEPTION_VALUES = (
    (IsInt(), "foo"),
    (IsUnsignedInt(), -1),
    (IsFloat(), "abc"),
    (IsBoolean(), 1),
    (IsStr(), 1),
    (IsNone(), 1),
    (ValueIn([1]), 2),
    (ValuesIntersect([1]), [2]),
    (ValuesSubsetOf([1]), [2]),
    (ValueMissing(), True),
    (And(IsStr), 1),
    (Or(IsStr), 1),
    (Not(IsInt), 1),
    (StringIn("abc"), 1),
    (StringStartsWith("FOO"), 1),
    (StringEndsWith("FOO"), 1),
    (IsListOf(IsInt), "foo"),
    (IsDictOf(IsInt, IsInt), 1),
)


@pytest.mark.parametrize("spec, value", _PATH_IN_EXCEPTION_VALUES)
def test_specs__path_is_displayed_in_exception(spec, value):
    with pytest.raises(MakefileError, match=_DUMMY_PATH_STR):
        spec(_DUMMY_PATH, value)

コード例 #14
0
        "GenotypingMethod": RemovedOption(),
        "SpeciesName": RemovedOption(),
        "CommonName": RemovedOption(),
        "Sex": IsStr(),
        "Gender": RemovedOption(),
    }
}
_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,