Ejemplo n.º 1
0
def test_process_increase_amount():
    # Test extraction of IncreaseAmount statements from a text description
    # of a substance increasing the expression of some gene.

    s = 'BRAF increases the expression of p53.'

    tp = api.process_text(s)
    statements = tp.statements

    # Exactly one statement should have been extracted from the provided text
    assert len(statements) == 1
    statement0 = statements[0]

    # The statement should be of type IncreaseAmount
    assert isinstance(statement0, IncreaseAmount)

    # The subject and object in the statement should correspond with what is
    # in the text
    subj0 = statement0.subj.db_refs['TEXT']
    assert subj0 == 'BRAF'
    #
    obj0 = statement0.obj.db_refs['TEXT']
    assert obj0 == 'p53'

    # There should be an evidence object (properties of evidence tested in
    # other tests)
    assert len(statements[0].evidence) == 1
Ejemplo n.º 2
0
def test_process_bind():
    # Test extracting of Complex statement from a text description of
    # substances binding to each other.

    s = 'BRAF binds to p53.'
    tp = api.process_text(s)
    statements = tp.statements

    # There should be exactly one statement extracted
    assert len(statements) == 1
    statement0 = statements[0]

    # The statement should be of type Complex
    assert isinstance(statement0, Complex)

    # The members of the complex should correspond to the two substances
    # mentioned in the text
    members = statement0.members
    members = [m.db_refs['TEXT'] for m in members]
    assert len(members) == 2
    assert 'BRAF' in members
    assert 'p53' in members

    # is_direct should be true in evidence for bind statement
    assert len(statement0.evidence) == 1
    assert statement0.evidence[0].epistemics['direct']
Ejemplo n.º 3
0
def test_evidence_text():
    # Test the ability of the processor to extract which sentence in particular
    # lead to the creation of the INDRA statement, amongst a corpus of text
    # not related to the statement's mechanism.

    # Corpus containing exactly one biological mechanism
    corpus = """Why did the cows return to the marijuana field? It was the pot
    calling the cattle back. Why do cows have hooves instead of feet? Because
    they lactose. When making non-dairy butter, there is little margarine for
    error. Ras leads to the phosphorylation of Raf. Do ghost cows say "moo" or
    "boo"? The surprising fact is they say "moo", but with a rising vibrato
    tone instead of an elongated one."""

    # Process the corpus
    tp = api.process_text(corpus)
    statements = tp.statements

    # Only one of the sentences was related to a biological mechanism
    assert len(statements) == 1
    statement0 = statements[0]

    # Make sure it got the right sentence
    text = statement0.evidence[0].text
    print('Statement text:"', text + '"')
    assert text == 'Ras leads to the phosphorylation of Raf.'
Ejemplo n.º 4
0
def test_process_increase_amount():
    # Test extraction of IncreaseAmount statements from a text description
    # of a substance increasing the expression of some gene.

    s = 'BRAF increases the expression of p53.'

    tp = api.process_text(s)
    statements = tp.statements

    # Exactly one statement should have been extracted from the provided text
    assert len(statements) == 1
    statement0 = statements[0]

    # The statement should be of type IncreaseAmount
    assert isinstance(statement0, IncreaseAmount)

    # The subject and object in the statement should correspond with what is
    # in the text
    subj0 = statement0.subj.db_refs['TEXT']
    assert subj0 == 'BRAF'
    #
    obj0 = statement0.obj.db_refs['TEXT']
    assert obj0 == 'p53'

    # There should be an evidence object (properties of evidence tested in
    # other tests)
    assert len(statements[0].evidence) == 1
Ejemplo n.º 5
0
def test_evidence_text():
    # Test the ability of the processor to extract which sentence in particular
    # lead to the creation of the INDRA statement, amongst a corpus of text
    # not related to the statement's mechanism.

    # Corpus containing exactly one biological mechanism
    corpus = """Why did the cows return to the marijuana field? It was the pot
    calling the cattle back. Why do cows have hooves instead of feet? Because
    they lactose. When making non-dairy butter, there is little margarine for
    error. Ras leads to the phosphorylation of Raf. Do ghost cows say "moo" or
    "boo"? The surprising fact is they say "moo", but with a rising vibrato
    tone instead of an elongated one."""

    # Process the corpus
    tp = api.process_text(corpus)
    statements = tp.statements

    # Only one of the sentences was related to a biological mechanism
    assert len(statements) == 1
    statement0 = statements[0]

    # Make sure it got the right sentence
    text = statement0.evidence[0].text
    print('Statement text:"', text + '"')
    assert text == 'Ras leads to the phosphorylation of Raf.'
Ejemplo n.º 6
0
def test_process_bind():
    # Test extracting of Complex statement from a text description of
    # substances binding to each other.

    s = 'BRAF binds to p53.'
    tp = api.process_text(s)
    statements = tp.statements

    # There should be exactly one statement extracted
    assert len(statements) == 1
    statement0 = statements[0]

    # The statement should be of type Complex
    assert isinstance(statement0, Complex)

    # The members of the complex should correspond to the two substances
    # mentioned in the text
    members = statement0.members
    members = [m.db_refs['TEXT'] for m in members]
    assert len(members) == 2
    assert 'BRAF' in members
    assert 'p53' in members

    # is_direct should be true in evidence for bind statement
    assert len(statement0.evidence) == 1
    assert statement0.evidence[0].epistemics['direct']
