# Path: indra/ontology/standardize.py
# def get_standard_agent(name, db_refs, ontology=None, ns_order=None, **kwargs):
#     """Get a standard agent based on the name, db_refs, and a any other kwargs.
# 
#     name : str
#         The name of the agent that may not be standardized.
#     db_refs : dict
#         A dict of db refs that may not be standardized, i.e., may be
#         missing an available UP ID corresponding to an existing HGNC ID.
#     ontology : Optional[indra.ontology.IndraOntology]
#         An IndraOntology object, if not provided, the default BioOntology
#         is used.
#     ns_order : Optional[list]
#         A list of namespaces which are in order of priority with higher
#         priority namespaces appearing earlier in the list.
#     kwargs :
#         Keyword arguments to pass to :func:`Agent.__init__`.
# 
#     Returns
#     -------
#     Agent
#         A standard agent
#     """
#     standard_name, db_refs = standardize_name_db_refs(db_refs,
#                                                       ontology=ontology,
#                                                       ns_order=ns_order)
#     if standard_name:
#         name = standard_name
#     assert_valid_db_refs(db_refs)
#     return Agent(name, db_refs=db_refs, **kwargs)


from indra.statements import *
from indra.ontology.standardize import get_standard_agent


class UbiBrowserProcessor:
    """Processor for UbiBrowser data."""
    def __init__(self, e3_df, dub_df):
        self.e3_df = e3_df
        self.dub_df = dub_df
        self.statements = []

    def extract_statements(self):
        for df, stmt_type in [(self.e3_df, Ubiquitination),
                              (self.dub_df, Deubiquitination)]:
            for _, row in df.iterrows():
                stmt = self._process_row(row, stmt_type)
                if stmt:
                    self.statements.append(stmt)

    @staticmethod
    def _process_row(row, stmt_type):
        # Note that even in the DUB table the subject of the statement
        # is called "E3"
        # There are some examples where a complex is implied (e.g., BMI1-RNF2),
        # for simplicity we just ignore these
        if '-' in row['E3AC']:
            return None
        subj_agent = get_standard_agent(row['E3GENE'], {'UP': row['E3AC']})

# Path: indra/ontology/standardize.py
# def get_standard_agent(name, db_refs, ontology=None, ns_order=None, **kwargs):
#     """Get a standard agent based on the name, db_refs, and a any other kwargs.
# 
#     name : str
#         The name of the agent that may not be standardized.
#     db_refs : dict
#         A dict of db refs that may not be standardized, i.e., may be
#         missing an available UP ID corresponding to an existing HGNC ID.
#     ontology : Optional[indra.ontology.IndraOntology]
#         An IndraOntology object, if not provided, the default BioOntology
#         is used.
#     ns_order : Optional[list]
#         A list of namespaces which are in order of priority with higher
#         priority namespaces appearing earlier in the list.
#     kwargs :
#         Keyword arguments to pass to :func:`Agent.__init__`.
# 
#     Returns
#     -------
#     Agent
#         A standard agent
#     """
#     standard_name, db_refs = standardize_name_db_refs(db_refs,
#                                                       ontology=ontology,
#                                                       ns_order=ns_order)
#     if standard_name:
#         name = standard_name
#     assert_valid_db_refs(db_refs)
#     return Agent(name, db_refs=db_refs, **kwargs)


# Path: indra/sources/ubibrowser/processor.py
from indra.statements import *
from indra.ontology.standardize import get_standard_agent



class UbiBrowserProcessor:
    """Processor for UbiBrowser data."""
    def __init__(self, e3_df, dub_df):
        self.e3_df = e3_df
        self.dub_df = dub_df
        self.statements = []

    def extract_statements(self):
        for df, stmt_type in [(self.e3_df, Ubiquitination),
                              (self.dub_df, Deubiquitination)]:
            for _, row in df.iterrows():
                stmt = self._process_row(row, stmt_type)
                if stmt:
                    self.statements.append(stmt)

    @staticmethod
    def _process_row(row, stmt_type):
        # Note that even in the DUB table the subject of the statement
        # is called "E3"
        # There are some examples where a complex is implied (e.g., BMI1-RNF2),
        # for simplicity we just ignore these
        if '-' in row['E3AC']:
            return None
        subj_agent = get_standard_agent(row['E3GENE'], {'UP': row['E3AC']})

        obj_agent = get_standard_agent(row['SUBGENE'], {'UP': row['SUBAC']})