Skip to content

Commit

Permalink
Merge pull request #46 from sybila/bioconda
Browse files Browse the repository at this point in the history
Bioconda preparations
  • Loading branch information
xtrojak authored Feb 12, 2022
2 parents 8baaa24 + 3bf7fcd commit 9401411
Show file tree
Hide file tree
Showing 71 changed files with 273 additions and 314 deletions.
12 changes: 6 additions & 6 deletions Callables/CTLModelChecking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Analysis.CTL import CTL
from Parsing.ParseBCSL import load_TS_from_json
import Parsing.ParseCTLformula
from Errors.FormulaParsingError import FormulaParsingError
from Errors.InvalidInputError import InvalidInputError
from eBCSgen.Analysis.CTL import CTL
from eBCSgen.Parsing.ParseBCSL import load_TS_from_json
from eBCSgen.Errors.FormulaParsingError import FormulaParsingError
from eBCSgen.Errors.InvalidInputError import InvalidInputError
from eBCSgen.Parsing.ParseCTLformula import CTLparser

"""
usage: CTLModelChecking.py [-h] --transition_file TRANSITION_FILE
Expand Down Expand Up @@ -40,7 +40,7 @@
if len(ts.params) != 0:
raise InvalidInputError("Provided transition system is parametrised - model checking cannot be executed.")

formula = Parsing.ParseCTLformula.CTLparser().parse(args.formula)
formula = CTLparser().parse(args.formula)
if formula.success:
result, states = CTL.model_checking(ts, formula)
output = 'Result: {}\nNumber of satisfying states: {}'.format(result, len(states))
Expand Down
6 changes: 3 additions & 3 deletions Callables/ExportSBML.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Parsing.ParseBCSL import Parser
from Errors.ModelParsingError import ModelParsingError
from Errors.UnspecifiedParsingError import UnspecifiedParsingError
from eBCSgen.Parsing.ParseBCSL import Parser
from eBCSgen.Errors.ModelParsingError import ModelParsingError
from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError

"""
usage: ExportSBML.py [-h] --model MODEL --output OUTPUT
Expand Down
7 changes: 3 additions & 4 deletions Callables/GenerateTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Parsing.ParseBCSL import Parser, load_TS_from_json
from Errors.ModelParsingError import ModelParsingError
from Errors.UnspecifiedParsingError import UnspecifiedParsingError
from Errors.RatesNotSpecifiedError import RatesNotSpecifiedError
from eBCSgen.Parsing.ParseBCSL import Parser, load_TS_from_json
from eBCSgen.Errors.ModelParsingError import ModelParsingError
from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError

"""
usage: GenerateTS.py [-h] --model MODEL --output OUTPUT --direct DIRECT
Expand Down
12 changes: 6 additions & 6 deletions Callables/PCTLModelChecking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Analysis.PCTL import PCTL
from Parsing.ParseBCSL import load_TS_from_json
import Parsing.ParsePCTLformula
from Errors.FormulaParsingError import FormulaParsingError
from Errors.InvalidInputError import InvalidInputError
from eBCSgen.Analysis.PCTL import PCTL
from eBCSgen.Parsing.ParseBCSL import load_TS_from_json
from eBCSgen.Errors.FormulaParsingError import FormulaParsingError
from eBCSgen.Errors.InvalidInputError import InvalidInputError
from eBCSgen.Parsing.ParsePCTLformula import PCTLparser

"""
usage: PCTLModelChecking.py [-h] --transition_file TRANSITION_FILE
Expand Down Expand Up @@ -51,7 +51,7 @@
if len(ts.params) != 0:
raise InvalidInputError("Provided transition system is parametrised - model checking cannot be executed.")

formula = Parsing.ParsePCTLformula.PCTLparser().parse(args.formula)
formula = PCTLparser().parse(args.formula)
if formula.success:
result = PCTL.model_checking(ts, formula, storm_local=local_storm)
f = open(args.output, "w")
Expand Down
13 changes: 6 additions & 7 deletions Callables/PCTLParameterSynthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Analysis.PCTL import PCTL
from Parsing.ParseBCSL import load_TS_from_json
import Parsing.ParsePCTLformula

from Errors.FormulaParsingError import FormulaParsingError
from Errors.InvalidInputError import InvalidInputError
from eBCSgen.Analysis.PCTL import PCTL
from eBCSgen.Parsing.ParseBCSL import load_TS_from_json
from eBCSgen.Errors.FormulaParsingError import FormulaParsingError
from eBCSgen.Errors.InvalidInputError import InvalidInputError
from eBCSgen.Parsing.ParsePCTLformula import PCTLparser