Ejemplo n.º 7
0
def test_evidence_pmid():
    # Test whether the pmid provided to the TEES processor is put into the
    # statement's evidence

    pmid = '42'

    # Process some text
    s = 'BRAF binds to p53.'
    tp = api.process_text(s, pmid)
    statements = tp.statements

    # Verify that the pmid was put in the right place
    assert len(statements[0].evidence) == 1
    assert statements[0].evidence[0].pmid == pmid
Ejemplo n.º 8
0
def test_evidence_pmid():
    # Test whether the pmid provided to the TEES processor is put into the
    # statement's evidence

    pmid = '42'

    # Process some text
    s = 'BRAF binds to p53.'
    tp = api.process_text(s, pmid)
    statements = tp.statements

    # Verify that the pmid was put in the right place
    assert len(statements[0].evidence) == 1
    assert statements[0].evidence[0].pmid == pmid
Ejemplo n.º 9
0
def test_process_dephosphorylation():
    # Test the extraction of a dephosphorylation sentence. This sentence is
    # processed into two INDRA statements, at least one of which is correct.

    # Text statement describing phosphorylation
    s = 'Here we show that febuxostat suppresses LPS-induced MCP-1 ' + \
            'production and mRNA expression via activating ' + \
            'MAPK phosphatase-1 (MKP-1) which, in turn, leads to ' + \
            'dephosphorylation and inactivation of JNK in macrophages.'
    tp = api.process_text(s)
    statements = tp.statements

    # We'll set this to true if at least one of the extracted statements meets
    # our criteria for correctness
    some_statement_correct = False

    # Extracting this particular sentence with TEES produces a couple
    # statements, at least one of which is correct
    for statement in statements:
        statement_correct = False
        enz = statement.enz.db_refs['TEXT']
        sub = statement.sub.db_refs['TEXT']

        # Does this statement have the entities named in the text?
        entities_correct = enz == 'MAPK phosphatase-1' and sub == 'JNK'

        # Is the statement a phosphorylation statement?
        type_correct = isinstance(statement, Dephosphorylation)

        # There should be an evidence object (properties of evidence tested in
        # other tests)
        assert len(statements[0].evidence) == 1

        # If yes to both, the correct statement was among those extracted
        statement_correct = type_correct and entities_correct
        some_statement_correct = statement_correct or some_statement_correct

    assert some_statement_correct
Ejemplo n.º 10
0
def test_process_dephosphorylation():
    # Test the extraction of a dephosphorylation sentence. This sentence is
    # processed into two INDRA statements, at least one of which is correct.

    # Text statement describing phosphorylation
    s = 'Here we show that febuxostat suppresses LPS-induced MCP-1 ' + \
            'production and mRNA expression via activating ' + \
            'MAPK phosphatase-1 (MKP-1) which, in turn, leads to ' + \
            'dephosphorylation and inactivation of JNK in macrophages.'
    tp = api.process_text(s)
    statements = tp.statements

    # We'll set this to true if at least one of the extracted statements meets
    # our criteria for correctness
    some_statement_correct = False

    # Extracting this particular sentence with TEES produces a couple
    # statements, at least one of which is correct
    for statement in statements:
        statement_correct = False
        enz = statement.enz.db_refs['TEXT']
        sub = statement.sub.db_refs['TEXT']

        # Does this statement have the entities named in the text?
        entities_correct = enz == 'MAPK phosphatase-1' and sub == 'JNK'

        # Is the statement a phosphorylation statement?
        type_correct = isinstance(statement, Dephosphorylation)

        # There should be an evidence object (properties of evidence tested in
        # other tests)
        assert len(statements[0].evidence) == 1

        # If yes to both, the correct statement was among those extracted
        statement_correct = type_correct and entities_correct
        some_statement_correct = statement_correct or some_statement_correct

    assert some_statement_correct
Ejemplo n.º 11
0
def test_process_phosphorylation():
    # Test the extraction of phosphorylation with a simple example.
    s = 'Ras leads to the phosphorylation of Braf.'
    tp = api.process_text(s)
    statements = tp.statements

    # Should only extract one statement
    assert len(statements) == 1

    # The statement should be a Phosphorylation statement
    statement = statements[0]
    assert isinstance(statement, Phosphorylation)

    # Check that the enzyme and substrate of the statement match the text
    enz = statement.enz
    assert enz.db_refs['TEXT'] == 'Ras'
    #
    sub = statement.sub
    assert sub.db_refs['TEXT'] == 'Braf'

    # There should be an evidence object (properties of evidence tested in
    # other tests)
    assert len(statements[0].evidence) == 1
Ejemplo n.º 12
0
def test_process_phosphorylation():
    # Test the extraction of phosphorylation with a simple example.
    s = 'Ras leads to the phosphorylation of Braf.'
    tp = api.process_text(s)
    statements = tp.statements

    # Should only extract one statement
    assert len(statements) == 1

    # The statement should be a Phosphorylation statement
    statement = statements[0]
    assert isinstance(statement, Phosphorylation)

    # Check that the enzyme and substrate of the statement match the text
    enz = statement.enz
    assert enz.db_refs['TEXT'] == 'Ras'
    #
    sub = statement.sub
    assert sub.db_refs['TEXT'] == 'Braf'

    # There should be an evidence object (properties of evidence tested in
    # other tests)
    assert len(statements[0].evidence) == 1