# Path: indra/databases/hgnc_client.py
# def get_uniprot_id(hgnc_id):
# def get_entrez_id(hgnc_id):
# def get_hgnc_from_entrez(entrez_id):
# def get_ensembl_id(hgnc_id):
# def get_hgnc_from_ensembl(ensembl_id):
# def get_hgnc_name(hgnc_id):
# def get_hgnc_id(hgnc_name):
# def get_current_hgnc_id(hgnc_name):
# def get_hgnc_from_mouse(mgi_id):
# def get_hgnc_from_rat(rgd_id):
# def get_rat_id(hgnc_id):
# def get_mouse_id(hgnc_id):
# def get_hgnc_entry(hgnc_id):
# def get_gene_type(hgnc_id: str) -> Union[str, None]:
# def is_kinase(gene_name):
# def is_transcription_factor(gene_name):
# def is_phosphatase(gene_name):
# def get_enzymes(hgnc_id: str) -> Set[str]:
# def get_hgncs_from_enzyme(ec_code: str) -> Set[str]:
# def _read_hgnc_maps():
# def _read_kinases():
# def _read_phosphatases():
# def _read_tfs():
# 
# Path: indra/databases/chebi_client.py
# def _add_prefix(chid):
# def get_pubchem_id(chebi_id):
# def get_chebi_id_from_pubchem(pubchem_id):
# def get_chembl_id(chebi_id):
# def get_chebi_id_from_chembl(chembl_id):
# def get_chebi_id_from_cas(cas_id):
# def get_chebi_name_from_id(chebi_id, offline=True):
# def get_chebi_id_from_name(chebi_name):
# def get_chebi_entry_from_web(chebi_id):
# def _get_chebi_value_from_entry(entry, key):
# def get_chebi_name_from_id_web(chebi_id):
# def get_inchi_key(chebi_id):
# def get_primary_id(chebi_id):
# def get_specific_id(chebi_ids):
#     def isa_cmp(a, b):
# def get_chebi_id_from_hmdb(hmdb_id):
# def _read_chebi_to_pubchem():
# def _read_chebi_to_chembl():
# def _read_cas_to_chebi():
# def _read_hmdb_to_chebi():
# def _read_resource_csv(fname):


import json
import logging
from indra.statements import *
from indra.literature import id_lookup
from indra.databases import hgnc_client, uniprot_client, chebi_client, \
    go_client
    interaction['participant_b'] = get_participant(stmt.agent)
    card.card['interaction'] = interaction
    return card


def get_generic(entity_type='protein'):
    participant = {
        'entity_text': [''],
        'entity_type': entity_type,
        'identifier': 'GENERIC'
        }
    return participant


def get_participant(agent):
    # Handle missing Agent as generic protein
    if agent is None:
        return get_generic('protein')
    # The Agent is not missing
    text_name = agent.db_refs.get('TEXT')
    if text_name is None:
        text_name = agent.name
    participant = {}
    participant['entity_text'] = [text_name]
    hgnc_id = agent.db_refs.get('HGNC')
    uniprot_id = agent.db_refs.get('UP')
    chebi_id = agent.db_refs.get('CHEBI')
    pfam_def_ids = agent.db_refs.get('PFAM-DEF')
    # If HGNC grounding is available, that is the first choice
    if hgnc_id:

# Path: indra/databases/hgnc_client.py
# def get_uniprot_id(hgnc_id):
# def get_entrez_id(hgnc_id):
# def get_hgnc_from_entrez(entrez_id):
# def get_ensembl_id(hgnc_id):
# def get_hgnc_from_ensembl(ensembl_id):
# def get_hgnc_name(hgnc_id):
# def get_hgnc_id(hgnc_name):
# def get_current_hgnc_id(hgnc_name):
# def get_hgnc_from_mouse(mgi_id):
# def get_hgnc_from_rat(rgd_id):
# def get_rat_id(hgnc_id):
# def get_mouse_id(hgnc_id):
# def get_hgnc_entry(hgnc_id):
# def get_gene_type(hgnc_id: str) -> Union[str, None]:
# def is_kinase(gene_name):
# def is_transcription_factor(gene_name):
# def is_phosphatase(gene_name):
# def get_enzymes(hgnc_id: str) -> Set[str]:
# def get_hgncs_from_enzyme(ec_code: str) -> Set[str]:
# def _read_hgnc_maps():
# def _read_kinases():
# def _read_phosphatases():
# def _read_tfs():
# 
# Path: indra/databases/chebi_client.py
# def _add_prefix(chid):
# def get_pubchem_id(chebi_id):
# def get_chebi_id_from_pubchem(pubchem_id):
# def get_chembl_id(chebi_id):
# def get_chebi_id_from_chembl(chembl_id):
# def get_chebi_id_from_cas(cas_id):
# def get_chebi_name_from_id(chebi_id, offline=True):
# def get_chebi_id_from_name(chebi_name):
# def get_chebi_entry_from_web(chebi_id):
# def _get_chebi_value_from_entry(entry, key):
# def get_chebi_name_from_id_web(chebi_id):
# def get_inchi_key(chebi_id):
# def get_primary_id(chebi_id):
# def get_specific_id(chebi_ids):
#     def isa_cmp(a, b):
# def get_chebi_id_from_hmdb(hmdb_id):
# def _read_chebi_to_pubchem():
# def _read_chebi_to_chembl():
# def _read_cas_to_chebi():
# def _read_hmdb_to_chebi():
# def _read_resource_csv(fname):


# Path: indra/assemblers/index_card/assembler.py
import json
import logging
from indra.statements import *
from indra.literature import id_lookup
from indra.databases import hgnc_client, uniprot_client, chebi_client, \
    go_client

    interaction['participant_b'] = get_participant(stmt.agent)
    card.card['interaction'] = interaction
    return card


def get_generic(entity_type='protein'):
    participant = {
        'entity_text': [''],
        'entity_type': entity_type,
        'identifier': 'GENERIC'
        }
    return participant


def get_participant(agent):
    # Handle missing Agent as generic protein
    if agent is None:
        return get_generic('protein')
    # The Agent is not missing
    text_name = agent.db_refs.get('TEXT')
    if text_name is None:
        text_name = agent.name
    participant = {}
    participant['entity_text'] = [text_name]
    hgnc_id = agent.db_refs.get('HGNC')
    uniprot_id = agent.db_refs.get('UP')
    chebi_id = agent.db_refs.get('CHEBI')
    pfam_def_ids = agent.db_refs.get('PFAM-DEF')
    # If HGNC grounding is available, that is the first choice
    if hgnc_id:

        uniprot_id = hgnc_client.get_uniprot_id(hgnc_id)