Я бы хотел использовать Cytoscape. js (https://js.cytoscape.org/) в Google Colab. Я обнаружил здесь (https://py2cytoscape.readthedocs.io/en/latest/), что это можно сделать в Jupyter Notebooks, но документация не очень тщательная.
Вот код, который я запустил, чтобы попытаться настроить Cytoscape и CyREST (вставьте каждый блок кода сюда в отдельную ячейку в Google Colab):
%%shell
# Install dependencies
pip install py2cytoscape
pip install dash dash-html-components
pip install dash-cytoscape
apt install g++ make libxml2-dev python-dev python3-dev zlib1g-dev
# Clone Cytoscape from Git and install
cd /usr/local/envs/cytoscape
wget https://github.com/cytoscape/cytoscape/releases/download/3.8.0/Cytoscape_3_8_0_unix.sh
chmod u+x Cytoscape_3_8_0_unix.sh
sudo sh Cytoscape_3_8_0_unix.sh -q
# Run Cytoscape to check that everything was installed correctly
Cytoscape &
# Start Cytoscape
!Cytoscape &
from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient()
network = cy.network.create(name='My Network', collection='My network collection')
print(network.get_id())
Это дало мне следующую ошибку:
---------------------------------------------------------------------------
ConnectionRefusedError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in _new_conn(self)
158 conn = connection.create_connection(
--> 159 (self._dns_host, self.port), self.timeout, **extra_kw)
160
23 frames
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f822bd80860>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
MaxRetryError: HTTPConnectionPool(host='localhost', port=1234): Max retries exceeded with url: /v1/styles/visualproperties (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f822bd80860>: Failed to establish a new connection: [Errno 111] Connection refused',))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
514 raise SSLError(e, request=request)
515
--> 516 raise ConnectionError(e, request=request)
517
518 except ClosedPoolError as e:
ConnectionError: HTTPConnectionPool(host='localhost', port=1234): Max retries exceeded with url: /v1/styles/visualproperties (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f822bd80860>: Failed to establish a new connection: [Errno 111] Connection refused',))
Я нашел этот фрагмент кода где-то, который должен помочь с запуском CyREST, но его запуск дал мне ту же ошибку, что и выше (которую я действительно не понимаю)
REST_PORT = '1234' # Set to whatever rest.port is in Cytoscape preferences
REST_ENDPOINT = "http://localhost:{}/v1".format(REST_PORT)
import requests
import json
import os
from urllib.request import urlretrieve
from IPython.display import Image, display, HTML
response = requests.get(REST_ENDPOINT)
js_resp = response.json()
assert js_resp['apiVersion'] == 'v1', \
"This notebook uses CyREST API v1, but version {} was found.".format(js_resp['apiVersion'])
print("CyREST v1 is running!")
Я предполагаю, что это проблема с порты в среде Google Colab Ubuntu, но я не знаю, как это исправить.