Commit cc8c520c authored by MARTINEZ Thierry 's avatar MARTINEZ Thierry

Better documentation for options

parent ad72f2ec
This diff is collapsed.
......@@ -99,7 +99,7 @@ create_cgraph(Id, Graph) :-
\+ (
agnode(Graph, VertexName, true, Node),
(
get_attribute(VertexId, kind: transition)
get_attribute(VertexId, kind = transition)
->
agset(Node, shape, box)
;
......
......@@ -83,7 +83,7 @@ influence_graph_aux(GraphId) :-
set_attribute(EdgeId, sign = '-')
)
),
place(GraphId, Output, PlaceId),
add_edge(GraphId, TransitionId, Output, _)
place(GraphId, Output, OutputId),
add_edge(GraphId, TransitionId, OutputId, _)
)
).
......@@ -198,7 +198,8 @@ list_model :-
),
list_model_initial_state,
list_model_parameters,
list_model_functions.
list_model_functions,
list_model_options.
select_model(RefSet) :-
......
......@@ -3,6 +3,7 @@
[
% Grammars
method/1,
time/1,
% Commands
numerical_simulation/1
]
......@@ -12,6 +13,13 @@
:- devdoc('\\section{Grammars}').
:- doc('
The page
\\url{http://www.gnu.org/software/gsl/manual/html_node/Stepping-Functions.html#Stepping-Functions}
gives a detailed description of all the numerical methods listed below.
').
:- grammar(method).
......@@ -38,6 +46,13 @@ method(msadams).
method(msbdf).
:- grammar(time).
time(Number) :-
number(Number).
:- devdoc('\\section{Commands}').
......
:- module(
plot,
[
% Commands
plot/0,
set_plot_driver/1,
gnu_plot/0,
gnu_plot_png/0,
export_plot/1,
export_plot_to_png/1
export_plot_to_png/1,
export_plot_to_canvas/2,
% Public API
set_plot_driver/1,
gnu_plot/0
]
).
:- devdoc('\\section{Commands}').
plot :-
biocham_command,
doc('plots the current trace.'),
doc('
plots the current trace.
\\begin{example}'
),
biocham_silent(clear_model),
biocham(load(library:examples/mapk/mapk)),
biocham(numerical_simulation(20, method: msbdf)),
biocham(plot),
doc('
\\end{example}'
),
get_plot_driver(Driver),
Driver.
export_plot(FileTemplate) :-
biocham_command,
doc('
saves the current trace into two files:
\\argument{FileTemplate}\\texttt{.csv} and \\texttt{.plot}.
'),
export_plot(FileTemplate, []).
get_plot_driver(Driver) :-
nb_getval(plot_driver, Driver).
export_plot_to_png(OutputFile) :-
biocham_command,
type(OutputFile, output_file),
doc('plots the current trace in a PNG file'),
export_plot(plot, [png(OutputFile)]),
execute_plot(['plot.plot']).
export_plot_to_canvas(OutputFile, BaseOutputFile) :-
biocham_command,
type(OutputFile, output_file),
type(BaseOutputFile, output_file),
doc('plots the current trace as a canvas element in an HTML file'),
export_plot(plot, [canvas(OutputFile, BaseOutputFile)]),
execute_plot(['plot.plot']).
:- devdoc('\\section{Public API}').
set_plot_driver(Driver) :-
......@@ -30,6 +70,13 @@ gnu_plot :-
execute_plot(['-persist', 'plot.plot']).
:- devdoc('\\section{Private predicates}').
get_plot_driver(Driver) :-
nb_getval(plot_driver, Driver).
gnu_plot_png :-
count(plot_png, Index),
format(atom(Filename), 'plot~d.png', [Index]),
......@@ -56,31 +103,6 @@ execute_plot(Options) :-
process_create(path(gnuplot), Options, []).
export_plot(FileTemplate) :-
biocham_command,
doc('
saves the current trace into two files:
\\argument{FileTemplate}\\texttt{.csv} and \\texttt{.plot}.
'),
export_plot(FileTemplate, []).
export_plot_to_png(OutputFile) :-
biocham_command,
type(OutputFile, output_file),
doc('plots the current trace in a PNG file'),
export_plot(plot, [png(OutputFile)]),
execute_plot(['plot.plot']).
export_plot_to_canvas(OutputFile, BaseOutputFile) :-
biocham_command,
type(OutputFile, output_file),
doc('plots the current trace as a canvas element in an HTML file'),
export_plot(plot, [canvas(OutputFile, BaseOutputFile)]),
execute_plot(['plot.plot']).
export_plot(FileTemplate, Options) :-
format(atom(PlotFile), '~a.plot', [FileTemplate]),
format(atom(CsvFile), '~a.csv', [FileTemplate]),
......
......@@ -38,7 +38,7 @@
** Listing and editing reactions, influences and events
*** Reactions
- reaction_editor.pl
*** Influences...
*** Influences
- influence_editor.pl
*** Events
- events.pl
......
......@@ -3,6 +3,7 @@
[
% Commands
quit/0,
list_options/0,
% Public API
toplevel/0,
command/1,
......@@ -11,7 +12,8 @@
set_prompt/1,
option/4,
set_option/2,
set_options/1
set_options/1,
list_model_options/0
]).
......@@ -24,6 +26,34 @@ quit :-
halt.
:- doc('
Some commands (e.g., \\command{numerical_simulation/1}) take named options
as arguments.
All the options can either be defined either locally for a single command or
globally for the whole model.
Options can be defined for a single command
by adding additional arguments of the form \\texttt{Option: Value}.
\\begin{example}
').
:- biocham_silent(clear_model).
:- biocham(a -> b).
:- biocham(a -< a).
:- biocham(present(a)).
:- biocham(numerical_simulation(20, method: msbdf)).
:- biocham(plot).
:- doc('
\\end{example}
Options can be defined globally for the model with the command
\\texttt{option(Option: Value, ..., Option: Value)}.
Local options take precedence over global options.
').
list_options :-
biocham_command,
doc('lists the set of options defined in the current model.'),
list_items([kind: option]).
:- devdoc('\\section{Public API}').
......@@ -160,6 +190,35 @@ set_options(List) :-
).
list_model_options :-
devdoc('
lists all the options in a loadable syntax
(auxiliary predicate of list_model).
'),
(
item([no_inheritance, kind: option])
->
write('option(\n'),
assertz(first),
\+ (
item([kind: option, item: option(Option: Value)]),
\+ (
(
retract(first)
->
true
;
write(',\n')
),
format(' ~w: ~w', [Option, Value])
)
),
write('\n).\n')
;
true
).
:- devdoc('\\section{Private predicates}').
......@@ -223,7 +282,13 @@ check_options(Options, CommandOptions) :-
member(option(Option, Type, _Doc), CommandOptions)
->
check_type_with_error(Type, UntypedValue, Value),
assertz(local_option(Option, Value))
(
local_option(Option, _)
->
throw(error(option_defined_twice(Option), check_options))
;
assertz(local_option(Option, Value))
)
;
throw(error(option_not_applicable(Option), check_options))
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment