<commit_before>from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
from indra.statements import *
from indra.assemblers.cyjs import CyJSAssembler

mek = Agent('MAP2K1', db_refs={'HGNC': '6840'})
erk = Agent('MAPK1', db_refs={'UP': 'P28482'})
dusp = Agent('DUSP4')
st_phos = Phosphorylation(mek, erk)
st_phos_Y = Phosphorylation(mek, erk, residue='Y')
st_phos_T = Phosphorylation(mek, erk, residue='T')
st_dephos = Dephosphorylation(dusp, erk)
st_complex = Complex([mek, erk, dusp])
st_act = Activation(mek, erk)
st_gef = Gef(Agent('SOS1'), Agent('HRAS'))
st_gap = Gap(Agent('RASA1'), Agent('HRAS'))
st_incamount = IncreaseAmount(Agent('TP53'), Agent('MDM2'))
st_decamount = DecreaseAmount(Agent('MDM2'), Agent('TP53'))
st_act2 = Inhibition(dusp, erk)
st_cited = Phosphorylation(mek, erk, evidence=Evidence(pmid='12345',
                                              text='MEK phosphorylates ERK'))
st_cited2 = Phosphorylation(mek, erk, evidence=Evidence(pmid='api35',
                                              text='MEK phosphorylates ERK'))
st_selfmod = Autophosphorylation(Agent('AKT1'), 'S', '473')

def test_act():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
    assert 'negative' in polarities
    db_refs = [node['data']['db_refs'] for node in cja._nodes]
    for node in cja._nodes:
        if node['data']['name'] == 'MAP2K1':
            assert node['data']['db_refs'].get('HGNC')
        if node['data']['name'] == 'MAPK1':
            assert node['data']['db_refs'].get('UniProt')
        if node['data']['name'] == 'DUSP4':
            assert not node['data']['db_refs']

def test_regamount():
    cja = CyJSAssembler()
    cja.add_statements([st_incamount, st_decamount])
    cja.make_model()
    assert len(cja._nodes) == 2
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
    assert 'negative' in polarities

def test_ras():
    cja = CyJSAssembler()
    cja.add_statements([st_gef, st_gap])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities<commit_msg>Add a simple test for text db_refs<commit_after>from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
from indra.statements import *
from indra.assemblers.cyjs import CyJSAssembler

mek = Agent('MAP2K1', db_refs={'HGNC': '6840', 'TEXT': 'mek1'})
erk = Agent('MAPK1', db_refs={'UP': 'P28482'})
dusp = Agent('DUSP4')
st_phos = Phosphorylation(mek, erk)
st_phos_Y = Phosphorylation(mek, erk, residue='Y')
st_phos_T = Phosphorylation(mek, erk, residue='T')
st_dephos = Dephosphorylation(dusp, erk)
st_complex = Complex([mek, erk, dusp])
st_act = Activation(mek, erk)
st_gef = Gef(Agent('SOS1'), Agent('HRAS'))
st_gap = Gap(Agent('RASA1'), Agent('HRAS'))
st_incamount = IncreaseAmount(Agent('TP53'), Agent('MDM2'))
st_decamount = DecreaseAmount(Agent('MDM2'), Agent('TP53'))
st_act2 = Inhibition(dusp, erk)
st_cited = Phosphorylation(mek, erk, evidence=Evidence(pmid='12345',
                                              text='MEK phosphorylates ERK'))
st_cited2 = Phosphorylation(mek, erk, evidence=Evidence(pmid='api35',
                                              text='MEK phosphorylates ERK'))
st_selfmod = Autophosphorylation(Agent('AKT1'), 'S', '473')

def test_act():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
    assert 'negative' in polarities
    db_refs = [node['data']['db_refs'] for node in cja._nodes]
    for node, refs in zip(cja._nodes, db_refs):
        if node['data']['name'] == 'MAP2K1':
            assert refs.get('HGNC') == \
                'http://identifiers.org/hgnc/HGNC:6840', refs
            assert refs.get('TEXT') == 'mek1', refs
        if node['data']['name'] == 'MAPK1':
            assert refs.get('UniProt')
        if node['data']['name'] == 'DUSP4':
            assert not refs

def test_regamount():
    cja = CyJSAssembler()
    cja.add_statements([st_incamount, st_decamount])
    cja.make_model()
    assert len(cja._nodes) == 2
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
    assert 'negative' in polarities

def test_ras():
    cja = CyJSAssembler()
    cja.add_statements([st_gef, st_gap])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
{'fraction_non_alphanumeric': 0.15374357020384835, 'fraction_numerical': 0.01943227281386931, 'mean_word_length': 3.847645429362881, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3203626', 'n_tokens_mistral': 1969, 'n_tokens_neox': 1823, 'n_words': 397}