def _update_msa(mkfile): msa = mkfile["MultipleSequenceAlignment"] defaults = msa.pop("Defaults") defaults.setdefault("Program", "MAFFT") defaults["MAFFT"].setdefault("Algorithm", "MAFFT") for key in mkfile["Project"]["Regions"]: msa[key] = fill_dict(msa.get(key, {}), defaults) unknown_regions = set(msa) - set(mkfile["Project"]["Regions"]) if unknown_regions: raise MakefileError("Unknown Regions of Interest in Genotyping: %s" % (", ".join(unknown_regions),))
def _update_msa(mkfile): msa = mkfile["MultipleSequenceAlignment"] defaults = msa.pop("Defaults") defaults.setdefault("Program", "MAFFT") defaults["MAFFT"].setdefault("Algorithm", "MAFFT") for key in mkfile["Project"]["Regions"]: msa[key] = fill_dict(msa.get(key, {}), defaults) unknown_regions = set(msa) - set(mkfile["Project"]["Regions"]) if unknown_regions: raise MakefileError("Unknown Regions of Interest in Genotyping: %s" \ % (", ".join(unknown_regions),))
def _do_update_options(options, data, path): options = copy.deepcopy(options) if "Options" in data: if "Features" in data["Options"]: raise MakefileError("Features may only be specified at root " "level, not at %r" % (":".join(path),)) # Fill out missing values using those of prior levels options = fill_dict(destination=data.pop("Options"), source=options) _update_possibly_empty_lists(options) if len(path) < 2: for key in data: if key != "Options": _do_update_options(options, data[key], path + (key,)) else: data["Options"] = options
def _do_update_options(options, data, path): options = copy.deepcopy(options) if "Options" in data: if "Features" in data["Options"]: raise MakefileError("Features may only be specified at root " "level, not at %r" % (":".join(path), )) # Fill out missing values using those of prior levels options = fill_dict(destination=data.pop("Options"), source=options) _update_possibly_empty_lists(options) if len(path) < 2: for key in data: if key != "Options": _do_update_options(options, data[key], path + (key, )) else: data["Options"] = options
def _update_genotyping(mkfile): genotyping = mkfile["Genotyping"] defaults = genotyping.pop("Defaults") defaults.setdefault("Padding", 5) defaults["VCF_Filter"].setdefault("MaxReadDepth", 0) for (key, subdd) in genotyping.iteritems(): if subdd.get("GenotypeEntirePrefix"): message = "GenotypeEntirePrefix is only allowed for prefixes " \ "using default parameters, but is set for %r" % (key,) raise MakefileError(message) for key in mkfile["Project"]["Regions"]: subdd = fill_dict(genotyping.get(key, {}), defaults) subdd["Random"]["--padding"] = subdd["Padding"] genotyping[key] = subdd regions = set(genotyping) unknown_regions = regions - set(mkfile["Project"]["Regions"]) if unknown_regions: raise MakefileError("Unknown Regions of Interest in Genotyping: %s" \ % (", ".join(unknown_regions),))
def test_fill_dict__source_not_modified(): expected = {"a": 1, "b": {"c": 2, "d": 3}} source = {"a": 1, "b": {"c": 2, "d": 3}} destination = {"b": {"d": 0}} _result = utils.fill_dict(destination, source) assert_equal(source, expected)
def test_fill_dict__destination_not_modified(): source = {"a": 1, "b": {"c": 2, "d": 3}} destination = {"b": {"d": 0}} _result = utils.fill_dict(destination, source) assert_equal(destination, {"b": {"d": 0}})
def test_fill_dict__filling_full_dict(): source = {"a": 1, "b": {"c": 2, "d": 3}} destination = {"a": 2, "b": {"c": 3, "d": 4}} expected = {"a": 2, "b": {"c": 3, "d": 4}} result = utils.fill_dict(destination, source) assert_equal(result, expected)
def test_fill_dict__filling_empty_dict(): source = {"a": 1, "b": {"c": 2, "d": 3}} expected = {"a": 1, "b": {"c": 2, "d": 3}} result = utils.fill_dict({}, source) assert_equal(result, expected)
def test_fill_dict__empty_dicts(): result = utils.fill_dict({}, {}) assert_equal(result, {})
def test_fill_dict__source_not_modified(): expected = {"a" : 1, "b" : {"c" : 2, "d" : 3}} source = {"a" : 1, "b" : {"c" : 2, "d" : 3}} destination = {"b" : {"d" : 0}} _result = utils.fill_dict(destination, source) assert_equal(source, expected)
def test_fill_dict__destination_not_modified(): source = {"a" : 1, "b" : {"c" : 2, "d" : 3}} destination = {"b" : {"d" : 0}} _result = utils.fill_dict(destination, source) assert_equal(destination, {"b" : {"d" : 0}})
def test_fill_dict__filling_full_dict(): source = {"a" : 1, "b" : {"c" : 2, "d" : 3}} destination = {"a" : 2, "b" : {"c" : 3, "d" : 4}} expected = {"a" : 2, "b" : {"c" : 3, "d" : 4}} result = utils.fill_dict(destination, source) assert_equal(result, expected)
def test_fill_dict__filling_empty_dict(): source = {"a" : 1, "b" : {"c" : 2, "d" : 3}} expected = {"a" : 1, "b" : {"c" : 2, "d" : 3}} result = utils.fill_dict({}, source) assert_equal(result, expected)