Mercurial > repos > sybila > ebcsgen_static_analysis
changeset 0:35cc9bb0b4e9 draft
planemo upload for repository https://github.com/sybila/galaxytools/tree/master/tools/ebcsgen commit f39ef50b0964744be7816de065024eeb1fb69364
author | sybila |
---|---|
date | Sat, 08 Oct 2022 14:07:25 +0000 |
parents | |
children | c3e4561d2cab |
files | ebcsgen_static_analysis.py ebcsgen_static_analysis.xml macros.xml test-data/reduced.bcsl.model test-data/redundant.bcsl.model |
diffstat | 5 files changed, 159 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ebcsgen_static_analysis.py Sat Oct 08 14:07:25 2022 +0000 @@ -0,0 +1,54 @@ +import argparse + +from eBCSgen.Errors.ComplexParsingError import ComplexParsingError +from eBCSgen.Errors.ModelParsingError import ModelParsingError +from eBCSgen.Errors.UnspecifiedParsingError import UnspecifiedParsingError +from eBCSgen.Parsing.ParseBCSL import Parser + + +def save_model(model, filename): + f = open(filename, "w") + f.write(repr(model)) + f.close() + + +args_parser = argparse.ArgumentParser(description='Static analysis') + +args_parser._action_groups.pop() +required = args_parser.add_argument_group('required arguments') +optional = args_parser.add_argument_group('optional arguments') + +required.add_argument('--model', type=str, required=True) +required.add_argument('--output', type=str, required=True) +required.add_argument('--method', type=str, required=True) +optional.add_argument('--complex') + +args = args_parser.parse_args() + +model_parser = Parser("model") +model_str = open(args.model, "r").read() +model = model_parser.parse(model_str) + +if model.success: + if args.method == "reduce": + model.data.reduce_context() + save_model(model.data, args.output) + elif args.method == "eliminate": + model.data.eliminate_redundant() + save_model(model.data, args.output) + else: + complex_parser = Parser("rate_complex") + complex = complex_parser.parse(args.complex) + if complex.success: + result = model.data.static_non_reachability(complex.data.children[0]) + f = open(args.output, "w") + s = "can possibly" if result else "cannot" + message = "The given agent\n\t{}\n{} be reached in the model.".format(complex.data.children[0], s) + f.write(message) + f.close() + else: + raise ComplexParsingError(complex.data, args.complex) +else: + if "error" in model.data: + raise UnspecifiedParsingError(model.data["error"]) + raise ModelParsingError(model.data, model_str)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ebcsgen_static_analysis.xml Sat Oct 08 14:07:25 2022 +0000 @@ -0,0 +1,73 @@ +<tool id="eBCSgen_static_analysis" name="eBCSgen static analysis" version="@TOOL_VERSION@_galaxy0"> + <description>- run static analysis techniques on given BCSL model</description> + <macros> + <import>macros.xml</import> + </macros> + <expand macro="creator"/> + <requirements> + <container type="docker">sybila/ebcsgen:v@TOOL_VERSION@</container> + </requirements> + + <options sanitize="False"/> + <command>python3 ${__tool_directory__}/ebcsgen_static_analysis.py + --model '$model' + --output '$output' + --method '$Method.method' + #if $Method.method == "reach": + --complex '$Method.complex' + #end if + </command> + + <inputs> + <param format="bcsl.model" name="model" type="data" label="Model file" help="Provide a BCSL model file"/> + <conditional name="Method"> + <param name="method" type="select" label="Choose static analysis method:"> + <option value="reach" selected="true">Static non-reachability</option> + <option value="eliminate">Rule redundancy elimination</option> + <option value="reduce">Context based reduction</option> + </param> + <when value="reach"> + <param name="complex" value="" type="text" label="Complex agent:"> + <validator type="empty_field"/> + </param> + </when> + </conditional> + </inputs> + + <outputs> + <data format="bcsl.model" name="output"> + <change_format> + <when input="Method.method" value="reach" format="txt"/> + </change_format> + </data> + </outputs> + + <tests> + <test> + <param name="model" value="redundant.bcsl.model" ftype="bcsl.model"/> + <param name="method" value="reach"/> + <param name="complex" value="P(S{i},T{a})::out"/> + <output name="output" ftype="txt"> + <assert_contents> + <has_text text="can possibly be reached in the model"/> + </assert_contents> + </output> + </test> + <test> + <param name="model" value="redundant.bcsl.model" ftype="bcsl.model"/> + <param name="method" value="eliminate"/> + <output name="output" ftype="bcsl.model"> + <assert_contents> + <has_text text="r1_X ~ // redundant #{1, 2} // P(T{i})::cell => P(T{a})::cell @ 1.0"/> + <has_text text="r1_T ~ // redundant #{1, 2} // P(T{i})::cell => P(T{a})::cell @ 1.0"/> + </assert_contents> + </output> + </test> + <test> + <param name="model" value="redundant.bcsl.model" ftype="bcsl.model"/> + <param name="method" value="reduce"/> + <output name="output" value="reduced.bcsl.model" ftype="bcsl.model"/> + </test> + </tests> + +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/macros.xml Sat Oct 08 14:07:25 2022 +0000 @@ -0,0 +1,17 @@ +<macros> + <token name="@TOOL_VERSION@">2.0.3</token> + + <xml name="creator"> + <creator> + <person + givenName="Matej" + familyName="Troják" + url="https://github.com/xtrojak" + identifier="0000-0003-0841-2707" /> + <organization + url="https://sybila.fi.muni.cz/" + email="sybila@fi.muni.cz" + name="SYBILA MUNI" /> + </creator> + </xml> +</macros>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/reduced.bcsl.model Sat Oct 08 14:07:25 2022 +0000 @@ -0,0 +1,7 @@ +#! rules +P()::cell => P()::out @ 1.0 + +#! inits +1 P()::cell + +#! definitions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/redundant.bcsl.model Sat Oct 08 14:07:25 2022 +0000 @@ -0,0 +1,8 @@ +#! rules +r1_S ~ P(S{i})::cell => P(S{a})::cell +r1_T ~ P(T{i})::cell => P(T{a})::cell +r2 ~ P()::cell => P()::out +r1_X ~ P(T{i})::cell => P(T{a})::cell + +#! inits +1 P(S{i},T{i})::cell \ No newline at end of file