示例#1
0
def get_observed_stmts(target_agent, observed_agent_forms, fold_change):
    stmts = []
    for obsf in observed_agent_forms:
        obs_agent = Agent(obsf.name, db_refs=obsf.db_refs)
        # If the agent has a modification then we make Modification
        # statements to check
        if obsf.mods:
            for mod in obsf.mods:
                # Create a Phosphorylation statement corresponding to
                # this drug/Ab pair
                if fold_change < 1:
                    stmt = Phosphorylation(target_agent, obs_agent,
                                           mod.residue, mod.position)
                else:
                    stmt = Dephosphorylation(target_agent, obs_agent,
                                             mod.residue, mod.position)
        # Otherwise the observed change is in protein amounts so we make
        # RegulateAmount statements
        else:
            if fold_change < 1:
                stmt = IncreaseAmount(target_agent, obs_agent)
            else:
                stmt = DecreaseAmount(target_agent, obs_agent)
        stmts.append(stmt)
    return stmts
示例#2
0
def test_find_contradicts():
    st1 = Inhibition(Agent('a'), Agent('b'))
    st2 = Activation(Agent('a'), Agent('b'))
    st3 = IncreaseAmount(Agent('a'), Agent('b'))
    st4 = DecreaseAmount(Agent('a'), Agent('b'))
    pa = Preassembler(hierarchies, [st1, st2, st3, st4])
    contradicts = pa.find_contradicts()
    assert len(contradicts) == 2
    for s1, s2 in contradicts:
        assert {s1.uuid, s2.uuid} in ({st1.uuid,
                                       st2.uuid}, {st3.uuid, st4.uuid})
示例#3
0
def test_find_contradicts():
    st1 = Inhibition(Agent('a'), Agent('b'))
    st2 = Activation(Agent('a'), Agent('b'))
    st3 = IncreaseAmount(Agent('a'), Agent('b'))
    st4 = DecreaseAmount(Agent('a'), Agent('b'))
    st5 = ActiveForm(
        Agent('a', mods=[ModCondition('phosphorylation', None, None, True)]),
        'kinase', True)
    st6 = ActiveForm(
        Agent('a', mods=[ModCondition('phosphorylation', None, None, True)]),
        'kinase', False)
    pa = Preassembler(hierarchies, [st1, st2, st3, st4, st5, st6])
    contradicts = pa.find_contradicts()
    assert len(contradicts) == 3
    for s1, s2 in contradicts:
        assert {s1.uuid,
                s2.uuid} in ({st1.uuid,
                              st2.uuid}, {st3.uuid,
                                          st4.uuid}, {st5.uuid, st6.uuid})
示例#4
0
    def process_increase_expression_amount(self):
        """Looks for Positive_Regulation events with a specified Cause
        and a Gene_Expression theme, and processes them into INDRA statements.
        """
        statements = []

        pwcs = self.find_event_parent_with_event_child('Positive_regulation',
                                                       'Gene_expression')
        for pair in pwcs:
            pos_reg = pair[0]
            expression = pair[1]

            cause = self.get_entity_text_for_relation(pos_reg, 'Cause')
            target = self.get_entity_text_for_relation(expression, 'Theme')

            if cause is not None and target is not None:
                theme_node = self.get_related_node(expression, 'Theme')
                assert (theme_node is not None)
                evidence = self.node_to_evidence(theme_node, is_direct=False)

                statements.append(
                    IncreaseAmount(s2a(cause), s2a(target), evidence=evidence))
        return statements
