<commit_before>from indra.databases import chebi_client
from indra.ontology.standardize import standardize_db_refs


minerva_to_indra_map = {
    'UNIPROT': 'UP',
    'REFSEQ': 'REFSEQ_PROT',
    'ENTREZ': 'EGID',
    'INTERPRO': 'IP',
}


def fix_id_standards(db_ns, db_id):
    if db_ns == 'CHEBI':
        if not db_id.startswith('CHEBI:'):
            db_id = f'CHEBI:{db_id}'
        db_id = chebi_client.get_primary_id(db_id)
    elif db_ns == 'HGNC' and db_id.startswith('HGNC:'):
        db_id = db_id[5:]
    return db_ns, db_id


def indra_db_refs_from_minerva_refs(refs):
    db_refs = {}
    for db_ns, db_id in refs:
        db_ns = minerva_to_indra_map[db_ns] \
            if db_ns in minerva_to_indra_map else db_ns
        db_nbs, db_id = fix_id_standards(db_ns, db_id)
        db_refs[db_ns] = db_id
    db_refs = standardize_db_refs(db_refs)
    return db_refs
<commit_msg>Extend minerva_to_indra_map<commit_after>from indra.databases import chebi_client
from indra.ontology.standardize import standardize_db_refs


minerva_to_indra_map = {
    'UNIPROT': 'UP',
    'REFSEQ': 'REFSEQ_PROT',
    'ENTREZ': 'EGID',
    'INTERPRO': 'IP',
    'MESH_2012': 'MESH',
}


def fix_id_standards(db_ns, db_id):
    if db_ns == 'CHEBI':
        if not db_id.startswith('CHEBI:'):
            db_id = f'CHEBI:{db_id}'
        db_id = chebi_client.get_primary_id(db_id)
    elif db_ns == 'HGNC' and db_id.startswith('HGNC:'):
        db_id = db_id[5:]
    return db_ns, db_id


def indra_db_refs_from_minerva_refs(refs):
    db_refs = {}
    for db_ns, db_id in refs:
        db_ns = minerva_to_indra_map[db_ns] \
            if db_ns in minerva_to_indra_map else db_ns
        db_nbs, db_id = fix_id_standards(db_ns, db_id)
        db_refs[db_ns] = db_id
    db_refs = standardize_db_refs(db_refs)
    return db_refs

{'fraction_non_alphanumeric': 0.11080636313768513, 'fraction_numerical': 0.0032912781130005485, 'mean_word_length': 3.2616822429906542, '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': '4210268', 'n_tokens_mistral': 813, 'n_tokens_neox': 763, 'n_words': 135}