Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gilda/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from gilda import __version__ as version
from gilda.grounder import GrounderInput, Grounder
from gilda.app.proxies import grounder
from gilda.ner import annotate

# NOTE: the Flask REST-X API has to be declared here, below the home endpoint
# otherwise it reserves the / base path.
Expand Down
88 changes: 52 additions & 36 deletions gilda/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,41 @@

{% block content %}
<div class="container" style="margin-top: 30px;">
<div class="col-md-offset-2 col-md-8 col-sm-offset-2 col-sm-8">
<div class="panel panel-info">
<div class="panel-heading">
<h2 style="margin-top: 10px; margin-bottom: 10px;">Gilda Grounding Service</h2>
</div>
<div class="panel-body">
<p>
The Gilda service (v{{ version }}) can be used to
identify identifiers for entity names.
</p>
<p> There are two usage modes: <b>Grounding</b> and <b>Annotation</b>. Grounding is also called
named entity normalization or linking and it assumes that the input is a span
of text corresponding to a named entity. Annotation is also called named
entity recognition and works with a longer span of text as input that may contain
any number of named entities in it.
</p>
<p>
For programmatic access, see the <a href="apidocs">API documentation</a>
and the <a href="https://github.com/gyorilab/gilda/blob/master/README.md">user guide</a>
for more information.
</p>
</div>
</div>
<ul class="nav nav-tabs">
<div class="col-md-offset-2 col-md-8 col-sm-offset-2 col-sm-8">
<div class="panel panel-info">
<div class="panel-heading">
<h2 style="margin-top: 10px; margin-bottom: 10px;">Gilda grounding
service</h2>
</div>
<div class="panel-body">
<p>
The Gilda service (v{{ version }}) can be used to
identify identifiers for entity names.
</p>
<p>
There are two usage modes: <b>grounding</b> (also called <i>named
entity normalization</i> or <i>linking</i>) and <b>annotation</b>
(also called <i>named entity recognition</i>).
</p>
<ul>
<li>In the <i>Grounding</i> mode, the input text is assumed to
correspond to a single named entity.
</li>
<li>In the <i>Annotation</i> mode, a longer span of text is used as
input which may contain any number of named entities in it.
</li>
</ul>
<p>
For programmatic access, see the <a href="apidocs">API
documentation</a>
and the <a
href="https://github.com/gyorilab/gilda/blob/master/README.md">user
guide</a>
for more information.
</p>
</div>
</div>
<ul class="nav nav-tabs">
{% set navigation_bar = [
('/', 'home', 'Grounding'),
('/ner', 'view_ner', 'Annotation')
Expand All @@ -55,17 +66,16 @@ <h2 style="margin-top: 10px; margin-bottom: 10px;">Gilda Grounding Service</h2>
{% endfor %}
</ul>
{% block gcontent %}{% endblock %}
<div class="well">
<p>
Gilda is developed by the <a href="https://gyorilab.github.io"
target="_blank">Gyori Lab for Computational Biomedicine</a>
at <a href="https://www.northeastern.edu" target="_blank">Northeastern University</a>.
Its development is funded by DARPA grants W911NF-15-1-0544,
W911NF-20-1-0255, and HR00112220036.
Point of contact: <a href="mailto:[email protected]">Benjamin M. Gyori</a>.
</p>
<div class="well">
<p>
Gilda is developed by the
<a href="https://gyorilab.github.io" target="_blank">Gyori Lab for Computational Biomedicine</a>
at <a href="https://www.northeastern.edu" target="_blank">Northeastern University</a>.
Its development is funded by DARPA grants HR00112220036. Point of contact:
<a href="mailto:[email protected]">Benjamin M. Gyori</a>.
</p>
</div>
</div>
</div>
</div>
{% endblock %}

Expand Down Expand Up @@ -110,7 +120,7 @@ <h4 class="modal-title">Species Prioritization</h4>
{% macro render_form(form) %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Gilda Grounding Input</h3>
<h3 class="panel-title">Gilda grounding input</h3>
</div>
<div class="panel-body">
<form class="form" method="POST" role="form">
Expand Down Expand Up @@ -155,7 +165,7 @@ <h4 class="modal-title">Context Text</h4>
{% macro render_ner_form(form) %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Gilda Annotation Input</h3>
<h3 class="panel-title">Gilda annotation input</h3>
</div>
<div class="panel-body">
<form class="form" method="POST" role="form">
Expand All @@ -166,5 +176,11 @@ <h3 class="panel-title">Gilda Annotation Input</h3>
</div>
</div>

<script>
function fillExample() {
document.getElementById('text').value = 'Small G proteins are an extensive family of proteins that bind and hydrolyze GTP. They are ubiquitous inside cells, regulating a wide range of cellular processes. Recently, many studies have examined the role of small G proteins, particularly the Ras family of G proteins, in memory formation. Once thought to be primarily involved in the transduction of a variety of extracellular signals during development, it is now clear that Ras family proteins also play critical roles in molecular processing underlying neuronal and behavioral plasticity. We here review a number of recent studies that explore how the signaling of Ras family proteins contributes to memory formation. Understanding these signaling processes is of fundamental importance both from a basic scientific perspective, with the goal of providing mechanistic insights into a critical aspect of cognitive behavior, and from a clinical perspective, with the goal of providing effective therapies for a range of disorders involving cognitive impairments.';
}
</script>

{{ render_species_modal() }}
{% endmacro %}
32 changes: 21 additions & 11 deletions gilda/app/templates/matches.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
{{ render_form(form) }}
{% endif %}

<div class="panel panel-default">
<div class="panel{% if matches %} panel-info{% else %} panel-warning{% endif %}">
<div class="panel-heading">
<h3 class="panel-title">Grounding Results for <code>{{ text }}</code></h3>
<h3 class="panel-title">
{% if matches %} Retrieved {% else %} No {% endif %}
grounding results for <span class="text-muted">{{ text }}</span>
</h3>
</div>
<div class="panel-body">
{% if context %}
Expand All @@ -16,45 +19,52 @@ <h3 class="panel-title">Grounding Results for <code>{{ text }}</code></h3>
</p>
{% endif %}
<p>
{% if matches %}
The table below contains the retrieved Groundings ordered by decreasing
score. The standard name for the entry is given in the Name column.
Additional groundings are provided for some entries where a match was
found to an equivalent term in a namespace different from the primary
grounding's.
{% else %}
No matches were found for the given input. Please try a different
entity text or modify the context or organism filters.
{% endif %}
</p>
</div>
{% if matches %}
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Grounding</th>
<th>Name</th>
<th>Score</th>
<th>Additional Groundings</th>
<th class="text-center">Grounding <i class="far fa-question-circle" title="The identifier the grounded term given as a compact URI (CURIE)."></i></th>
<th class="text-center">Name <i class="far fa-question-circle" title="The standardized name of the grounded term."></i></th>
<th class="text-center">Score <i class="far fa-question-circle" title="The score associated with the grounding match, used for ranking matches."></i></th>
<th class="text-center">Additional groundings <i class="far fa-question-circle" title="Identifiers equivalent to the one appearing under Grounding, formatted as compact URIs (CURIEs)."></i></th>
</tr>
</thead>
<tbody>
<tbody class="text-center">
{% for match in matches %}
<tr>
{% set match_curie = match.term.get_curie() %}
<td>
<a class="label label-primary" href="{{ match['url'] }}">
<a class="label label-primary" href="{{ match['url'] }}" target="_blank">
{{ match_curie }}
</a>
</a>&nbsp; <a href="{{ match['url'] }}" target="_blank"><i class="fa fa-external-link-alt"></i></a>
</td>
<td>{{ match['term']['entry_name'] }}</td>
<td class="text-right">{{ match['score'] | round(4) }}</td>
<td>
{% for xref_curie, xref_url in match.get_grounding_dict().items() %}
{% if xref_curie != match_curie %}
<a class="label label-info" href="{{ xref_url }}">
<a class="label label-info" href="{{ xref_url }}" target="_blank">
{{ xref_curie }}
</a>
</a>&nbsp; <a href="{{ xref_url }}" target="_blank"><i class="fa fa-external-link-alt"></i></a>
{% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% endblock %}
50 changes: 37 additions & 13 deletions gilda/app/templates/ner_matches.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,54 @@
{{ render_ner_form(form) }}
{% endif %}

<div class="panel panel-default">
<div class="panel{% if annotations %} panel-info{% else %} panel-warning{% endif %}">
<div class="panel-heading">
<div class="row">
<div class="col-md-6">
<h3 class="panel-title">Named Entity Recognition Results</h3>
<h3 class="panel-title">
{% if annotations %} Named Entity Recognition Results {% else %} No Results Found {% endif %}
</h3>
</div>
{% if annotations %}
<div class="col-md-6 text-right">
<button onclick="download_csv()" class="btn btn-primary">
<i class="fas fa-download"></i> Download CSV
</button>
</div>
{% endif %}
</div>
</div>
<div class="panel-body">
<blockquote>
{{ text | safe }}
</blockquote>
{% if not annotations %}
<p>No entities were recognized in the provided text. Please try a different
text or adjust the species priority list if used.</p>
{% endif %}
</div>
{% if annotations %}
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Span</th>
<th>Text</th>
<th>Grounding</th>
<th>Standard name</th>
<th>Score</th>
<th>Additional groundings</th>
<th class="text-nowrap">Span <i class="far fa-question-circle"
title="The start and end positions of the recognized entity in the text."></i>
</th>
<th class="text-nowrap">Text <i class="far fa-question-circle"
title="The recognized entity text."></i>
</th>
<th class="text-nowrap">Grounding <i class="far fa-question-circle"
title="The identifier of the grounded entity given as a compact URI (CURIE)."></i>
</th>
<th class="text-nowrap">Standard name <i class="far fa-question-circle"
title="The standardized name of the grounded entity."></i>
</th>
<th class="text-nowrap">Score <i class="far fa-question-circle"
title="The score of the grounding match used for ranking matches."></i>
</th>
<th class="text-nowrap">Additional groundings <i
class="far fa-question-circle"
title="Identifiers equivalent to the one appearing under Grounding, formatted as compact URIs (CURIEs)."></i></th>
</tr>
</thead>
<tbody>
Expand All @@ -49,27 +70,29 @@ <h3 class="panel-title">Named Entity Recognition Results</h3>
<td>{{ annotation['start'] }}-{{ annotation['end'] }}</td>
<td>{{ annotation['text'] }}</td>
<td>
<a class="label label-primary" href="{{ match['url'] }}">
<a class="label label-primary" href="{{ match['url'] }}" target="_blank">
{{ match_curie }}
</a>
</a>&nbsp; <a href="{{ match['url'] }}" target="_blank"><i class="fa fa-external-link-alt"></i></a>
</td>
<td>{{ match['term']['entry_name'] }}</td>
<td class="text-right">{{ match['score'] | round(4) }}</td>
<td class="text-right">{{ match['score'] | round(3) }}</td>
<td>
{% for xref_curie, xref_url in match.get_grounding_dict().items() %}
{% if xref_curie != match_curie %}
<a class="label label-info" href="{{ xref_url }}">
<a class="label label-info" href="{{ xref_url }}" target="_blank">
{{ xref_curie }}
</a>
</a>&nbsp; <a href="{{ xref_url }}" target="_blank"><i class="fa fa-external-link-alt"></i></a>
{% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>

{% if annotations %}
<script>
function download_csv() {
const csvData = `{{ csv_data | safe }}`;
Expand All @@ -84,4 +107,5 @@ <h3 class="panel-title">Named Entity Recognition Results</h3>
document.body.removeChild(a);
}
</script>
{% endif %}
{% endblock %}
18 changes: 13 additions & 5 deletions gilda/app/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GroundForm(FlaskForm):
text = StringField(
"Entity text",
validators=[DataRequired()],
description="Input the entity text (e.g., <code>k-ras</code>) to ground.",
description='Input the entity text (e.g., <span class="bg-info">k-ras</span>) to ground.',
)
context = TextAreaField(
"Context (optional)",
Expand Down Expand Up @@ -64,9 +64,16 @@ class NERForm(FlaskForm):
validators=[DataRequired()],
description=dedent(
"""\
Text from which to identify and ground named entities.
"""
<p>Enter text to annotate with named entities and corresponding identifiers.
The results will highlight recognized entities and provide
text position, grounding information and normalized name for each
entity.</p> <p>Click
<a href="#" onclick="fillExample(); return false;">here</a>
for an example input text from an
<a href="https://pubmed.ncbi.nlm.nih.gov/21040840/">article</a>
about small G-proteins."""
),
render_kw={"rows": 6},
)
organisms = ORGANISMS_FIELD
submit = SubmitField("Submit")
Expand Down Expand Up @@ -120,7 +127,7 @@ def view_ner():
writer = csv.writer(si)
writer.writerow([
"Start", "End", "Text", "Grounding", "Standard Name", "Score",
"Additional Groundings"
"Additional Groundings", "URL"
])

# Write data
Expand All @@ -139,7 +146,8 @@ def view_ner():
match_curie,
match.term.entry_name,
f"{match.score:.4f}",
additional_groundings
additional_groundings,
match.url
])

csv_data = si.getvalue()
Expand Down
8 changes: 8 additions & 0 deletions gilda/resources/ner_stoplist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,11 @@ white
wt
µM
µm
family
families
role
roles
review
reviews
goal
goals
Loading