Example #1
0
 def get_pdf_graph(self):
     """Save a graph made with GraphAssembler as pdf, return file name."""
     fname = 'indrabot.pdf'
     ga = GraphAssembler(self.get_statements())
     ga.make_model()
     ga.save_pdf(fname)
     return fname
Example #2
0
 def get_pdf_graph(self):
     """Save a graph made with GraphAssembler as pdf, return file name."""
     fname = 'indrabot.pdf'
     ga = GraphAssembler(self.get_statements())
     ga.make_model()
     ga.save_pdf(fname)
     return fname
Example #3
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)
Example #4
0
 def report_paths_graph(self, paths_list):
     from indra.assemblers.graph import GraphAssembler
     from indra.util import flatten
     path_stmts = [stmts_from_json(l) for l in paths_list]
     all_stmts = flatten(path_stmts)
     ga = GraphAssembler(all_stmts)
     ga.make_model()
     resource = get_img_path('qca_paths.png')
     ga.save_pdf(resource)
     content = KQMLList('display-image')
     content.set('type', 'simulation')
     content.sets('path', resource)
     self.tell(content)
Example #5
0
 def report_paths_graph(self, paths_list):
     from indra.assemblers.graph import GraphAssembler
     from indra.util import flatten
     path_stmts = [stmts_from_json(l) for l in paths_list]
     all_stmts = flatten(path_stmts)
     ga = GraphAssembler(all_stmts)
     ga.make_model()
     resource = get_img_path('qca_paths.png')
     ga.save_pdf(resource)
     content = KQMLList('display-image')
     content.set('type', 'simulation')
     content.sets('path', resource)
     self.tell(content)
Example #6
0
def format_stmts(stmts, output_format, ev_counts=None, source_counts=None):
    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 = '"%s"' % stmt.evidence[0].text if \
                    stmt.evidence[0].text else ''
                pmid = stmt.evidence[0].pmid if stmt.evidence[0].pmid else ''
            try:
                ea_txt = EnglishAssembler([stmt]).make_model()
            except Exception as e:
                ea_txt = ''
                logger.error('English assembly failed for %s' % stmt)
                logger.error(e)
            line = '%s\t%s\t%s\tPMID%s\n' % (stmt, ea_txt, 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
    elif output_format == 'html':
        ev_counts = {} if not ev_counts else ev_counts
        ha = HtmlAssembler(stmts, ev_totals=ev_counts,
                           source_counts=source_counts)
        fname = 'indrabot.html'
        ha.save_model(fname)
        return fname
    return None
def test_save_pdf():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    ga.save_pdf('/dev/null')
def test_save_pdf():
    st = [Phosphorylation(Agent('MAP2K1'), Agent('MAPK1'))]
    ga = GraphAssembler()
    ga.add_statements(st)
    ga.make_model()
    ga.save_pdf('/dev/null')