<commit_before>from snovault import (
    AuditFailure,
    audit_checker,
)
from .conditions import rfa
from .ontology_data import biosampleType_ontologyPrefix
from .gtex_data import gtexDonorsList
import datetime

targetBasedAssayList = [
    'ChIP-seq',
    'RNA Bind-n-Seq',
    'ChIA-PET',
    'RIP Array',
    'RIP-seq',
    'MeDIP-seq',
    'iCLIP',
    'eCLIP',
    'shRNA knockdown followed by RNA-seq',
    ]

controlRequiredAssayList = [
    'ChIP-seq',
    'RNA Bind-n-Seq',
    'RIP-seq',
    'RAMPAGE',
    'CAGE',
    'single cell isolation followed by RNA-seq',
    'shRNA knockdown followed by RNA-seq'
    ]

seq_assays = [
    'RNA-seq',
    'ChIP-seq',
    'RNA Bind-n-Seq',
    'MeDIP-seq',
    'RNA-PET',
    'DNA-PET',
    'ChIA-PET',
    'CAGE',
    'RAMPAGE',
    'RIP-seq',
    ]

non_seq_assays = [
    'RNA profiling by array assay',
    'DNA methylation profiling by array assay',
    'Genotype',
    'comparative genomic hybridization by array',
    'RIP-chip',
    'protein sequencing by tandem mass spectrometry assay',
    'microRNA profiling by array assay',
    'Switchgear',
    '5C',
    ]


@audit_checker('Experiment', frame=['original_files',
                                    'replicates',
                                    'replicates.library',
                                    'replicates.library.biosample',
                                    'replicates.library.biosample.donor',
                                    'replicates.library.biosample.donor.organism',
                                    'original_files.quality_metrics',
                                    'original_files.derived_from'],
               condition=rfa('ENCODE3'))
def audit_experiement_rampage_encode3_standards(value, system):
    '''
    This is an attempt to pool into a dispatch function standard audits
    allowing easier maintanance and lower duplication of code and some level
    of separation between audits and standards - which are related but are
    not the same.

    - Experiments required to have at least 2 bio reps
    >>> audit_experiment_replicated()

    - Read depth for each replicate is 25M uniquely mapped reads
    - Read length is at least 50 BP --> DONE
    - Gene level quantification Spearman >0.9, 0.8 for isogenic, anisogenic
    - Control of RAMPAGE is corrsponding RNA-seq experiment
    ???
    - Only paired end sequencing would allow pipeline processing --> DONE
    - Sequencing platform Illumina GA, HiSeq --> DONE
    
    - Spike-ins indicated (barcodes - impossible to check)
    >>> audit_experiment_spikein

    - Mapping to GRCh38 or mm10
    - Gene quantifications are using gencode V4 or M4
    '''

    
    if value['status'] not in ['released', 'release ready']:
        return
    if 'assay_term_name' not in value or value['assay_term_name'] != 'RAMPAGE':
        return
    if 'original_files' not in value or len(value['original_files']) == 0:
        return
    if 'replicates' not in value:
        return


    num_bio_reps = set()
    for rep in value['replicates']:
        num_bio_reps.add(rep['biological_replicate_number'])<commit_msg>fixed bug not dealing with missing replication_type<commit_after>from snovault import (
    AuditFailure,
    audit_checker,
)
from .conditions import rfa
from .ontology_data import biosampleType_ontologyPrefix
from .gtex_data import gtexDonorsList
import datetime

targetBasedAssayList = [
    'ChIP-seq',
    'RNA Bind-n-Seq',
    'ChIA-PET',
    'RIP Array',
    'RIP-seq',
    'MeDIP-seq',
    'iCLIP',
    'eCLIP',
    'shRNA knockdown followed by RNA-seq',
    ]

controlRequiredAssayList = [
    'ChIP-seq',
    'RNA Bind-n-Seq',
    'RIP-seq',
    'RAMPAGE',
    'CAGE',
    'single cell isolation followed by RNA-seq',
    'shRNA knockdown followed by RNA-seq'
    ]

seq_assays = [
    'RNA-seq',
    'ChIP-seq',
    'RNA Bind-n-Seq',
    'MeDIP-seq',
    'RNA-PET',
    'DNA-PET',
    'ChIA-PET',
    'CAGE',
    'RAMPAGE',
    'RIP-seq',
    ]

non_seq_assays = [
    'RNA profiling by array assay',
    'DNA methylation profiling by array assay',
    'Genotype',
    'comparative genomic hybridization by array',
    'RIP-chip',
    'protein sequencing by tandem mass spectrometry assay',
    'microRNA profiling by array assay',
    'Switchgear',
    '5C',
    ]


@audit_checker('Experiment', frame=['original_files',
                                    'replicates',
                                    'replicates.library',
                                    'replicates.library.biosample',
                                    'replicates.library.biosample.donor',
                                    'replicates.library.biosample.donor.organism',
                                    'original_files.quality_metrics',
                                    'original_files.derived_from'],
               condition=rfa('ENCODE3'))
def audit_experiement_rampage_encode3_standards(value, system):
    '''
    This is an attempt to pool into a dispatch function standard audits
    allowing easier maintanance and lower duplication of code and some level
    of separation between audits and standards - which are related but are
    not the same.

    - Experiments required to have at least 2 bio reps
    >>> audit_experiment_replicated()

    - Read depth for each replicate is 25M uniquely mapped reads
    - Read length is at least 50 BP --> DONE
    - Gene level quantification Spearman >0.9, 0.8 for isogenic, anisogenic
    - Control of RAMPAGE is corrsponding RNA-seq experiment
    ???
    - Only paired end sequencing would allow pipeline processing --> DONE
    - Sequencing platform Illumina GA, HiSeq --> DONE
    
    - Spike-ins indicated (barcodes - impossible to check)
    >>> audit_experiment_spikein

    - Mapping to GRCh38 or mm10
    - Gene quantifications are using gencode V4 or M4
    '''
    if 'replication_type' not in value:
        return
    
    if value['status'] not in ['released', 'release ready']:
        return
    if 'assay_term_name' not in value or value['assay_term_name'] != 'RAMPAGE':
        return
    if 'original_files' not in value or len(value['original_files']) == 0:
        return
    if 'replicates' not in value:
        return


    num_bio_reps = set()
    for rep in value['replicates']:
        num_bio_reps.add(rep['biological_replicate_number'])
{'fraction_non_alphanumeric': 0.09622047244094488, 'fraction_numerical': 0.005984251968503937, 'mean_word_length': 2.277089783281734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4489383', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1876, 'n_words': 543}