<commit_before>"""Estimate resources required for processing a set of tasks.

Uses annotations provided in multitasks.py for each function to identify utilized
programs, then extracts resource requirements from the input bcbio_system file.
"""
import collections
import math

from bcbio.pipeline import config_utils
from bcbio.log import logger

def _get_resource_programs(fn, algs):
    """Retrieve programs used in analysis based on algorithm configurations.

    Helps avoid requiring core information from unused programs.
    """
    used_progs = _get_used_programs(fn, algs)
    # standard list of programs we always use
    # XXX Need to expose this in a top-level way to allow more multiprocessing
    for prog in (fn.metadata.get("resources", []) if hasattr(fn, "metadata") else []):
        if prog in used_progs:
            yield prog

def _get_ensure_functions(fn, algs):
    used_progs = _get_used_programs(fn, algs)
    for prog in (fn.metadata.get("ensure", {}).keys() if hasattr(fn, "metadata") else []):
        if prog in used_progs:
            yield fn.metadata["ensure"][prog]

def _get_used_programs(fn, algs):
    used_progs = set(["gatk", "gemini", "bcbio_coverage", "samtools",
                      "snpEff", "cufflinks", "picard", "rnaseqc"])
    for alg in algs:
        # get aligners used
        aligner = alg.get("aligner")
        if aligner:
            used_progs.add(aligner)
        vc = alg.get("variantcaller")<commit_msg>Ensure snpeff resource requirements passed along with new all lowercase approach to input keys<commit_after>"""Estimate resources required for processing a set of tasks.

Uses annotations provided in multitasks.py for each function to identify utilized
programs, then extracts resource requirements from the input bcbio_system file.
"""
import collections
import math

from bcbio.pipeline import config_utils
from bcbio.log import logger

def _get_resource_programs(fn, algs):
    """Retrieve programs used in analysis based on algorithm configurations.

    Helps avoid requiring core information from unused programs.
    """
    used_progs = _get_used_programs(fn, algs)
    # standard list of programs we always use
    # XXX Need to expose this in a top-level way to allow more multiprocessing
    for prog in (fn.metadata.get("resources", []) if hasattr(fn, "metadata") else []):
        if prog in used_progs:
            yield prog

def _get_ensure_functions(fn, algs):
    used_progs = _get_used_programs(fn, algs)
    for prog in (fn.metadata.get("ensure", {}).keys() if hasattr(fn, "metadata") else []):
        if prog in used_progs:
            yield fn.metadata["ensure"][prog]

def _get_used_programs(fn, algs):
    used_progs = set(["gatk", "gemini", "bcbio_coverage", "samtools",
                      "snpeff", "cufflinks", "picard", "rnaseqc"])
    for alg in algs:
        # get aligners used
        aligner = alg.get("aligner")
        if aligner:
            used_progs.add(aligner)
        vc = alg.get("variantcaller")
{'fraction_non_alphanumeric': 0.09450915141430949, 'fraction_numerical': 0.0, 'mean_word_length': 3.4467455621301775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5604425', 'n_tokens_mistral': 913, 'n_tokens_neox': 889, 'n_words': 304}