Ejemplo n.º 1
0
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),))
Ejemplo n.º 2
0
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),))
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
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),))
Ejemplo n.º 6
0
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),))
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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}})
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
def test_fill_dict__empty_dicts():
    result = utils.fill_dict({}, {})
    assert_equal(result, {})
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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}})
Ejemplo n.º 14
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)
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
def test_fill_dict__empty_dicts():
    result = utils.fill_dict({}, {})
    assert_equal(result, {})