_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), }
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": {
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,
def test_or__default_set__must_meet_spec(): with pytest.raises(ValueError): Or(IsInt, ValueIn((10, )), default=5.5)
def test_or__defaults_not_set_in_specs(): with pytest.raises(ValueError): Or(IsInt(default=10), ValueIn((10, )))
def test_or__default_not_set(): spec = Or(IsInt, ValueIn((10, ))) assert spec.default is DEFAULT_NOT_SET
def test_or__default_set__valid_value(): spec = Or(IsInt, ValueIn((10, )), default=17) assert spec.default == 17
def test_or__rejects_no_tests(): with pytest.raises(ValueError): Or()
def test_or__rejects_non_spec_tests(): with pytest.raises(TypeError): Or(id)
def test_or__rejects_if_both_specs_fail(): spec = Or(IsStr, IsBoolean) with pytest.raises(MakefileError): spec(_DUMMY_PATH, 1)
def test_or__accepts_second_test(): spec = Or(IsStr, IsBoolean) spec(_DUMMY_PATH, False)
def test_or__accepts_first_test(): spec = Or(IsStr, IsBoolean) spec(_DUMMY_PATH, "Foo")
############################################################################### # 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)
"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,