def make_html(stmts, fname):
    ha = HtmlAssembler(
        stmts,
        title='Small molecule inhibitors of %s assembled by INDRA' % target,
        db_rest_url='http://db.indra.bio/latest')
    ha.make_model()
    ha.save_model(fname)
Пример #2
0
def assemble_html(stmts_with_counts):
    for channel, (stmts, ev_counts, source_counts) in stmts_with_counts.items():
        ha = HtmlAssembler(stmts, ev_totals=ev_counts,
                           source_counts=source_counts,
                           title='INDRA statements for %s' % channel,
                           db_rest_url='https://db.indra.bio')
        ha.save_model('html/%s.html' % channel)
Пример #3
0
def html_assembler(indra_stmts, fname):
    """Assemble INDRA statements into a HTML report"""
    html_assembler = HtmlAssembler(indra_stmts,
                                   db_rest_url='https://db.indra.bio')
    assembled_html_report = html_assembler.make_model(no_redundancy=True)
    html_assembler.save_model(fname)
    return assembled_html_report
Пример #4
0
def make_html(stmts, ev_counts, source_counts, fname, drug):
    ha = HtmlAssembler(stmts,
                       ev_totals=ev_counts,
                       source_counts=source_counts,
                       title='Effects of %s assembled by INDRA' % drug,
                       db_rest_url='http://db.indra.bio/latest')
    ha.make_model()
    ha.save_model(fname)
Пример #5
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
Пример #6
0
from indra.tools import assemble_corpus as ac
from indra.statements import stmts_to_json_file
from indra.assemblers.html import HtmlAssembler
from indra.sources import reach
tp = reach.process_pmc('PMC4455820', url=reach.local_nxml_url)
if tp:
    stmts = tp.statements
    print(stmts)
    stmts = ac.filter_grounded_only(stmts)  # Filter out ungrounded agents
    stmts = ac.run_preassembly(
        stmts,  # Run preassembly
        return_toplevel=False,
        normalize_equivalences=
        True,  # Optional: rewrite equivalent groundings to one standard
        normalize_opposites=
        True,  # Optional: rewrite opposite groundings to one standard
        normalize_ns='WM'
    )  # Use 'WM' namespace to normalize equivalences and opposites
    stmts = ac.filter_belief(stmts, 0.8)  # Apply belief cutoff of e.g., 0.8
    stmts_to_json_file(stmts, 'PMC4455820.json')
    ha = HtmlAssembler(stmts)
    ha.save_model('PMC4455820.html')

#
#
#
#
Пример #7
0
#attempt to combine many statements

from indra.tools import assemble_corpus as ac
from indra.statements import stmts_to_json_file
from indra.assemblers.html import HtmlAssembler
from indra.sources import reach

pmcids = ["PMC3717945", "PMC5906628"]
stmts = []

for pmcid in pmcids:
    tp = reach.process_pmc(pmcid)
    stmts += tp.statements

stmts = ac.filter_grounded_only(stmts)  # Filter out ungrounded agents
stmts = ac.run_preassembly(
    stmts,  # Run preassembly
    return_toplevel=False,
    normalize_equivalences=
    True,  # Optional: rewrite equivalent groundings to one standard
    normalize_opposites=
    True,  # Optional: rewrite opposite groundings to one standard
    normalize_ns='WM'
)  # Use 'WM' namespace to normalize equivalences and opposites
stmts = ac.filter_belief(stmts, 0.8)  # Apply belief cutoff of e.g., 0.8
stmts_to_json_file(stmts, 'bigresults.json')
ha = HtmlAssembler(stmts)
ha.save_model('bigresults.html')
def assemble_html(stmts, fname_key):
    ha = HtmlAssembler(stmts)
    ha.make_model()
    ha.save_model('%s.html' % fname_key)