Skip to content

SyntaxError when running from vcml file with parameter expressions containing || or && #29

@smgroves

Description

@smgroves

When I run a simulation from a vcml file that contains expressions with || and &&, python can't correctly parse them and gives a SyntaxError. The simulations seem to run (all the way to 100%) but then the error is given.

vc.simulate(biomodel, sim.name) gave the following traceback:

Traceback (most recent call last):
  File "/Users/smgroves/Documents/GitHub/VCell_Analysis/run_pyvcell/1_run_CPC_model.py", line 36, in <module>
    # %% run a loop of simulations
                           ^^^^^^^^
  File "/Users/smgroves/Documents/anaconda3/envs/pyvcell_env/lib/python3.11/site-packages/pyvcell/vcml/vcml_simulation.py", line 48, in simulate
    return Result(solver_output_dir=out_dir, sim_id=sim_id, job_id=job_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smgroves/Documents/anaconda3/envs/pyvcell_env/lib/python3.11/site-packages/pyvcell/sim_results/result.py", line 58, in __init__
    self.data_functions.read()
  File "/Users/smgroves/Documents/anaconda3/envs/pyvcell_env/lib/python3.11/site-packages/pyvcell/_internal/simdata/simdata_models.py", line 408, in read
    function = NamedFunction(name=name, vcell_expression=expression, variable_type=variable_type)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smgroves/Documents/anaconda3/envs/pyvcell_env/lib/python3.11/site-packages/pyvcell/_internal/simdata/simdata_models.py", line 364, in __init__
    tree = ast.parse(self.python_expression)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smgroves/Documents/anaconda3/envs/pyvcell_env/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<unknown>", line 1                               on', 'pNdc80:Mps1_trans_activation', 'Ndc80:pMps1_trans_activation', 'pNdc80:pMps1_trans_activation', 'Knl1_phos_panMps1a', ' Knl1_dephosp', 'Mps1a_input', 'Plk1a_input', 'Mps1i_cis_activation', 'pMps1_cis_activation', 'Mps1i_out...

This seemed to correspond to this expression in my vcml file:

        <SubVolume Name="void" Handle="2" Type="Analytical" KeyValue="296344228">
          <AnalyticExpression>(((x &gt;= 0.0) &amp;&amp; (x &lt;= 0.125) &amp;&amp; (y &gt;= 1.45) &amp;&amp; (y &lt;= 1.75)) || ((x &gt;= 1.475) &amp;&amp; (x &lt;= 1.6) &amp;&amp; (y &gt;= 1.45) &amp;&amp; (y &lt;= 1.75)))</AnalyticExpression>
        </SubVolume>

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

Status

Active

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions