<commit_before>-- lua-npge, Nucleotide PanGenome explorer (Lua module)
-- Copyright (C) 2014-2015 <NAME>
-- See the LICENSE file for terms of use.

describe("npge.fragment.overlaps", function()

    local model = require 'npge.model'
    local s = model.Sequence("genome&chromosome&c", "ATGC")
    local Fragment = model.Fragment
    local overlaps = require 'npge.fragment.overlaps'

    it("non-parted vs non-parted, same ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 0, 0, 1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 1, 1),
                Fragment(s, 1, 2, 1)
            ), {
                Fragment(s, 1, 1, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 1, 1, 1)
            ), {
            }
        )
    end)

    it("non-parted vs non-parted, different ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 0, 0, -1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 0, -1),
                Fragment(s, 0, 0, 1)
            ), {
                Fragment(s, 0, 0, -1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 1, -1)
            ), {
                Fragment(s, 1, 1, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 2, -1)
            ), {
            }
        )
    end)

    it("non-parted vs parted, same ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 3, 0, 1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 3, 1),
                Fragment(s, 2, 1, 1)
            ), {
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 3, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 2, 1, 1)
            ), {
                Fragment(s, 1, 1, 1),
                Fragment(s, 2, 2, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 3, 0, 1)
            ), {
            }
        )
    end)

    it("non-parted vs parted, different ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 0, 3, -1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 3, 1),
                Fragment(s, 1, 2, -1)
            ), {
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 3, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 1, 2, -1)
            ), {
                Fragment(s, 1, 1, 1),
                Fragment(s, 2, 2, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 0, 3, -1)
            ), {
            }
        )
    end)

    it("parted vs parted, same ori", function()
        assert.same(
            overlaps(
                Fragment(s, 2, 1, 1),
                Fragment(s, 3, 0, 1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 3, 0, 1),
                Fragment(s, 2, 1, 1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 2, 1, 1),
                Fragment(s, 3, 2, 1)
            ), {
                Fragment(s, 2, 2, 1),
                Fragment(s, 3, 1, 1),
            }
        )
    end)

    it("parted vs parted, different ori", function()
        assert.same(
            overlaps(
                Fragment(s, 2, 1, 1),
                Fragment(s, 0, 3, -1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 3, 0, 1),
                Fragment(s, 1, 2, -1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, -1),
                Fragment(s, 3, 2, 1)
            ), {
                Fragment(s, 1, 3, -1),
                Fragment(s, 2, 2, -1),
            }
        )
    end)

end)<commit_msg>test fragment.overlaps with another sequence<commit_after>-- lua-npge, Nucleotide PanGenome explorer (Lua module)
-- Copyright (C) 2014-2015 <NAME>
-- See the LICENSE file for terms of use.

describe("npge.fragment.overlaps", function()

    local model = require 'npge.model'
    local s = model.Sequence("genome&chromosome&c", "ATGC")
    local Fragment = model.Fragment
    local overlaps = require 'npge.fragment.overlaps'

    it("non-parted vs non-parted, same ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 0, 0, 1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 1, 1),
                Fragment(s, 1, 2, 1)
            ), {
                Fragment(s, 1, 1, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 1, 1, 1)
            ), {
            }
        )
    end)

    it("non-parted vs non-parted, different ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 0, 0, -1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 0, -1),
                Fragment(s, 0, 0, 1)
            ), {
                Fragment(s, 0, 0, -1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 1, -1)
            ), {
                Fragment(s, 1, 1, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 2, -1)
            ), {
            }
        )
    end)

    it("non-parted vs parted, same ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 3, 0, 1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 3, 1),
                Fragment(s, 2, 1, 1)
            ), {
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 3, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 2, 1, 1)
            ), {
                Fragment(s, 1, 1, 1),
                Fragment(s, 2, 2, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 3, 0, 1)
            ), {
            }
        )
    end)

    it("non-parted vs parted, different ori", function()
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s, 0, 3, -1)
            ), {
                Fragment(s, 0, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 0, 3, 1),
                Fragment(s, 1, 2, -1)
            ), {
                Fragment(s, 0, 1, 1),
                Fragment(s, 2, 3, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 1, 2, -1)
            ), {
                Fragment(s, 1, 1, 1),
                Fragment(s, 2, 2, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, 1),
                Fragment(s, 0, 3, -1)
            ), {
            }
        )
    end)

    it("parted vs parted, same ori", function()
        assert.same(
            overlaps(
                Fragment(s, 2, 1, 1),
                Fragment(s, 3, 0, 1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 3, 0, 1),
                Fragment(s, 2, 1, 1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 2, 1, 1),
                Fragment(s, 3, 2, 1)
            ), {
                Fragment(s, 2, 2, 1),
                Fragment(s, 3, 1, 1),
            }
        )
    end)

    it("parted vs parted, different ori", function()
        assert.same(
            overlaps(
                Fragment(s, 2, 1, 1),
                Fragment(s, 0, 3, -1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 3, 0, 1),
                Fragment(s, 1, 2, -1)
            ), {
                Fragment(s, 3, 0, 1),
            }
        )
        assert.same(
            overlaps(
                Fragment(s, 1, 2, -1),
                Fragment(s, 3, 2, 1)
            ), {
                Fragment(s, 1, 3, -1),
                Fragment(s, 2, 2, -1),
            }
        )
    end)

    it("another sequence", function()
        local s2 = model.Sequence("genome2&chromosome&c", "AAAA")
        assert.same(
            overlaps(
                Fragment(s, 0, 0, 1),
                Fragment(s2, 0, 0, 1)
            ), {
            }
        )
    end)

end)
{'fraction_non_alphanumeric': 0.1304305757135946, 'fraction_numerical': 0.0401548137397194, 'mean_word_length': 0.8470335954253038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3287307', 'n_tokens_mistral': 3756, 'n_tokens_neox': 3090, 'n_words': 783}