예제 #1
0
def test_split__three_groups():
    msa = {"seq1" : "ACGCAT", "seq2" : "GAGTGA"}
    expected = {"1" : {"seq1" : "AC", "seq2" : "GT"},
                "2" : {"seq1" : "CA", "seq2" : "AG"},
                "3" : {"seq1" : "GT", "seq2" : "GA"}}
    with RequiredCall(_VALIDATION_PATH, args = [msa]):
        assert_equal(split_msa(msa, "123"), expected)
    with RequiredCall(_VALIDATION_PATH, args = [msa]):
        assert_equal(split_msa(msa), expected)
예제 #2
0
def test_split__partial_group():
    msa = {"seq1" : "ACGCA", "seq2" : "GAGTG"}
    expected = {"1" : {"seq1" : "AC", "seq2" : "GT"},
                "2" : {"seq1" : "CA", "seq2" : "AG"},
                "3" : {"seq1" : "G", "seq2" : "G"}}
    with RequiredCall(_VALIDATION_PATH, args = [msa]):
        assert_equal(split_msa(msa), expected)
예제 #3
0
def test_split__empty_group():
    msa = {"seq1" : "AC", "seq2" : "GA"}
    expected = {"1" : {"seq1" : "A", "seq2" : "G"},
                "2" : {"seq1" : "C", "seq2" : "A"},
                "3" : {"seq1" : "",  "seq2" : ""}}
    with RequiredCall(_VALIDATION_PATH, args = [msa]):
        assert_equal(split_msa(msa), expected)
예제 #4
0
def test_split__three_groups():
    msa = {"seq1": "ACGCAT", "seq2": "GAGTGA"}
    expected = {
        "1": {
            "seq1": "AC",
            "seq2": "GT"
        },
        "2": {
            "seq1": "CA",
            "seq2": "AG"
        },
        "3": {
            "seq1": "GT",
            "seq2": "GA"
        }
    }
    with RequiredCall(_VALIDATION_PATH, args=[msa]):
        assert_equal(split_msa(msa, "123"), expected)
    with RequiredCall(_VALIDATION_PATH, args=[msa]):
        assert_equal(split_msa(msa), expected)
예제 #5
0
def test_split_msa__two_groups():
    msa = {"seq1": "ACGCAT", "seq2": "GAGTGA"}
    expected = {
        "1": {
            "seq1": "ACCA",
            "seq2": "GATG"
        },
        "2": {
            "seq1": "GT",
            "seq2": "GA"
        }
    }
    with RequiredCall(_VALIDATION_PATH, args=[msa]):
        assert_equal(split_msa(msa, "112"), expected)
예제 #6
0
def test_split__partial_group():
    msa = {"seq1": "ACGCA", "seq2": "GAGTG"}
    expected = {
        "1": {
            "seq1": "AC",
            "seq2": "GT"
        },
        "2": {
            "seq1": "CA",
            "seq2": "AG"
        },
        "3": {
            "seq1": "G",
            "seq2": "G"
        }
    }
    with RequiredCall(_VALIDATION_PATH, args=[msa]):
        assert_equal(split_msa(msa), expected)
예제 #7
0
def test_split__empty_group():
    msa = {"seq1": "AC", "seq2": "GA"}
    expected = {
        "1": {
            "seq1": "A",
            "seq2": "G"
        },
        "2": {
            "seq1": "C",
            "seq2": "A"
        },
        "3": {
            "seq1": "",
            "seq2": ""
        }
    }
    with RequiredCall(_VALIDATION_PATH, args=[msa]):
        assert_equal(split_msa(msa), expected)
예제 #8
0
    def _run(self, _config, temp):
        msas = []
        for filename in sorted(self._infiles):
            split_by = self._infiles[filename].get("partition_by", self._part_by)
            for (key, msa) in sorted(split_msa(read_msa(filename), split_by).items()):
                for excluded_group in self._excluded:
                    msa.pop(excluded_group)
                msas.append(("%s_%s" % (self._infiles[filename]["name"], key), msa))

        msa = join_msa(*(msa for (_, msa) in msas))
        with open(reroot_path(temp, self._out_prefix + ".phy"), "w") as output:
            output.write(interleaved_phy(msa, add_flag = self._add_flag))

        with open(reroot_path(temp, self._out_prefix + ".partitions"), "w") as output:
            end = 0
            for (name, msa) in msas:
                length = len(msa.itervalues().next())
                output.write("DNA, %s = %i-%i\n" % (name, end + 1, end + length))
                end += length
예제 #9
0
def test_split_msa__no_split_by():
    split_msa({"seq1": "ACG", "seq2": "GAT"}, split_by="")
예제 #10
0
def test_split_msa__empty_msa():
    split_msa({})
예제 #11
0
def test_split_msa__single_group():
    msa = {"seq1": "ACGCAT", "seq2": "GAGTGA"}
    expected = {'1': {"seq1": "ACGCAT", "seq2": "GAGTGA"}}
    with RequiredCall(_VALIDATION_PATH, args=[msa]):
        assert_equal(split_msa(msa, "111"), expected)
예제 #12
0
def test_split_msa__no_split_by():
    split_msa({"seq1" : "ACG", "seq2" : "GAT"}, split_by = "")
예제 #13
0
def test_split_msa__empty_msa():
    split_msa({})
예제 #14
0
def test_split_msa__two_groups():
    msa = {"seq1" : "ACGCAT", "seq2" : "GAGTGA"}
    expected = {"1" : {"seq1" : "ACCA", "seq2" : "GATG"},
                "2" : {"seq1" : "GT",   "seq2" : "GA"}}
    with RequiredCall(_VALIDATION_PATH, args = [msa]):
        assert_equal(split_msa(msa, "112"), expected)
예제 #15
0
def test_split_msa__single_group():
    msa = {"seq1" : "ACGCAT", "seq2" : "GAGTGA"}
    expected = {'1' : {"seq1" : "ACGCAT", "seq2" : "GAGTGA"}}
    with RequiredCall(_VALIDATION_PATH, args = [msa]):
        assert_equal(split_msa(msa, "111"), expected)