<commit_before>from indra import bel
from indra import biopax


def get_bel_statistics(bp):
    if bp is None:
        return 0, 0
    num_all = len(bp.all_direct_stmts) - len(bp.degenerate_stmts)
    num_extracted = len(bp.converted_direct_stmts)
    return num_all, num_extracted

def get_biopax_statistics(bp):
    if bp is None:
        return 0, 0
    num_all, num_extracted = bp.get_coverage()
    return num_all, num_extracted

signaling = ['MAPK1', 'AKT1', 'JAK1', 'MAPK8', 'CTNNB1']
genereg = ['MYC', 'TP53', 'STAT3', 'FOXO3', 'JUN']
metabolism = ['IDH1', 'PFKL', 'DHFR', 'GLUL', 'NOS1']

#all_genes = signaling + genereg + metabolism
all_genes = metabolism
stats = {'bel': {}, 'biopax': {}}
for gene in all_genes:
    print('%s\n=========' % gene)
    belp = bel.process_ndex_neighborhood([gene])
    num_all, num_extracted = get_bel_statistics(belp)
    stats['bel'][gene] = (num_all, num_extracted)
    print(num_all, num_extracted)
    biopp = biopax.process_pc_neighborhood([gene])
    num_all, num_extracted = get_biopax_statistics(biopp)
    print(num_all, num_extracted)
    stats['biopax'][gene] = (num_all, num_extracted)<commit_msg>Print coverage stats table and fixes<commit_after>from indra import bel
from indra import biopax


def get_bel_statistics(bp):
    if bp is None:
        return 0, 0
    num_all = len(bp.all_direct_stmts) - len(bp.degenerate_stmts)
    num_extracted = len(bp.converted_direct_stmts)
    return num_all, num_extracted

def get_biopax_statistics(bp):
    if bp is None:
        return 0, 0
    num_all, num_extracted = bp.get_coverage()
    return num_all, num_extracted

def print_stats(stats):
    header = ['Gene', 'BPXtot', 'BPXext', 'BPX\%', 'BELtot', 'BELext', 'BEL\%']
    print(' & '.join(header) + '\\\\')
    for gene, gene_stats in stats.items():
        bpx_vals = ['%d' % gene_stats['biopax'][0],
                    '%d' % gene_stats['biopax'][1],
                    ('%.1f\\%%' % (100.0*gene_stats['biopax'][1] /
                                   gene_stats['biopax'][0])
                                 if gene_stats['biopax'][0] else 'N/A')]
        bel_vals = ['%d' % gene_stats['bel'][0],
                    '%d' % gene_stats['bel'][1],
                    ('%.1f\\%%' % (100.0*gene_stats['bel'][1] /
                                   gene_stats['bel'][0])
                                if gene_stats['bel'][0] else 'N/A')]
        print(' & '.join([gene] + bpx_vals + bel_vals) + '\\\\')

if __name__ == '__main__':
    signaling = ['MAPK1', 'AKT1', 'JAK1', 'GNAS', 'CTNNB1']
    genereg = ['MYC', 'TP53', 'STAT3', 'FOXO3', 'JUN']
    metabolism = ['IDH1', 'PFKL', 'DHFR', 'GLUL', 'NOS1']

    all_genes = signaling + genereg + metabolism
    stats = {g: {} for g in all_genes}
    for gene in all_genes:
        print('%s\n======' % gene)
        belp = bel.process_ndex_neighborhood([gene])
        num_all, num_extracted = get_bel_statistics(belp)
        stats[gene]['bel'] = (num_all, num_extracted)
        print(num_all, num_extracted)
        biopp = biopax.process_pc_neighborhood([gene])
        num_all, num_extracted = get_biopax_statistics(biopp)
        print(num_all, num_extracted)
        stats[gene]['biopax'] = (num_all, num_extracted)

    print_stats(stats)
{'fraction_non_alphanumeric': 0.1588325652841782, 'fraction_numerical': 0.015053763440860216, 'mean_word_length': 2.9323671497584543, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '239438', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1201, 'n_words': 240}