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

-- Options are same as options of BlastHits
return function(query, bank, options)
    options = options or {}
    local algo = require 'npge.algo'
    local CS = algo.ConsensusSequences
    local bank_cons, seq2block = CS(bank, 'bank')
    local s2b
    local query_cons, blockset
    if query == bank then
        query_cons = bank_cons
        blockset = bank
    elseif options.subset then
        blockset = bank
        local b2s = {}
        for seq, block in pairs(seq2block) do
            b2s[block] = seq
        end
        local query_seqs = {}
        for block in query:iterBlocks() do
            local seq = assert(b2s[block])
            table.insert(query_seqs, seq)
        end
        local BlockSet = require 'npge.model.BlockSet'
        query_cons = BlockSet(query_seqs, {})
    else
        local query_s2b
        query_cons, query_s2b = CS(query, 'query')
        for seq, block in pairs(query_s2b) do
            seq2block[seq] = block
        end
        blockset = algo.Merge(query, bank)
    end
    local hits_cons = algo.BlastHits(query_cons, bank_cons,
        options)
    hits_cons = algo.ExcludeSelfOverlap(hits_cons)
    hits_cons = algo.Cover(hits_cons)
    local hits = algo.UnwindBlocks(hits_cons,
        blockset, seq2block)
    hits = algo.GoodSubblocks(hits)
    return hits
end<commit_msg>AddGoodBlast: parallel BlastHits and GoodSubblocks<commit_after>-- lua-npge, Nucleotide PanGenome explorer (Lua module)
-- Copyright (C) 2014-2015 <NAME>
-- See the LICENSE file for terms of use.

-- Options are same as options of BlastHits
return function(query, bank, options)
    options = options or {}
    local algo = require 'npge.algo'
    local CS = algo.ConsensusSequences
    local bank_cons, seq2block = CS(bank, 'bank')
    local s2b
    local query_cons, blockset
    if query == bank then
        query_cons = bank_cons
        blockset = bank
    elseif options.subset then
        blockset = bank
        local b2s = {}
        for seq, block in pairs(seq2block) do
            b2s[block] = seq
        end
        local query_seqs = {}
        for block in query:iterBlocks() do
            local seq = assert(b2s[block])
            table.insert(query_seqs, seq)
        end
        local BlockSet = require 'npge.model.BlockSet'
        query_cons = BlockSet(query_seqs, {})
    else
        local query_s2b
        query_cons, query_s2b = CS(query, 'query')
        for seq, block in pairs(query_s2b) do
            seq2block[seq] = block
        end
        blockset = algo.Merge(query, bank)
    end
    local hits_cons = algo.Workers.BlastHits(
        query_cons, bank_cons, options)
    hits_cons = algo.ExcludeSelfOverlap(hits_cons)
    hits_cons = algo.Cover(hits_cons)
    local hits = algo.UnwindBlocks(hits_cons,
        blockset, seq2block)
    hits = algo.Workers.GoodSubblocks(hits)
    return hits
end
{'fraction_non_alphanumeric': 0.08383035122597747, 'fraction_numerical': 0.012591119946984758, 'mean_word_length': 2.399774774774775, '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': '2111361', 'n_tokens_mistral': 974, 'n_tokens_neox': 957, 'n_words': 268}