From 330be799d6806b1480fb6f96245c9a1a07662d02 Mon Sep 17 00:00:00 2001 From: Olawumi Olasunkanmi Date: Thu, 26 Sep 2024 12:33:03 -0400 Subject: [PATCH] Added more templated quieries --- app.py | 54 +++++++++++++++++++++----------------------- assets/styles.css | 3 ++- requirements.txt | 2 +- src/edgar_ui.py | 26 ++++++++++++++++----- src/visualization.py | 22 ++++++++++++++---- 5 files changed, 67 insertions(+), 40 deletions(-) diff --git a/app.py b/app.py index 4dad3fb..4f536ca 100644 --- a/app.py +++ b/app.py @@ -18,15 +18,8 @@ ) server = app.server - - -robokop_link = html.A( - id = "robokop-link", - children=html.Img(src='/assets/robokop.png',style={'height':'2em','width':'6em','padding-left':'1em'}), - href='https://robokop.renci.org/', - target='_blank', - rel='noopener noreferrer') - +app.title = 'EDGAR' +app._favicon = 'Logo.ico' colors = {'background': 'white', 'background': '#7794B8', 'dropdown': '#6c6f73', 'text': '#000000'} @@ -108,25 +101,30 @@ def resolvename(name): ), html.Br(), html.Div([ - html.Div( - html.Article([ - "This research explores pathway enrichment strategies in biomedical Knowledge Graphs (KGs) as a versatile link-prediction approach, with drug repurposing exemplifying a significant application. Leveraging systems biology, network expression analysis, pathway analysis (PA), and machine learning (ML) methods, KGs aid in uncovering novel interactions among biomedical entities of interest. ", - html.P(), - "While these approaches excel in inferring missing edges within the KG, PA may overlook candidates with similar pathway effects. ", - html.P(), - "By utilizing enrichment-driven analyses on KG data from ROBOKOP, our EDGAR paper applied this method on Alzheimer's disease case study, demonstrating the efficacy of enrichment strategies in linking entities for drug repurposing. Our approach is validated through literature-based evidence derived from clinical trials, showcasing the potential of enrichment-driven strategies in linking biomedical entities." - ], - style={'font-size': '20px'} - ) - ), - html.Br(), - html.Div( - robokop_link + html.Div( + html.Article([ + "Leveraging systems biology, network expression analysis, pathway analysis (PA), rule learning and machine learning (ML) methods, KGs aid in uncovering novel interactions among biomedical entities of interest. ", + "While these approaches excel in inferring missing edges within the KG, they may overlook candidates with similar pathway effects. ", + html.P(), + "This research explores pathway enrichment strategies in biomedical Knowledge Graphs (KGs) as a versatile link-prediction approach, with drug repurposing exemplifying a significant application in the paper. ", + html.P(), + "By utilizing enrichment-driven analyses on KG data from ", + html.A( + "ROBOKOP", + href='https://robokop.renci.org/', + target='_blank', + rel='noopener noreferrer', + style={'color': 'blue', 'text-decoration': 'underline'} + ), + ", our EDGAR paper demonstrates the efficacy of enrichment strategies in linking entities for drug repurposing. Our approach is validated through literature-based evidence derived from clinical trials, showcasing the potential of enrichment-driven strategies in linking biomedical entities." + ], + style={'font-size': '20px'} ) - - ], - style={'background-color': 'whitesmoke', 'display': 'flex', 'flex-direction': 'row', - 'align-items': 'center', 'justify-content': 'center'} + ), + html.Br(), + ], + style={'background-color': 'whitesmoke', 'display': 'flex', 'flex-direction': 'row', + 'align-items': 'center', 'justify-content': 'center'} ), ], className="p-3 bg-body-secondary rounded-3") @@ -242,4 +240,4 @@ def normalizeterm(searchterm, click): #### Visualize the Output ###### if __name__ == "__main__": - app.run_server(debug=False) + app.run_server(debug=True) diff --git a/assets/styles.css b/assets/styles.css index 0172afb..9eb1e29 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -3,7 +3,8 @@ @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@900&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Oswald:wght@900&display=swap'); - + + body { margin: 0; diff --git a/requirements.txt b/requirements.txt index 8d11f00..b59953d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,6 +19,6 @@ PyYAML==6.0.1 requests==2.32.3 setuptools==71.0.4 urllib3==2.2.2 -aiohttp==3.10.1 +aiohttp~=3.10.1 gunicorn diff --git a/src/edgar_ui.py b/src/edgar_ui.py index a991753..db9b504 100644 --- a/src/edgar_ui.py +++ b/src/edgar_ui.py @@ -21,7 +21,7 @@ request_in_progress = False response_status = 0 tk = bmt.Toolkit() -AC_URL = "https://answercoalesce-test.apps.renci.org/query" +AC_URL = "https://answercoalesce.renci.org/query" all_node_classes = tk.get_all_classes('entity') @@ -166,12 +166,16 @@ def send_post_request(data): dcc.Dropdown( id="example-query-dropdown", options=[ - {'label': "What Drugs treats Disease Y?", + {'label': "What Drugs treats Disease Y eg. MONDO:0004975?", 'value': "biolink:Drug-biolink:treats-biolink:Disease"}, - {'label': "What Genes is associated with Disease X?", - 'value': "biolink:Gene-biolink:associated_with-biolink:Disease"}, - {'label': "What are the Biological Process and Molecular Activities that affects Genes X?", - 'value': "biolink:BioProcessOrActivity-biolink:affects-biolink:Gene"} + {'label': "What Genes are genetically associated with Disease X eg. DOID:0050430?", + 'value': "biolink:Gene-biolink:genetically_associated_with-biolink:Disease"}, + {'label': "What are the Phenotypes of Disease X eg. MONDO:0005147?", + 'value': "biolink:Disease-biolink:has_phenotype-biolink:PhenotypicFeature"}, + {'label': "What are the Genes that affects Phenotype X eg. HP:0003637?", + 'value': "biolink:Gene-biolink:affects-biolink:PhenotypicFeature"}, + {'label': "What are the Phenotypes of Gene X eg. NCBIGene:122481?", + 'value': "biolink:Gene-biolink:has_phenotype-biolink:PhenotypicFeature"} ], value=None, placeholder='Select an example query pattern...optional', @@ -409,3 +413,13 @@ def visualize_data(store_data, visualize_nclicks): return vizlayout(store_data) return "" + +@callback( + Output('output-data', 'children', allow_duplicate=True), + [Input('example-query-dropdown', 'value'), + Input('source_dropdown', 'value'), + Input('predicate_dropdown', 'value'), + Input('target_dropdown', 'value')] +) +def update_output(selected_query, source_value, predicate_value, target_value): + return f'Selected Query: {selected_query}, Source: {source_value}, Predicate: {predicate_value}, Target: {target_value}' diff --git a/src/visualization.py b/src/visualization.py index e83a0b4..f49cd76 100644 --- a/src/visualization.py +++ b/src/visualization.py @@ -205,6 +205,10 @@ def pickgroup2curieedge(enrichment2group_edge, group2curie_edge, kg_nodes, kg_ed terminals = [group2curie_edge['subject'], group2curie_edge['object']] finaledges = [] pvalues = set() + + # print('enrichment2group_edge', enrichment2group_edge) + # print() + # print('group2curie_edge', group2curie_edge) for attributes in enrichment2group_edge["attributes"]: # ususally one enrichment2group_support_graphs = attributes["value"] # Each of these exists in the auxiliary graph @@ -229,10 +233,20 @@ def pickgroup2curieedge(enrichment2group_edge, group2curie_edge, kg_nodes, kg_ed finaledge = [kg_nodes[object_]["name"], group2curie_edge["predicate"], kg_nodes[next_element]["name"]] elif object_ in terminals: - next_element = terminals[ - terminals.index(object_) + 1] if object_ in terminals and terminals.index( - object_) + 1 < len( - object_) else None + try: + next_element = terminals[ + terminals.index(object_) + 1] if object_ in terminals and terminals.index( + object_) + 1 < len( + object_) else None + except: + next_element = terminals[ + terminals.index(object_)] if object_ in terminals and terminals.index( + object_) + 1 < len(object_) else None + + # next_element = terminals[ + # terminals.index(object_) + 1] if object_ in terminals and terminals.index( + # object_) + 1 < len( + # object_) else None finaledge = [group2curie_edge["predicate"], kg_nodes[next_element]["name"]] finaledges.append(theedge + finaledge) return pvalues, finaledges