diff --git a/c302/OpenWormReader.py b/c302/OpenWormReader.py index b88f45ca..68a1ad0f 100644 --- a/c302/OpenWormReader.py +++ b/c302/OpenWormReader.py @@ -5,11 +5,15 @@ from c302.NeuroMLUtilities import analyse_connections from c302 import print_, MUSCLE_RE -from owmeta_core.bundle import Bundle -from owmeta_core.context import Context -from owmeta.neuron import Neuron -from owmeta.muscle import BodyWallMuscle -from owmeta.worm import Worm +try: + from owmeta_core.bundle import Bundle + from owmeta_core.context import Context + from owmeta.neuron import Neuron + from owmeta.muscle import BodyWallMuscle + from owmeta.worm import Worm +except: + print("owmeta not installed! Cannot run OpenWormReader") + exit() ############################################################ diff --git a/c302/__init__.py b/c302/__init__.py index 581c08b8..89b5ee22 100755 --- a/c302/__init__.py +++ b/c302/__init__.py @@ -39,13 +39,18 @@ import collections -from owmeta_core import __version__ as owc_version -from owmeta_core.bundle import Bundle -from owmeta_core.context import Context -from owmeta import __version__ as owmeta_version -from owmeta.cell import Cell -from owmeta.neuron import Neuron -from owmeta.muscle import Muscle +try: + from owmeta_core import __version__ as owc_version + from owmeta_core.bundle import Bundle + from owmeta_core.context import Context + from owmeta import __version__ as owmeta_version + from owmeta.cell import Cell + from owmeta.neuron import Neuron + from owmeta.muscle import Muscle + owmeta_installed = True +except: + print("owmeta not installed! Proceeding anyway...") + owmeta_installed = False try: from urllib2 import URLError # Python 2 @@ -618,8 +623,8 @@ def generate(net_id, info = "\n\nParameters and setting used to generate this network:\n\n"+\ " Data reader: %s\n" % data_reader+\ " c302 version: %s\n" % __version__+\ - " owmeta version: %s\n" % owmeta_version+\ - " owmeta_core version: %s\n" % owc_version+\ + " owmeta version: %s\n" % ('' if not owmeta_installed else owmeta_version) +\ + " owmeta_core version: %s\n" % ('' if not owmeta_installed else owc_version) +\ " Cells: %s\n" % (cells if cells is not None else "All cells")+\ " Cell stimulated: %s\n" % (cells_to_stimulate if cells_to_stimulate is not None else "All neurons")+\ " Connection: %s\n" % (conns_to_include if conns_to_include is not None else "All connections") + \ diff --git a/c302/c302_utils.py b/c302/c302_utils.py index e1e7e0fd..e476f08c 100644 --- a/c302/c302_utils.py +++ b/c302/c302_utils.py @@ -8,7 +8,6 @@ import numpy as np from pyneuroml import pynml from pyneuroml import plot as pyneuroml_plot -from owmeta_core.bundle import Bundle import c302 @@ -456,6 +455,7 @@ def generate_conn_matrix(nml_doc, save_fig_dir=None, verbose=False, figsize=defa all_cells = sorted(all_cells) try: + from owmeta_core.bundle import Bundle with Bundle('openworm/owmeta-data', version=6) as bnd: all_neuron_info, all_muscle_info = c302._get_cell_info(bnd, all_cells) except Exception as e: diff --git a/setup.py b/setup.py index 16f8f2de..12799e6c 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,6 @@ 'xlrd', 'xlwt', 'pyNeuroML>=0.5.11', - 'owmeta>=0.12.3', 'WormNeuroAtlas', ], entry_points={