Beispiel #1
0
def test_get_string():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    graph_str = ga.get_string()
    assert(graph_str)
Beispiel #2
0
def test_phosphorylation():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert(len(ga.graph.nodes()) == 2)
    assert(len(ga.graph.edges()) == 1)
Beispiel #3
0
def test_complex():
    st = [Complex([Agent('BRAF'), Agent('RAF1'), Agent('YWAH')])]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert(len(ga.graph.nodes()) == 3)
    assert(len(ga.graph.edges()) == 3)
Beispiel #4
0
def test_dephosphorylation_noenz():
    st = [Dephosphorylation(None, Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert(len(ga.graph.nodes()) == 0)
    assert(len(ga.graph.edges()) == 0)
Beispiel #5
0
def test_inactivation():
    st = [Inhibition(Agent('DUSP4'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert(len(ga.graph.nodes()) == 2)
    assert(len(ga.graph.edges()) == 1)
def test_get_string():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    graph_str = ga.get_string()
    assert (graph_str)
def test_phosphorylation():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert (len(ga.graph.nodes()) == 2)
    assert (len(ga.graph.edges()) == 1)
def test_complex():
    st = [Complex([Agent('BRAF'), Agent('RAF1'), Agent('YWAH')])]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert (len(ga.graph.nodes()) == 3)
    assert (len(ga.graph.edges()) == 3)
def test_inactivation():
    st = [Inhibition(Agent('DUSP4'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert (len(ga.graph.nodes()) == 2)
    assert (len(ga.graph.edges()) == 1)
Beispiel #10
0
def test_dephosphorylation_noenz():
    st = [Dephosphorylation(None, Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    assert (len(ga.graph.nodes()) == 0)
    assert (len(ga.graph.edges()) == 0)
Beispiel #11
0
def format_stmts(stmts, output_format):
    if output_format == 'tsv':
        msg = ''
        for stmt in stmts:
            if not stmt.evidence:
                logger.warning('Statement %s without evidence' % stmt.uuid)
                txt = ''
                pmid = ''
            else:
                txt = stmt.evidence[0].text if stmt.evidence[0].text else ''
                pmid = stmt.evidence[0].pmid if stmt.evidence[0].pmid else ''
            line = '%s\t%s\t%s\n' % (stmt, txt, pmid)
            msg += line
        return msg
    elif output_format == 'pkl':
        fname = 'indrabot.pkl'
        with open(fname, 'wb') as fh:
            pickle.dump(stmts, fh)
        return fname
    elif output_format == 'pdf':
        fname = 'indrabot.pdf'
        ga = GraphAssembler(stmts)
        ga.make_model()
        ga.save_pdf(fname)
        return fname
    elif output_format == 'json':
        msg = json.dumps(stmts_to_json(stmts), indent=1)
        return msg
    return None
Beispiel #12
0
def draw_graph(stmts, fname):
    graphpr = {'rankdir': 'TD'}
    nodepr = {'fontsize': 12, 'shape': 'plaintext', 'margin': '0,0', 'pad': 0}
    ga = GraphAssembler(stmts,
                        graph_properties=graphpr,
                        node_properties=nodepr)
    ga.make_model()
    ga.save_dot('%s.dot' % fname)
    ga.save_pdf('%s.pdf' % fname)
Beispiel #13
0
def assemble_graph():
    """Assemble INDRA Statements and return Graphviz graph dot string."""
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    stmts_json = body.get('statements')
    stmts = stmts_from_json(stmts_json)
    ga = GraphAssembler(stmts)
    model_str = ga.make_model()
    res = {'model': model_str}
    return res
Beispiel #14
0
def test_save_pdf():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    ga.save_pdf('/dev/null')
Beispiel #15
0
def test_save_pdf():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    ga.save_pdf('/dev/null')
Beispiel #16
0
import sys
import pickle
from indra import reach
from indra.assemblers import GraphAssembler

txt = open('extension.txt', 'rt').read()
rp = reach.process_text(txt, offline=True)
st = rp.statements
for s in st:
    print '%s\t%s' % (s, s.evidence[0].text)

with open('extension.pkl', 'wb') as fh:
    pickle.dump(st, fh)

graphpr = {'rankdir': 'TD'}
nodepr = {'fontsize': 12, 'shape': 'plaintext', 'margin': '0,0', 'pad': 0}
ga = GraphAssembler(st, graph_properties=graphpr, node_properties=nodepr)
ga.make_model()
ga.save_dot('jnk_extension.dot')
ga.save_pdf('jnk_extension.pdf')