"""
usage: PCTLParameterSynthesis.py [-h] --transition_file TRANSITION_FILE
Expand Down Expand Up @@ -70,7 +69,7 @@
if undefined:
raise InvalidInputError("Intervals undefined for parameters: {}.".format(", ".join(undefined)))

formula = Parsing.ParsePCTLformula.PCTLparser().parse(args.formula)
formula = PCTLparser().parse(args.formula)
if formula.success:
result = PCTL().parameter_synthesis(ts, formula, region, local_storm)
f = open(args.output, "w")
Expand Down
4 changes: 2 additions & 2 deletions Callables/RemoteParsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import sys, os
import json

from flask import Flask, request, jsonify
from flask import Flask, request
from flask import make_response

# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Parsing.ParseBCSL import Parser
from eBCSgen.Parsing.ParseBCSL import Parser

app = Flask(__name__)

Expand Down
10 changes: 5 additions & 5 deletions Callables/Simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Parsing.ParseBCSL import Parser
from Errors.ModelParsingError import ModelParsingError
from Errors.UnspecifiedParsingError import UnspecifiedParsingError
from Errors.InvalidInputError import InvalidInputError
from Errors.RatesNotSpecifiedError import RatesNotSpecifiedError
from eBCSgen.Parsing.ParseBCSL import Parser
from eBCSgen.Errors.ModelParsingError import ModelParsingError
from eBCSgen.Errors import UnspecifiedParsingError
from eBCSgen.Errors.InvalidInputError import InvalidInputError
from eBCSgen.Errors.RatesNotSpecifiedError import RatesNotSpecifiedError

"""
usage: Simulation.py [-h] --model MODEL --output OUTPUT --deterministic
Expand Down
10 changes: 6 additions & 4 deletions Callables/StaticAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
# this add to path eBCSgen home dir, so it can be called from anywhere
sys.path.append(os.path.split(sys.path[0])[0])

from Parsing.ParseBCSL import Parser
from Errors.ModelParsingError import ModelParsingError
from Errors.ComplexParsingError import ComplexParsingError
from Errors.UnspecifiedParsingError import UnspecifiedParsingError
from eBCSgen.Parsing.ParseBCSL import Parser
from eBCSgen.Errors.ModelParsingError import ModelParsingError
from eBCSgen.Errors.ComplexParsingError import ComplexParsingError
from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError


def save_model(model, filename):
f = open(filename, "w")
f.write(repr(model))
f.close()


