sys-bio / tellurium

Python Environment for Modeling and Simulating Biological Systems
http://tellurium.analogmachine.org/
Apache License 2.0
106 stars 36 forks source link

Tellurium notebook UnicodeDecodeError in example notebooks on Ubuntu #306

Closed matthiaskoenig closed 6 years ago

matthiaskoenig commented 6 years ago

I am getting UnicodeDecodeError in the tellurium notebook version when running some of the example notebooks. For instace the Wolf example:

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-3-7faca393993f> in <module>()
----> 1 get_ipython().run_cell_magic('omex', '', '// Author information:\n// - Name: kyle medley\n// - Email: medleyj@uw.edu\n// - Organization: uw\n// -- Begin Antimony block converted from wolf2001.xml\n// Created by libAntimony v2.9.3\nmodel *wolf2001()\n\n  // Compartments and Species:\n  compartment c0, c1, c2;\n  species $sul_ex in c0, $eth_ex in c0, $oxy_ex in c0, oxy in c2, $H2O in c2;\n  species A3c in c1, aps in c1, $PPi in c1, pap in c1, sul in c1, eth in c1;\n  species $A2c in c1, hyd in c1, cys in c1, N2 in c1, $N1 in c1, aco in c1;\n  species oah in c1, S1 in c2, $S2 in c2, $C1 in c2, $C2 in c2, $A2m in c2;\n  species A3m in c2, $Ho in c1, $Hm in c2;\n\n  // Assignment Rules:\n  A2c := Ac - A3c;\n  N1 := N - N2;\n  S2 := S - S1;\n  A2m := Am - A3m;\n\n  // Reactions:\n  v1: $sul_ex => sul; c0*k_v0/(1 + (cys/Kc)^n);\n  v13: $eth_ex => eth; c0*k_v13;\n  v2: sul + A3c => aps + $PPi; c1*k2*sul*A3c;\n  v10: $oxy_ex => oxy; c0*k_v10;\n  v14: oxy => $oxy_ex; c2*k14*oxy;\n  v3: aps + A3c => pap + $A2c; c1*k3*aps*A3c;\n  v4: pap + 3 N2 => hyd + 3 $N1; c1*k4*pap*N2;\n  v5: hyd + oah => cys; c1*k5*hyd*oah;\n  v6: cys => ; c1*k6*cys;\n  v7: eth + 2 $N1 => aco + 2 N2; c1*k7*eth*N1;\n  v15: aco => oah; c1*k15*aco;\n  v17: hyd => ; c1*k17*hyd;\n  v18: oah => ; c1*k18*oah;\n  v8: $S2 + aco => S1; c2*k8*aco*S2;\n  v9: S1 + 4 $N1 => $S2 + 4 N2; c2*k9*S1*N1;\n  v11a: $C1 + $Hm + N2 => $C2 + $Ho + $N1; c2*k11*N2*oxy/((a*N2 + oxy)*(1 + (hyd/Kh)^m));\n  v11a2: $C2 + oxy => $C1 + $H2O; c2*k11*N2*oxy/((a*N2 + oxy)*(1 + (hyd/Kh)^m));\n  v16: $A2c + A3m => $A2m + A3c; c2*k16*A3m*A2c;\n  v11b: $Ho + $A2m => $Hm + A3m; (c2*3*k11*N2*oxy/((a*N2 + oxy)*(1 + (hyd/Kh)^m)))*A2m/(Ka + A2m);\n  vLEAK: $Ho => $Hm; 0;\n  v12: A3c => $A2c; c1*k12*A3c;\n\n  // Species initializations:\n  sul_ex = 0;\n  eth_ex = 0;\n  oxy_ex = 0;\n  oxy = 7;\n  oxy has substance_per_volume;\n  H2O = 0;\n  A3c = 1.5;\n  A3c has substance_per_volume;\n  aps = 0.5;\n  aps has substance_per_volume;\n  PPi = 0;\n  pap = 0.4;\n  pap has substance_per_volume;\n  sul = 0.4;\n  sul has substance_per_volume;\n  eth = 4;\n  eth has substance_per_volume;\n  A2c has substance_per_volume;\n  hyd = 0.5;\n  hyd has substance_per_volume;\n  cys = 0.3;\n  cys has substance_per_volume;\n  N2 = 2;\n  N2 has substance_per_volume;\n  N1 has substance_per_volume;\n  aco = 0.3;\n  aco has substance_per_volume;\n  oah = 1.5;\n  oah has substance_per_volume;\n  S1 = 1.5;\n  S1 has substance_per_volume;\n  S2 has substance_per_volume;\n  C1 = 0;\n  C2 = 0;\n  A2m has substance_per_volume;\n  A3m = 1.5;\n  A3m has substance_per_volume;\n  Ho = 0;\n  Hm = 0;\n\n  // Compartment initializations:\n  c0 = 1;\n  c1 = 1;\n  c2 = 1;\n\n  // Variable initializations:\n  Ac = 2;\n  N = 2;\n  S = 2;\n  Am = 2;\n  k_v0 = 1.6;\n  Kc = 0.1;\n  n = 4;\n  k_v13 = 4;\n  k2 = 0.2;\n  k_v10 = 80;\n  k14 = 10;\n  k3 = 0.2;\n  k4 = 0.2;\n  k5 = 0.1;\n  k6 = 0.12;\n  k7 = 10;\n  k15 = 5;\n  k17 = 0.02;\n  k18 = 1;\n  k8 = 10;\n  k9 = 10;\n  k11 = 10;\n  a = 0.1;\n  Kh = 0.5;\n  m = 4;\n  k16 = 10;\n  Ka = 1;\n  k12 = 5;\n\n  // Other declarations:\n  const c0, c1, c2, Ac, N, S, Am, k_v0, Kc, n, k_v13, k2, k_v10, k14, k3;\n  const k4, k5, k6, k7, k15, k17, k18, k8, k9, k11, a, Kh, m, k16, Ka, k12;\n\n  // Unit definitions:\n  unit substance_per_volume = mole / litre;\n  unit substance = mole;\n\n  // Display Names:\n  c0 is "external";\n  c1 is "cytosol";\n  c2 is "mitochondria";\n  sul_ex is "SO4_ex";\n  eth_ex is "EtOH_ex";\n  oxy_ex is "O2_ex";\n  oxy is "O2";\n  A3c is "ATP";\n  aps is "APS";\n  pap is "PAPS";\n  sul is "SO4";\n  eth is "EtOH";\n  A2c is "ADP";\n  hyd is "H2S";\n  cys is "CYS";\n  N2 is "NADH";\n  N1 is "NAD";\n  aco is "AcCoA";\n  oah is "OAH";\n  A2m is "ADP_mit";\n  A3m is "ATP_mit";\n  v11a is "vET1";\n  v11a2 is "vET2";\n  v11b is "vSYNT";\nend\n// -- End Antimony block\n\n// -- Begin PhraSEDML block converted from main.xml\n// Created by libphrasedml v1.0.7\n// Models\nmodel_m_1 = model "wolf2001" with m = 1\nmodel_m_2 = model "wolf2001" with m = 2\nmodel_m_4 = model "wolf2001" with m = 4\nmodel_m_8 = model "wolf2001" with m = 8\nmodel_m_16 = model "wolf2001" with m = 16\n\n// Simulations\nsim_short = simulate uniform(0, 100, 5000)\nsim_long = simulate uniform(0, 200, 5000)\n\n// Tasks\nm1_short = run sim_short on model_m_1\nm2_short = run sim_short on model_m_2\nm4_short = run sim_short on model_m_4\nm8_short = run sim_short on model_m_8\nm16_short = run sim_short on model_m_16\nm1_long = run sim_long on model_m_1\nm2_long = run sim_long on model_m_2\nm4_long = run sim_long on model_m_4\nm8_long = run sim_long on model_m_8\nm16_long = run sim_long on model_m_16\n\n// Outputs\nplot "Oxygen (short duration)" m1_short.time vs m1_short.model_m_1.oxy, m2_short.model_m_2.oxy, m4_short.model_m_4.oxy, m8_short.model_m_8.oxy, m16_short.model_m_16.oxy\nplot "Oxygen (long duration)" m1_long.time vs m1_long.model_m_1.oxy, m2_long.model_m_2.oxy, m4_long.model_m_4.oxy, m8_long.model_m_8.oxy, m16_long.model_m_16.oxy\n// -- End PhraSEDML block')

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2129             magic_arg_s = self.var_expand(line, stack_depth)
   2130             with self.builtin_trap:
