<commit_before>from snovault import (
    AuditFailure,
    audit_checker,
)
from .conditions import rfa


@audit_checker('antibody_lot', frame=[
    'targets',
    'characterizations',
    'characterizations.target'],
    condition=rfa('ENCODE3', 'modERN'))
def audit_antibody_missing_characterizations(value, system):
    '''
    Check to see what characterizations are lacking for each antibody,
    for the cell lines we know about.
    '''
    if value['targets'][0].get('investigated_as') in ['control']:
        return

    if not value['characterizations']:
        detail = '{} '.format(value['@id']) + \
            'does not have any supporting characterizations submitted.'
        yield AuditFailure('no characterizations submitted', detail,
                           level='NOT_COMPLIANT')
        return

    primary_chars = []
    secondary_chars = []
    num_compliant_primary = 0
    compliant_secondary = False
    for char in value['characterizations']:
        if 'primary_characterization_method' in char:
            primary_chars.append(char)
            if char['status'] in ['compliant', 'exempt from standards']:
                num_compliant_primary += 1
        if 'secondary_characterization_method' in char:
            secondary_chars.append(char)
            if char['status'] in ['compliant', 'exempt from standards']:
                compliant_secondary = True

    if not primary_chars:
        detail = '{} '.format(value['@id']) + \
            'does not have any primary characterizations submitted.'
        yield AuditFailure('no primary characterizations', detail,
                           level='NOT_COMPLIANT')

    if not secondary_chars:
        detail = '{} '.format(value['@id']) + \
            'does not have any secondary characterizations submitted.'
        yield AuditFailure('no secondary characterizations', detail,
                           level='NOT_COMPLIANT')

    if value['lot_reviews'][0]['detail'] in ['Characterizations not reviewed.']:
        detail = '{} has old characterizations that were not reviewed'.format(
            value['@id'])
        yield AuditFailure('characterizations not reviewed', detail, level='WARNING')

    for lot_review in value['lot_reviews']:
        if lot_review['detail'] in [
            'Pending review of primary characterization.',
            'Primary characterization(s) in progress.',
            'Pending review of primary and secondary characterizations.',
            'Pending review of primary and awaiting submission of secondary characterization(s).',
            'Awaiting compliant primary and secondary characterizations.',
            'Awaiting a compliant primary characterization.',
            'Characterizations in progress.'
        ]:
            detail = '{} needs a compliant primary in {}'.format(
                value['@id'],
                lot_review['biosample_term_name'])
            yield AuditFailure('need compliant primaries', detail,
                               level='NOT_COMPLIANT')

        if lot_review['detail'] is None and lot_review['status'] in ['awaiting lab characterization']:
            detail = '{} needs a compliant primary characterization for one or more cell types.'.format(
                value['@id'])
            yield AuditFailure('need compliant primaries', detail,
                               level='NOT_COMPLIANT')

    if secondary_chars and not compliant_secondary:
        detail = '{} '.format(value['@id']) + \
            'needs a compliant secondary characterization.'
        yield AuditFailure('need compliant secondary', detail,
                           level='NOT_COMPLIANT')
        return<commit_msg>Edit need primary char audit message<commit_after>from snovault import (
    AuditFailure,
    audit_checker,
)
from .conditions import rfa


@audit_checker('antibody_lot', frame=[
    'targets',
    'characterizations',
    'characterizations.target'],
    condition=rfa('ENCODE3', 'modERN'))
def audit_antibody_missing_characterizations(value, system):
    '''
    Check to see what characterizations are lacking for each antibody,
    for the cell lines we know about.
    '''
    if value['targets'][0].get('investigated_as') in ['control']:
        return

    if not value['characterizations']:
        detail = '{} '.format(value['@id']) + \
            'does not have any supporting characterizations submitted.'
        yield AuditFailure('no characterizations submitted', detail,
                           level='NOT_COMPLIANT')
        return

    primary_chars = []
    secondary_chars = []
    num_compliant_primary = 0
    compliant_secondary = False
    for char in value['characterizations']:
        if 'primary_characterization_method' in char:
            primary_chars.append(char)
            if char['status'] in ['compliant', 'exempt from standards']:
                num_compliant_primary += 1
        if 'secondary_characterization_method' in char:
            secondary_chars.append(char)
            if char['status'] in ['compliant', 'exempt from standards']:
                compliant_secondary = True

    if not primary_chars:
        detail = '{} '.format(value['@id']) + \
            'does not have any primary characterizations submitted.'
        yield AuditFailure('no primary characterizations', detail,
                           level='NOT_COMPLIANT')

    if not secondary_chars:
        detail = '{} '.format(value['@id']) + \
            'does not have any secondary characterizations submitted.'
        yield AuditFailure('no secondary characterizations', detail,
                           level='NOT_COMPLIANT')

    if value['lot_reviews'][0]['detail'] in ['Characterizations not reviewed.']:
        detail = '{} has old characterizations that were not reviewed.'.format(
            value['@id'])
        yield AuditFailure('characterizations not reviewed', detail, level='WARNING')

    for lot_review in value['lot_reviews']:
        if lot_review['detail'] in [
            'Pending review of primary characterization.',
            'Primary characterization(s) in progress.',
            'Pending review of primary and secondary characterizations.',
            'Pending review of primary and awaiting submission of secondary characterization(s).',
            'Awaiting compliant primary and secondary characterizations.',
            'Awaiting a compliant primary characterization.',
            'Characterizations in progress.'
        ]:
            biosample = lot_review['bioasmple_term_name']
            if biosample == 'not specified':
                biosample = 'one or more cell types/tissues.'

            detail = '{} needs a compliant primary in {}'.format(
                value['@id'],
                lot_review['biosample_term_name'])
            yield AuditFailure('need compliant primaries', detail,
                               level='NOT_COMPLIANT')

        if lot_review['detail'] is None and lot_review['status'] == 'awaiting lab characterization':
            detail = '{} needs a compliant primary characterization for one or more cell ' + \
                'types/tissues.'.format(value['@id'])
            yield AuditFailure('need compliant primaries', detail,
                               level='NOT_COMPLIANT')

    if secondary_chars and not compliant_secondary:
        detail = '{} '.format(value['@id']) + \
            'needs a compliant secondary characterization.'
        yield AuditFailure('need compliant secondary', detail,
                           level='NOT_COMPLIANT')
        return
{'fraction_non_alphanumeric': 0.10224274406332454, 'fraction_numerical': 0.0013192612137203166, 'mean_word_length': 2.4569083447332423, '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': '4918268', 'n_tokens_mistral': 1892, 'n_tokens_neox': 1823, 'n_words': 544}