"""
usage: StaticAnalysis.py [-h] --model MODEL --output OUTPUT --method METHOD
[--complex COMPLEX]
Expand Down
10 changes: 5 additions & 5 deletions Testing/test_PCTL.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest

import Core.Formula
import Parsing.ParseBCSL
from Parsing.ParsePCTLformula import PCTLparser
from eBCSgen.Parsing.ParsePCTLformula import PCTLparser
from eBCSgen.Parsing.ParseBCSL import Parser
from eBCSgen.Core.Formula import AtomicProposition


class TestPCTL(unittest.TestCase):
Expand All @@ -15,13 +15,13 @@ def setUp(self):

# parse complex

complex_parser = Parsing.ParseBCSL.Parser("rate_complex")
complex_parser = Parser("rate_complex")

self.complex_1 = complex_parser.parse("K(S{i},T{a}).B{o}::cyt").data.children[0]
self.complex_2 = complex_parser.parse("K(S{a},T{a}).B{o}::cyt").data.children[0]
self.complex_3 = complex_parser.parse("K(S{a},T{i}).B{o}::cyt").data.children[0]

self.ap_1 = Core.Formula.AtomicProposition(self.complex_1, " >= ", "5")
self.ap_1 = AtomicProposition(self.complex_1, " >= ", "5")

def test_str(self):
formula = self.parser.parse(self.formula_1)
Expand Down
10 changes: 5 additions & 5 deletions Testing/test_TS.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import unittest
import numpy as np

from Core.Complex import Complex
from Core.Structure import StructureAgent
from TS.Edge import Edge
from TS.State import State, Vector, Memory
from TS.TransitionSystem import TransitionSystem
from eBCSgen.Core.Complex import Complex
from eBCSgen.Core.Structure import StructureAgent
from eBCSgen.TS.Edge import Edge
from eBCSgen.TS.State import State, Vector, Memory
from eBCSgen.TS.TransitionSystem import TransitionSystem


class TestTransitionSystem(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion Testing/test_atomic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from Core.Atomic import AtomicAgent
from eBCSgen.Core.Atomic import AtomicAgent


class TestAtomic(unittest.TestCase):
Expand Down
12 changes: 6 additions & 6 deletions Testing/test_complex.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import collections
import unittest

import Parsing.ParseBCSL
from Core.Structure import StructureAgent
from Core.Atomic import AtomicAgent
from Core.Complex import Complex, align_agents
from eBCSgen.Core.Structure import StructureAgent
from eBCSgen.Core.Atomic import AtomicAgent
from eBCSgen.Core.Complex import Complex, align_agents
from eBCSgen.Parsing.ParseBCSL import Parser


class TestComplex(unittest.TestCase):
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_create_all_compatible(self):
atomic_signature = {"S": {"a", "i"}, "T": {"u", "p"}}
structure_signature = {"KaiC": {"S"}}

complex_parser = Parsing.ParseBCSL.Parser("rate_complex")
complex_parser = Parser("rate_complex")

complex1 = complex_parser.parse("KaiC(S{a}).T{u}::cyt").data.children[0]
complex2 = complex_parser.parse("KaiC(S{a}).T{p}::cyt").data.children[0]
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_align_agents(self):
agent = "X(T{s}).A(S{i},U{a}).A(S{i},U{b})::cyt"
pattern = "A().A(S{i}).X()::cyt"

complex_parser = Parsing.ParseBCSL.Parser("rate_complex")
complex_parser = Parser("rate_complex")

complex = complex_parser.parse(agent).data.children[0]
pattern = complex_parser.parse(pattern).data.children[0]
Expand Down
2 changes: 1 addition & 1 deletion Testing/test_export_SBML.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import libsbml

from Parsing.ParseBCSL import Parser
from eBCSgen.Parsing.ParseBCSL import Parser


class TestSBMLexport(unittest.TestCase):
Expand Down
48 changes: 24 additions & 24 deletions Testing/test_formal_methods.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import unittest

import Parsing.ParsePCTLformula
import Parsing.ParseCTLformula
from Analysis.PCTL import PCTL
from Analysis.CTL import CTL
from Errors.ComplexOutOfScope import ComplexOutOfScope
from Parsing.ParseBCSL import Parser, load_TS_from_json
from eBCSgen.Analysis.PCTL import PCTL
from eBCSgen.Analysis.CTL import CTL
from eBCSgen.Errors.ComplexOutOfScope import ComplexOutOfScope
from eBCSgen.Parsing.ParseBCSL import Parser, load_TS_from_json
from eBCSgen.Parsing.ParsePCTLformula import PCTLparser
from eBCSgen.Parsing.ParseCTLformula import CTLparser


class TestFormalMethods(unittest.TestCase):
def setUp(self):
self.parser = Parsing.ParsePCTLformula.PCTLparser()
self.parser = PCTLparser()
self.model_parser = Parser("model")
self.model = """
#! rules
Expand Down Expand Up @@ -69,22 +69,22 @@ def test_tumor_model_checking(self):
ts.save_to_json('/tmp/ts.json')
ts = load_TS_from_json('/tmp/ts.json')

formula = Parsing.ParsePCTLformula.PCTLparser().parse("P=? [F T(P{m})::x>2 & T(P{i})::x>=0 & T(P{i})::x<2]")
formula = self.parser.parse("P=? [F T(P{m})::x>2 & T(P{i})::x>=0 & T(P{i})::x<2]")
result = PCTL.model_checking(ts, formula)
self.assertTrue("Result" in str(result))

formula = Parsing.ParsePCTLformula.PCTLparser().parse("P > 0.5 [F T(P{m})::x>2]")
formula = self.parser.parse("P > 0.5 [F T(P{m})::x>2]")
result = PCTL.model_checking(ts, formula)
self.assertTrue("Result" in str(result))

def test_tumor_modelchecking_wrong_formula(self):
formula = Parsing.ParsePCTLformula.PCTLparser().parse("P > 0.5 [F T(P{m}):x>2]")
formula = self.parser.parse("P > 0.5 [F T(P{m}):x>2]")
error_message = {'line': 1, 'column': 19, 'unexpected': ':', 'expected': {'::', '.'}}
self.assertEqual(formula.data, error_message)

def test_parameter_synthesis(self):
model_parsed = self.model_parser.parse(self.tumor_parametric).data
formula = Parsing.ParsePCTLformula.PCTLparser().parse("P=? [F T(P{m})::x>2]")
formula = self.parser.parse("P=? [F T(P{m})::x>2]")
ts = model_parsed.generate_direct_transition_system()
ts.change_to_vector_backend()
ts.save_to_json('/tmp/ts.json', params=['d2'])
Expand All @@ -99,11 +99,11 @@ def test_parametric_model(self):
ts.save_to_json('/tmp/ts.json', params=['q'])
ts = load_TS_from_json('/tmp/ts.json')