-> 2131                 result = fn(magic_arg_s, cell)
   2132             return result
   2133 

<decorator-gen-130> in omex(self, line, cell)

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/temagics/magics.py in omex(self, line, cell)
     76 
     77         if not savefile:
---> 78             executeInlineOmex(cell)
     79         else:
     80             exportInlineOmex(cell, savefile)

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/tellurium/tellurium.py in executeInlineOmex(inline_omex)
    693     :param inline_omex: String containing inline phrasedml and antimony.
    694     """
--> 695     in_omex = teconverters.inlineOmex.fromString(inline_omex)
    696     in_omex.executeOmex()
    697 

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/tellurium/teconverters/inline_omex.py in fromString(cls, omex_str)
    189                 })
    190 
--> 191         return inlineOmex(sources)
    192 
    193 

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/tellurium/teconverters/inline_omex.py in __init__(self, sources)
     51         self.omex = Omex(
     52             description=DumpJSONInfo(),
---> 53             creator=readCreator()
     54         )
     55 

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/site-packages/tellurium/teconverters/convert_omex.py in readCreator(file)
     32             return None
     33     with open(file) as f:
---> 34         return json.load(f)
     35 
     36 

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/json/__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    294 
    295     """
--> 296     return loads(fp.read(),
    297         cls=cls, object_hook=object_hook,
    298         parse_float=parse_float, parse_int=parse_int,

~/.config/Tellurium/telocal/python-3.6.3/lib/python3.6/encodings/ascii.py in decode(self, input, final)
     24 class IncrementalDecoder(codecs.IncrementalDecoder):
     25     def decode(self, input, final=False):
---> 26         return codecs.ascii_decode(input, self.errors)[0]
     27 
     28 class StreamWriter(Codec,codecs.StreamWriter):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 57: ordinal not in range(128)
0u812 commented 6 years ago

Thanks for reporting both of these. This one was a Unicode error. Rebuilding the notebook binaries now.