<jupyter_start><jupyter_text>e(BE:L) RESTful API client Summary:This notebooks demonstrates the potential of the e(BE:L) RESTful API client. This client allows to query a database storing BEL and and eBEL statement. Statistics gives a general overview on the database. Import Note!For this notebook to function properly, you must have graphviz installed. For more information, visit https://graphviz.gitlab.io/download/<jupyter_code>from ebel_rest import connect, query, statistics
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Example DatabaseTo demonstrate how one can use this package to obtain information from a given database, we will use the COVID-19 Knowledge Graph available at http://graphstore.scai.fraunhofer.de/.<jupyter_code># Database settings
server = "https://graphstore.scai.fraunhofer.de"
password = '<PASSWORD>'
user = 'covid_user'
db_name = "covid"
print_url = True

# Connect to database
connect(user, password, server, db_name, print_url)<jupyter_output><empty_output><jupyter_text>Statistics DisplayAll statistics can be shown as1. table (pandas.DataFrame)3. _data (python object)<jupyter_code>s = statistics.publication_by_year()<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_publication_by_year/<jupyter_text>As a pandas DataFrame:<jupyter_code>s.table[:20]<jupyter_output><empty_output><jupyter_text>As a python dictionary:<jupyter_code>s.data<jupyter_output><empty_output><jupyter_text>Use pandas to visualize ebel_rest tables  Because tables in `ebel_rest` are pandas tables, all [pandas visualization](https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html) options are available. Here are 2 examples:<jupyter_code>_=s.table.set_index('publication_year').plot.bar(figsize=(20,5))
_=s.table[1:20].set_index('publication_year').plot.pie(y='number_of_publications', figsize=(7, 7),legend=None)<jupyter_output><empty_output><jupyter_text>Methods To keep it simple on the first row for all statistic methods are shown.  Total Number of Curated Publications<jupyter_code>statistics.total_publications().data[0]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_total_publications/<jupyter_text>Total Number of Curated BEL Statements<jupyter_code>statistics.total_bel_edges().data[0]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_total_stmts/<jupyter_text>Total Number of BEL Nodes from Curated Statements<jupyter_code>statistics.total_bel_nodes().data[0]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_total_bel_nodes/<jupyter_text>Publications by year<jupyter_code>statistics.publication_by_year().table[:2]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_publication_by_year/<jupyter_text>Publication by number of statements<jupyter_code>statistics.publication_by_number_of_statements().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_publication_by_number_of_statements/<jupyter_text>Last author by number of publications<jupyter_code>statistics.last_author_by_number_of_publications().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_last_author_by_number_of_publications/<jupyter_text>Author by number of statements<jupyter_code>statistics.last_author_by_number_of_statements().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_last_author_by_number_of_statements/<jupyter_text>Node namespace ordered by count<jupyter_code>statistics.node_namespace_order_by_count().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_node_namespace_order_by_count/<jupyter_text>Node namespace ordered by namespace<jupyter_code>statistics.node_namespace_order_by_namespace().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_node_namespace_order_by_namespace/<jupyter_text>Edge classes<jupyter_code>statistics.edges().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_edges/<jupyter_text>Node classes<jupyter_code>statistics.nodes().table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_nodes/<jupyter_text>GraphsAll graph data can be retrieved as1. edges (python object => list of dictionaries)2. table (pandas.DataFrame)2. table_all_columns (pandas.DataFrame)See below the graph view possibilities.  Graph queries<jupyter_code>query.annotation('MeSHAnatomy', 'Lysosomes').edges[0]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_by_annotation/MeSHAnatomy/Lysosomes<jupyter_text>Ouery by last author<jupyter_code>query.last_author('<NAME>').table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_by_last_author/Denison%20MR///<jupyter_text>Query by PubMed identifier<jupyter_code>query.pmid(32129518).table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_by_pmid/32129518<jupyter_text>Causal & correlative relations by gene symbol<jupyter_code>query.causal_correlative_by_gene('ACE2').table[:1]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_causal_correlative_by_gene/ACE2<jupyter_text>All causal paths from gene 1 to gene 2 with causal relations<jupyter_code>query.path(source='FURIN',target='COVID-19',min_edges=1,max_edges=2).table[:3]<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_path/FURIN/COVID-19/1-2<jupyter_text>BELish<jupyter_code>query.belish('p(HGNC:"IFNB1") ? ?').table<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/belish_helper/p%28HGNC%3A%22IFNB1%22%29%20%3F%20%3F<jupyter_text>Graph display<jupyter_code>g = query.pmid(32129518)<jupyter_output>https://graphstore.scai.fraunhofer.de/function/covid/bel_by_pmid/32129518<jupyter_text>Table<jupyter_code>g.table[:5]<jupyter_output><empty_output><jupyter_text>Table (comprehensive)<jupyter_code>g.table_all_columns[:4]<jupyter_output><empty_output><jupyter_text>BEL graph (simplified)<jupyter_code>g.as_graph()<jupyter_output><empty_output><jupyter_text>BEL graph (simplified with edge IDs)<jupyter_code>g.as_graph_with_ids()<jupyter_output><empty_output><jupyter_text>BEL graph (with node labels as BEL)<jupyter_code>g.as_graph_bel()<jupyter_output><empty_output><jupyter_text>BEL graph (with node labels as BEL and edge IDs)<jupyter_code>g.as_graph_bel_with_ids()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11413708690330478, 'fraction_numerical': 0.0151468788249694, 'mean_word_length': 10.529100529100528, 'pattern_counts': {'":': 0, '<': 104, '<?xml version=': 0, '>': 105, 'https://': 22, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '30', 'dir': 'jupyter-structured-clean-dedup', 'id': '302461', 'license': 'MIT', 'n_tokens_mistral': 2468, 'n_tokens_neox': 2357, 'n_words': 276, 'path': 'notebooks/Examples.ipynb', 'repo_name': 'e-BE-L/ebel_rest', 'size': '6535'}