import pkg_resources
import sys
import os
import time
from urllib.request import urlretrieve

import indra.util.get_version
import indra.java_vm # make sure INDRA is in charge of the JVM
import pybel
import pybel_tools
from pybel_tools.visualization import to_jupyter

"""
Explanation: Converting BioPAX to BEL
Author: Charles Tapley Hoyt
Estimated Run Time: 5 seconds
This notebook shows how a WikiPathways entry, distributed as BioPAX, can be loaded into PyBEL using INDRA.
Imports
End of explanation
"""


%%bash
java -showversion 2>&1 | head -n 4

%%bash
locale

print(sys.version)

print(time.asctime())

os.environ['CLASSPATH']

"""
Explanation: Environment
End of explanation
"""


pybel.utils.get_version()

pybel_tools.utils.get_version()

pkg_resources.get_distribution("jnius-indra").version

indra.util.get_version.get_version()

"""
Explanation: Dependencies
End of explanation
"""


apoptosis_url = 'https://www.wikipathways.org//wpi/wpi.php?action=downloadFile&type=owl&pwTitle=Pathway:WP254&oldid=95107'

apoptosis_path = os.path.join(os.path.expanduser('~'), 'Downloads', 'WP254_95107.owl')

if not os.path.exists(apoptosis_path):
    urlretrieve(apoptosis_url, apoptosis_path)

"""
Explanation: Data
The apoptosis pathway is downloaded from WikiPathways to the current user's downloads folder.
End of explanation
"""


graph = pybel.from_biopax(apoptosis_path)

to_jupyter(graph)

"""
Explanation: Conversion
A file path is given to pybel.from_biopax, which wraps indra.sources.biopax.biopax_api.process_owl.
End of explanation
"""


