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

local ori = function(start, stop)
    if start < stop then
        return 1
    else
        return -1
    end
end

local function readBlast(file, query, bank, same)
    local new_blocks = {}
    local query_name, subject_name
    local query_row, subject_row
    local query_start, subject_start
    local query_stop, subject_stop
    local goodHit = function()
        return query_name and subject_name
            and query_row and subject_row
    end
    if same then
        local goodHit0 = goodHit
        goodHit = function()
            return goodHit0() and query_name <= subject_name
        end
    end
    local function tryAdd()
        if goodHit() then
            assert(query_row)
            assert(subject_row)
            assert(query_start)
            assert(query_stop)
            assert(subject_start)
            assert(subject_stop)
            local Fragment = require 'npge.model.Fragment'
            local query_seq =
                query:sequenceByName(query_name)
            assert(query_seq)
            local query_ori = ori(query_start, query_stop)
            local query_f = Fragment(query_seq,
                query_start - 1, query_stop - 1, query_ori)
            local subject_seq =
                bank:sequenceByName(subject_name)
            assert(subject_seq)
            local subject_ori = ori(subject_start, subject_stop)
            local subject_f = Fragment(subject_seq,
                subject_start - 1, subject_stop - 1,
                subject_ori)
            local Block = require 'npge.model.Block'
            local query_row1 = table.concat(query_row)
            local subject_row1 = table.concat(subject_row)
            local block = Block({
                {query_f, query_row1},
                {subject_f, subject_row1},
            })
            table.insert(new_blocks, block)
        end
        query_row = nil
        subject_row = nil
        query_start = nil
        query_stop = nil
        subject_start = nil
        subject_stop = nil
    end
    local startsWith = require 'npge.util.startsWith'
    local split = require 'npge.util.split'
    local trim = require 'npge.util.trim'
    local unpack = require 'npge.util.unpack'<commit_msg>BlastHits, same=true: filter out more hits<commit_after>-- lua-npge, Nucleotide PanGenome explorer (Lua module)
-- Copyright (C) 2014-2015 <NAME>
-- See the LICENSE file for terms of use.

local ori = function(start, stop)
    if start < stop then
        return 1
    else
        return -1
    end
end

local function readBlast(file, query, bank, same)
    local new_blocks = {}
    local query_name, subject_name
    local query_row, subject_row
    local query_start, subject_start
    local query_stop, subject_stop
    local function goodHit()
        return query_name and subject_name
            and query_row and subject_row
    end
    local function goodFragments(query_f, subject_f)
        return true
    end
    if same then
        local goodHit0 = goodHit
        goodHit = function()
            return goodHit0() and query_name <= subject_name
        end
        goodFragments = function(query_f, subject_f)
            return query_f < subject_f
        end
    end
    local function tryAdd()
        if goodHit() then
            assert(query_row)
            assert(subject_row)
            assert(query_start)
            assert(query_stop)
            assert(subject_start)
            assert(subject_stop)
            local Fragment = require 'npge.model.Fragment'
            local query_seq =
                query:sequenceByName(query_name)
            assert(query_seq)
            local query_ori = ori(query_start, query_stop)
            local query_f = Fragment(query_seq,
                query_start - 1, query_stop - 1, query_ori)
            local subject_seq =
                bank:sequenceByName(subject_name)
            assert(subject_seq)
            local subject_ori = ori(subject_start, subject_stop)
            local subject_f = Fragment(subject_seq,
                subject_start - 1, subject_stop - 1,
                subject_ori)
            if goodFragments(query_f, subject_f) then
                local Block = require 'npge.model.Block'
                local query_row1 = table.concat(query_row)
                local subject_row1 = table.concat(subject_row)
                local block = Block({
                    {query_f, query_row1},
                    {subject_f, subject_row1},
                })
                table.insert(new_blocks, block)
            end
        end
        query_row = nil
        subject_row = nil
        query_start = nil
        query_stop = nil
        subject_start = nil
        subject_stop = nil
    end
    local startsWith = require 'npge.util.startsWith'
    local split = require 'npge.util.split'
    local trim = require 'npge.util.trim'
    local unpack = require 'npge.util.unpack'
{'fraction_non_alphanumeric': 0.06620553359683795, 'fraction_numerical': 0.007905138339920948, 'mean_word_length': 1.878839590443686, 'pattern_counts': {'":': 0, '<': 10, '<?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': '896439', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1381, 'n_words': 379}