示例#5
0
def _get_db_with_pa_stmts():
    db = get_temp_db(clear=True)

    db_builder = DbBuilder(db)
    db_builder.add_text_refs([('12345', 'PMC54321'), ('24680', 'PMC08642'),
                              ('97531', ), ('87687', )])
    db_builder.add_text_content([['pubmed-ttl', 'pubmed-abs', 'pmc_oa'],
                                 ['pubmed-ttl', 'pubmed-abs', 'manuscripts'],
                                 ['pubmed-ttl', 'pubmed-abs', 'pmc_oa'],
                                 ['pubmed-ttl', 'pubmed-abs']])
    db_builder.add_readings([
        # Ref 1
        ['REACH', 'TRIPS'],  # pubmed ttl
        ['REACH', 'SPARSER'],  # pubmed abs
        ['REACH', 'ISI'],  # pmc_oa
        # Ref 2
        ['REACH', 'TRIPS'],  # pubmed ttl (new)
        ['SPARSER'],  # pubmed abs
        ['REACH', 'SPARSER'],  # manuscripts
        # Ref 3
        ['SPARSER', 'TRIPS', 'REACH'],  # pubmed ttl
        ['REACH', 'EIDOS', 'SPARSER'],  # pubmed abs
        ['SPARSER'],  # pmc oa (new)
        # Ref 4
        ['TRIPS', 'REACH', 'SPARSER'],  # pubmed ttl (new)
        ['REACH', 'SPARSER'],  # pubmed abs (new)
    ])

    db_builder.add_raw_reading_statements([
        # Ref 1
        # pubmed ttl
        [Phosphorylation(mek, erk)],  # reach
        [Phosphorylation(mek, erk, 'T', '124')],  # trips
        # pubmed abs
        [
            Phosphorylation(mek, erk),
            Inhibition(erk, ras), (Phosphorylation(mek, erk), 'in the body')
        ],  # reach
        [
            Complex([mek, erk]),
            Complex([erk, ras]), (Phosphorylation(None, erk), 'In the body')
        ],  # sparser
        # pmc OA
        [],  # reach
        [],  # ISI

        # Ref 2
        # pubmed ttl
        [Phosphorylation(map2k1, mapk1)],  # reach (new)
        [Phosphorylation(map2k1, mapk1, 'T', '124')],  # trips (new)
        # pubmed abs
        [Phosphorylation(map2k1, mapk1)],  # sparser
        # manuscript
        [],  # reach
        [],  # sparser

        # Ref 3
        # pubmed ttl
        [],  # sparser
        [Inhibition(simvastatin, raf)],  # TRIPS
        [],  # reach
        # pubmed abs
        [],  # reach
        [],  # eidos
        [Activation(map2k1_mg, erk),
         Inhibition(simvastatin_ng, raf)],  # sparser (new)
        # pmc oa
        [
            Inhibition(simvastatin_ng, raf),
            Inhibition(erk, ras),
            Activation(ras, raf)
        ],  # sparser (new)

        # Ref 4
        # pubmed ttl
        [],  # trips (new)
        [],  # reach (new)
        [],  # sparser (new)
        # pubmed abstract
        [
            Activation(kras, braf),
            Complex([map2k1, mapk1]),
            Complex([kras, braf])
        ],  # reach (new)
        [
            Complex([kras, braf]),
            Complex([mek, erk]),
            IncreaseAmount(kras, braf)
        ],  # sparser (new)
    ])
    db_builder.add_databases(['biopax', 'tas', 'bel'])
    db_builder.add_raw_database_statements([[
        Activation(mek, raf),
        Inhibition(erk, ras),
        Phosphorylation(mek, erk),
        Activation(ras, raf)
    ], [Inhibition(simvastatin, raf)], [Phosphorylation(mek, erk, 'T',
                                                        '124')]])
    db_builder.add_pa_statements([(Phosphorylation(mek, erk), [0, 2, 4,
                                                               25], [1, 8]),
                                  (Phosphorylation(mek, erk, 'T',
                                                   '124'), [1, 28]),
                                  (Phosphorylation(None, erk), [7], [0, 1, 8]),
                                  (Activation(mek, raf), [23]),
                                  (Inhibition(simvastatin, raf), [11, 27]),
                                  (Complex([mek, erk]), [5]),
                                  (Complex([erk, ras]), [6]),
                                  (Inhibition(erk, ras), [3, 24]),
                                  (Phosphorylation(map2k1, mapk1), [10])])

    # Add the preassembly update.
    pu = db.PreassemblyUpdates(corpus_init=True)
    db.session.add(pu)
    db.session.commit()

    return db