<commit_before>"""module contains code to consume gn3-wgcna api
and process data to be rendered by datatables
"""


def fetch_trait_data(requestform):
    """fetch trait data"""
    db_obj = SimpleNamespace()
    get_trait_db_obs(db_obj,
                     [trait.strip()
                      for trait in requestform['trait_list'].split(',')])

    return process_dataset(db_obj.trait_list)
<commit_msg>add function to process trait sample data<commit_after>"""module contains code to consume gn3-wgcna api
and process data to be rendered by datatables
"""
from utility.helper_functions import get_trait_db_obs


def fetch_trait_data(requestform):
    """fetch trait data"""
    db_obj = SimpleNamespace()
    get_trait_db_obs(db_obj,
                     [trait.strip()
                      for trait in requestform['trait_list'].split(',')])

    return process_dataset(db_obj.trait_list)


def process_dataset(trait_list):
    """process datasets and strains"""

    input_data = {}
    traits = []
    strains = []

    # xtodo unique traits and strains

    for trait in trait_list:
        traits.append(trait[0].name)

        input_data[trait[0].name] = {}
        for strain in trait[0].data:
            strains.append(strain)
            input_data[trait[0].name][strain] = trait[0].data[strain].value

    return {
        "wgcna_input": input_data
    }

    def process_dataset(trait_list):
    """process datasets and strains"""

    input_data = {}
    traits = []
    strains = []

    # xtodo unique traits and strains

    for trait in trait_list:
        traits.append(trait[0].name)

        input_data[trait[0].name] = {}
        for strain in trait[0].data:
            strains.append(strain)
            input_data[trait[0].name][strain] = trait[0].data[strain].value

    return {
        "wgcna_input": input_data
    }

{'fraction_non_alphanumeric': 0.11183144246353323, 'fraction_numerical': 0.006482982171799027, 'mean_word_length': 2.6966067864271457, 'pattern_counts': {'":': 2, '<': 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': '4804743', 'n_tokens_mistral': 576, 'n_tokens_neox': 562, 'n_words': 130}