<jupyter_start><jupyter_text>TutorialQuick tutorial on how to use the COVID-19 Knowledge Graph.<jupyter_code># If you don't have it installed already, install the ebel_rest package
# !pip install ebel_rest
import os
import sys
import time

import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
from ebel_rest import connect, query, statistics
%config InlineBackend.figure_formats = ['svg']
%matplotlib inline
matplotlib.style.use('seaborn')<jupyter_output><empty_output><jupyter_text>Notebook Provenance<jupyter_code>sys.version
time.asctime()<jupyter_output><empty_output><jupyter_text>Set Graphstore Configuration and Connect<jupyter_code>server = "http://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>Content Summary A summary of the types of nodes and edges present in the COVID-19 Knowledge Graph.<jupyter_code>statistics.summarize().table<jupyter_output>http://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_summarize/<jupyter_text>Explore provenance informationThe pubmid identifiers for the articles selected for the contruction of the COVID-19 Knowledge Graph.**Note that there are numerous preprints that will not be taken into account since we only consider papers indexed in PubMed for this analysis.**<jupyter_code>pubmed_identifiers = query.list_pmids()
pubmed_identifiers<jupyter_output><empty_output><jupyter_text>Summary of Nodes and Edges in the Knowledge Graph<jupyter_code>fig, axes = plt.subplots(1, 2)
lax = axes[0]
rax = axes[1]

ntc = statistics.nodes().table.set_index('node_class').sort_values(by='number_of_nodes', axis=0, ascending=True)
etc = statistics.edges().table.set_index('edge_class').sort_values(by='number_of_edges', axis=0, ascending=True)

ntc.plot(kind='barh', ax=lax, legend=None)
lax.set_xlabel("Number of Nodes")
lax.set_ylabel("")
lax.set_title('Total BEL Nodes: {}'.format(statistics.total_bel_nodes().data[0]['number_of_bel_nodes']))

etc.plot(kind='barh', ax=rax, legend=None)
rax.set_xlabel("Number of Edges")
rax.set_ylabel("")
rax.set_title('Total BEL Relations: {}'.format(statistics.total_bel_edges().data[0]['number_of_stmts']))

plt.tight_layout()

# Export
# plt.savefig("nodes_edges_summary.svg")<jupyter_output>http://graphstore.scai.fraunhofer.de/function/covid/_bel_statistics_nodes/
http://graphstore.scai.fraunhofer.de/function/covid/_bel_statistics_edges/
http://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_total_bel_nodes/
http://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_total_stmts/<jupyter_text>Summary of Namespaces Used<jupyter_code>nsp = statistics.namespace_by_count().table.set_index('namespace').plot.bar(figsize=(10,5), rot=45)
nsp.set_xlabel("Namespace")

for container in nsp.containers:
    plt.setp(container, width=0.8)
    
plt.tight_layout()

# # Export
plt.savefig("namespace_summary.svg")<jupyter_output>http://graphstore.scai.fraunhofer.de/function/covid/bel_statistics_namespace_count/
{'fraction_non_alphanumeric': 0.12006420545746388, 'fraction_numerical': 0.006741573033707865, 'mean_word_length': 7.954022988505747, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '548531', 'license': 'Apache-2.0', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1077, 'n_words': 198, 'path': 'notebooks/tutorial.ipynb', 'repo_name': 'ziranl16/Analysis', 'size': '3110'}