formula = Parsing.ParsePCTLformula.PCTLparser().parse("P<=0.3 [F X().Y{_}::rep >= 1]")
formula = self.parser.parse("P<=0.3 [F X().Y{_}::rep >= 1]")
result = PCTL.parameter_synthesis(ts, formula, region='0<=q<=1')
self.assertTrue("Result (initial states)" in str(result))

formula = Parsing.ParsePCTLformula.PCTLparser().parse("P=? [F X().Y{_}::rep >= 1]")
formula = self.parser.parse("P=? [F X().Y{_}::rep >= 1]")
result = PCTL.parameter_synthesis(ts, formula, region=None)
self.assertTrue("Result (initial states)" in str(result))

Expand All @@ -122,7 +122,7 @@ def test_synthesis_out_of_scope(self):
k2 = 5
"""
model = self.model_parser.parse(model_str).data
formula = Parsing.ParsePCTLformula.PCTLparser().parse('P <= 0.5[F X()::out = 1]')
formula = self.parser.parse('P <= 0.5[F X()::out = 1]')
ts = model.generate_direct_transition_system()
ts.change_to_vector_backend()
ts.save_to_json('/tmp/ts.json', params=['k1'])
Expand All @@ -149,11 +149,11 @@ def test_synthesis_simple(self):
ts.save_to_json('/tmp/ts.json', params=['k1'])
ts = load_TS_from_json('/tmp/ts.json')

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P <= 0.5[F X()::rep = 1]')
formula = self.parser.parse('P <= 0.5[F X()::rep = 1]')
output = PCTL.parameter_synthesis(ts, formula, region='0<=k1<=1')
self.assertTrue("Region results" in str(output))

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P=? [F X()::rep = 1]')
formula = self.parser.parse('P=? [F X()::rep = 1]')
output = PCTL.parameter_synthesis(ts, formula, region=None)
self.assertTrue("Result (initial states)" in str(output))

Expand All @@ -178,11 +178,11 @@ def test_synthesis_advanced(self):
ts.save_to_json('/tmp/ts.json', params=['k1'])
ts = load_TS_from_json('/tmp/ts.json')

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P <= 0.5[F X()::rep = 1]')
formula = self.parser.parse('P <= 0.5[F X()::rep = 1]')
output = PCTL.parameter_synthesis(ts, formula, region='0<=k1<=1')
self.assertTrue("Region results" in str(output))

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P=? [F X()::rep = 1]')
formula = self.parser.parse('P=? [F X()::rep = 1]')
output = PCTL.parameter_synthesis(ts, formula, region=None)
self.assertTrue("Result (initial states)" in str(output))

Expand All @@ -207,11 +207,11 @@ def test_model_checking_simple(self):
ts.save_to_json('/tmp/ts.json')
ts = load_TS_from_json('/tmp/ts.json')

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P <= 0.5[F X()::rep=1]')
formula = self.parser.parse('P <= 0.5[F X()::rep=1]')
output = PCTL.model_checking(ts, formula)
self.assertTrue("Result (for initial states)" in str(output))

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P=? [F X()::rep = 1]')
formula = self.parser.parse('P=? [F X()::rep = 1]')
output = PCTL.model_checking(ts, formula)
self.assertTrue("Result (for initial states)" in str(output))

Expand All @@ -237,11 +237,11 @@ def test_model_checking_advanced(self):
ts.save_to_json('/tmp/ts.json')
ts = load_TS_from_json('/tmp/ts.json')

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P >= 0.5[F X()::rep=1]')
formula = self.parser.parse('P >= 0.5[F X()::rep=1]')
output = PCTL.model_checking(ts, formula)
self.assertTrue("Result (for initial states)" in str(output))

formula = Parsing.ParsePCTLformula.PCTLparser().parse('P=? [F X()::rep = 1]')
formula = self.parser.parse('P=? [F X()::rep = 1]')
output = PCTL.model_checking(ts, formula)
self.assertTrue("Result (for initial states)" in str(output))

Expand All @@ -264,10 +264,10 @@ def test_CTL_model_checking(self):
ts = model.generate_direct_transition_system()
ts.change_to_vector_backend()

formula = Parsing.ParseCTLformula.CTLparser().parse('E(F([Y()::rep > 1]))')
formula = CTLparser().parse('E(F([Y()::rep > 1]))')
result, states = CTL.model_checking(ts, formula)
self.assertTrue(result)

formula = Parsing.ParseCTLformula.CTLparser().parse('E(F([Z()::rep > 1]))')
formula = CTLparser().parse('E(F([Z()::rep > 1]))')
result, states = CTL.model_checking(ts, formula)
self.assertFalse(result)
Loading

0 comments on commit 9401411

Please sign in to comment.