<commit_before>"""Assigns FDR to proteins from qvality"""
from app.actions.pycolator import reassign as pyreassign
from app.dataformats import prottable as prottabledata


def assign_protein_fdr(qvalityfn, proteins, headerfields, scorefield):
    qvalityout = pyreassign.parse_qvality_output(qvalityfn)
    fdrheader = headerfields['proteinfdr'][prottabledata.HEADER_QVAL][None]
    pepheader = headerfields['proteinpep'][prottabledata.HEADER_PEP][None]
    for protein in proteins:
        outprotein = {k: v for k, v in protein.items()}
        score = float(outprotein[scorefield])
        qval, pep, warning = pyreassign.lookup_statistic(score, qvalityout)
        outprotein.update({fdrheader: qval, pepheader: pep})<commit_msg>Qvality rounds at 5 decimals so make sure we also do that or we will interpolate almost every value instead of looking it up<commit_after>"""Assigns FDR to proteins from qvality"""
from app.actions.pycolator import reassign as pyreassign
from app.dataformats import prottable as prottabledata


def assign_protein_fdr(qvalityfn, proteins, headerfields, scorefield):
    qvalityout = pyreassign.parse_qvality_output(qvalityfn)
    fdrheader = headerfields['proteinfdr'][prottabledata.HEADER_QVAL][None]
    pepheader = headerfields['proteinpep'][prottabledata.HEADER_PEP][None]
    for protein in proteins:
        outprotein = {k: v for k, v in protein.items()}
        score = round(float(outprotein[scorefield]), 5)
        qval, pep, warning = pyreassign.lookup_statistic(score, qvalityout)
        outprotein.update({fdrheader: qval, pepheader: pep})
{'fraction_non_alphanumeric': 0.09136735979836169, 'fraction_numerical': 0.001260239445494644, 'mean_word_length': 5.178988326848249, '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': '6511566', 'n_tokens_mistral': 520, 'n_tokens_neox': 501, 'n_words': 127}