Install¶
py4cytoscape
requires Python 3.6, 3.7, or 3.8. If you do not already
have a Python environment configured on your computer, please see the
instructions for installing the full scientific Python stack.
Note
If you are on Windows and want to install optional packages (e.g., scipy), then you will need to install a Python distributions such as Anaconda, Enthought Canopy, Python(x,y), WinPython, or Pyzo. If you use one of these Python distribution, please refer to their online documentation.
PyCharm and other integrated development environments often install their own Python distributions.
Below we assume you have the default Python environment already configured on
your computer and you intend to install py4cytoscape
inside of it. If you want
to create and work with Python virtual environments, please follow instructions
on venv and virtual
environments.
First, make sure you have the latest version of pip
(the Python package manager)
installed. If you do not, refer to the Pip documentation and install pip
first.
Cytoscape Prerequisite¶
To exercise py4cytoscape
, you must first have downloaded, installed, and
executed Cytoscape. If you have not already done this, please refer to the Launching
Cytoscape
instructions.
Note
Cytoscape and py4cytoscape
must be running on the same workstation or
virtual machine. py4cytoscape
communicates with Cytoscape via a localhost
connection, which precludes py4cytoscape
from accessing Cytoscape
remotely. While this limitation can be overcome by configuring py4cytoscape
or
supplying the Cytoscape URL in py4cytoscape
calls, this can become a complex
networking problem if firewalls and routers are present on the network.
Install the development version (Python Console or Jupyter Notebook)¶
Install the current release of py4cytoscape
with pip
:
pip install python-igraph requests pandas networkx
pip install py4cytoscape
cd py4cytoscape
python setup.py install # or python setup.py install --user
To install the latest py4cytoscape development version, instead
of pip install py4cytoscape
, use:
git clone git://github.com/cytoscape/py4cytoscape
Verify Cytoscape connection¶
To verify that py4cytoscape
is properly installed and able to communicate with
Cytoscape, execute the following in a Python Console or Jupyter Notebook
(after starting Cytoscape):
import py4cytoscape as py4
dir(py4)
py4.cytoscape_ping()
py4.cytoscape_version_info()
This will import py4cytoscape
into the Python namespace, print a (long) list
of py4cytoscape
entrypoints, and then demonstrate a connection to Cytoscape
by collecting Cytoscape information.
Testing¶
py4cytoscape
uses the Python unittest
testing package. You can learn more
about unittest
on its homepage.
To execute tests from an OS command line, set the current directory to
the py4cytoscape
package directory. Then, establish the execution environment:
cd tests
set PYTHONPATH=..
Note
You must start Cytoscape before executing any tests. For Cytoscape execution, the current directory should be the Cytoscape program directory.
The py4cytoscape
test suite consists of a number of sub-suites. Executing one
or two of them is relatively quick. To execute a single sub-suite
(e.g., test_apps.py
):
python -m unittest test_apps.py
To execute more than one sub-suite (e.g., test_apps.py
and test_filters.py
):
python -m unittest test_apps.py test_filters.py
To execute the entire test suite:
python -m unittest
To execute a single test (e.g., test_get_app_information) in a single test suite:
python -m unittest test_apps.AppsTests.test_get_app_information
Note
To send test output to a file, redirect stderr and console:
python -m unittest 2>stderr.log 1>cons.log
Some tests require console input, and without console prompts, the tests will appear to stall. To avoid executing such tests, set the PY4CYTOSCAPE_SKIP_UI_TESTS environment variable described below.
The runalltests.bat
script contains all commands needed to run all tests
with all environment variables set. It must be run with the tests
directory
as the current directory.
Note
To execute tests with less console debug output, set this environment variable before executing tests:
set PY4CYTOSCAPE_SUMMARY_LOGGER=FALSE
To further configure logging, see the Logging file.
Note
To execute tests without showing test names as tests execute, set this environment variable before executing the tests:
set PY4CYTOSCAPE_SHOW_TEST_PROGRESS=FALSE
Note
To skip execution of tests that require user input, set this environment variable before executing tests:
set PY4CYTOSCAPE_SKIP_UI_TESTS=TRUE
Note
When executing a large number of tests, we recommend that all three environment variables be set as described above.
Note
When executing tests in PyCharm, you can set environment
variables using the Run | Edit Configurations...
menu item.