<commit_before>import requests
from dataclasses import dataclass
from utility.tools import GN3_LOCAL_URL


@dataclass
class CtlDatabase:
    """class for keeping track of ctl db data"""

    dataset: dict

    trait_db_list: list


def parse_geno_data(dataset_group_name) ->dict:
	"""function to parse geno file data"""
	genofile_location = locate(dataset.group.name + ".geno", "genotype")
	parser = genofile_parser.ConvertGenoFile(genofilelocation)

	parser.process_csv()

	# get marker and marker names

    markers = []
    markernames = []
    for marker in parser.markers:
        markernames.append(marker["name"])
        markers.append(marker["genotypes"])

    return {

    "genotypes":list(itertools.chain(*markers)),
    "markernames":markernames
    "individuals":parser.individuals,


    }





def parse_form_data(form_data: dict):
    """function to parse/validate form data
    input: dict containing required data
    output: dict with parsed data

    """

    trait_db_list = [trait.strip()
                          for trait in requestform['trait_list'].split(',')]
    form_data["trait_db_list"] = [x for x in  trait_db_list if x]

    form_data["nperm"] = int(form_data["nperm"])
    form_data["significance"] = float(int(form_data["significance"]))
    form_data["strategy"] = form_data["strategy"].capitalize()
<commit_msg>fetch pheno input data<commit_after>import requests
from dataclasses import dataclass

from utility import genofile_parser
from utility.tools import GN3_LOCAL_URL
from utility.tools import locate


from base.trait import create_trait
from base.trait import retrieve_sample_data


@dataclass
class CtlDatabase:
    """class for keeping track of ctl db data"""

    dataset: dict

    trait_db_list: list


def parse_geno_data(dataset_group_name) ->dict:
	"""function to parse geno file data"""
	genofile_location = locate(dataset.group.name + ".geno", "genotype")
	parser = genofile_parser.ConvertGenoFile(genofilelocation)

	parser.process_csv()

	# get marker and marker names

    markers = []
    markernames = []
    for marker in parser.markers:
        markernames.append(marker["name"])
        markers.append(marker["genotypes"])

    return {

    "genotypes":list(itertools.chain(*markers)),
    "markernames":markernames
    "individuals":parser.individuals,


    }


def parse_phenotype_data(trait_db_list):
	"""function to parse and generate phenodata"""

    traits = []
    for trait in trait_db_list:
        if trait != "":
            ts = trait.split(':')
            gt = create_trait(name=ts[0], dataset_name=ts[1])
            gt = retrieve_sample_data(gt, dataset, individuals)
            for ind in individuals:
                if ind in list(gt.data.keys()):
                    traits.append(gt.data[ind].value)
                else:
                    traits.append("-999")


    # missing inviduals 

    return {
    "trait_db_list":trait_db_list,
    "traits":traits
    }






def parse_form_data(form_data: dict):
    """function to parse/validate form data
    input: dict containing required data
    output: dict with parsed data

    """

    trait_db_list = [trait.strip()
                          for trait in requestform['trait_list'].split(',')]
    form_data["trait_db_list"] = [x for x in  trait_db_list if x]

    form_data["nperm"] = int(form_data["nperm"])
    form_data["significance"] = float(int(form_data["significance"]))
    form_data["strategy"] = form_data["strategy"].capitalize()

{'fraction_non_alphanumeric': 0.11260744985673353, 'fraction_numerical': 0.0020057306590257878, 'mean_word_length': 3.347447073474471, 'pattern_counts': {'":': 9, '<': 3, '<?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': '659201', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1077, 'n_words': 251}