Commit 0018af7d authored by FAGES Francois's avatar FAGES Francois
parents c7008174 1ff94d9d
......@@ -30,8 +30,10 @@ filename(Filename, ExpandedFilename) :-
library_path(LibraryPath),
Options = [relative_to(LibraryPath)]
;
Options = [],
SubFilename = Filename
SubFilename = Filename,
%Options = [], !bugwar: relative_to(Dir)!
working_directory(Dir, Dir),
Options = [relative_to(Dir)]
),
absolute_file_name(SubFilename, ExpandedFilename, [expand(true) | Options]).
......
......@@ -173,6 +173,10 @@ convert_expression(- A, - AIndexed) :-
!,
convert_expression(A, AIndexed).
convert_expression([A], - AIndexed) :-
!,
convert_expression(A, AIndexed).
convert_expression(A + B, AIndexed + BIndexed) :-
!,
convert_expression(A, AIndexed),
......
......@@ -219,5 +219,3 @@ reserved('EX').
reserved('xor').
reserved('R').
......@@ -3,7 +3,8 @@
[
list_ODE/0,
compute_ode/0,
ode/2
ode/2,
load_ode/1
]).
:- dynamic(ode/2).
......@@ -79,3 +80,40 @@ print_ode :-
format('~f \td[~w]/dt=~w\n', [InitialConcentration, Molecule, Equation])
)
).
load_ode(InputFile) :-
biocham_command,
type(InputFile, input_file),
doc('
creates a new Biocham model (reaction rules, initial state, parameters and
macros) inferred from an xppaut .ode file (preferably written with
parameters).
'),
external_convert_ode(InputFile, 'external_ode.bc'),
load_biocham('external_ode.bc').
add_ode(InputFile) :-
biocham_command,
type(InputFile, input_file),
doc('
adds reaction rules, initial state, parameters and
macros inferred from an xppaut .ode file (preferably written with
parameters).
'),
external_convert_ode(InputFile, 'external_ode.bc'),
add_biocham('external_ode.bc').
external_convert_ode(InputFile, OutputFile) :-
setup_call_cleanup(
open('external_load_ode.bc', write, Ode_bc),
(
portray_clause(Ode_bc, load_ode(InputFile)),
portray_clause(Ode_bc, export_biocham(OutputFile)),
portray_clause(Ode_bc, 'quit')
),
close(Ode_bc)
),
call_subprocess(path(biocham), ['external_load_ode.bc'], [stdout(pipe(_))]).
......@@ -13,4 +13,21 @@ test('compute_ode', [true(ODEs == [ode(b, a), ode(a, -a)])]) :-
ODEs).
test('load_ode', [true(Reactions = [[a] for a => b])]) :-
clear_model,
setup_call_cleanup(
open('test.ode', write, TestOde),
write(TestOde, '
init a = 0
init b = 0
da/dt = -a
db/dt = a
done
'),
close(TestOde)
),
load_ode('test.ode'),
all_items([kind: reaction], Reactions).
:- end_tests(ode).
......@@ -64,8 +64,9 @@ export_plot(FileTemplate, Options) :-
export_table(CsvFile),
get_table_data([HeaderRow | _ ]),
HeaderRow =.. [row, _TimeHeader | Headers],
absolute_file_name(PlotFile, AbsolutePlotFile),
setup_call_cleanup(
open(PlotFile, write, Stream),
open(AbsolutePlotFile, write, Stream),
export_plot_stream(Stream, CsvFile, Headers, Options),
close(Stream)
).
......
......@@ -117,6 +117,10 @@ kinetics((SimpleKinetics0, SimpleKinetics1)) :-
:- grammar(simple_kinetics).
simple_kinetics([A]) :-
simple_kinetics(A).
simple_kinetics(SimpleKinetics0 + SimpleKinetics1) :-
simple_kinetics(SimpleKinetics0),
simple_kinetics(SimpleKinetics1).
......
......@@ -74,7 +74,9 @@ export_table(OutputFile) :-
TitleRow =.. [row | ColumnNames],
Table = [TitleRow | Data]
),
csv_write_file(FilenameCsv, Table).
working_directory(Dir, Dir),
absolute_file_name(FilenameCsv, AbsoluteFilenameCsv, [relative_to(Dir)]),
csv_write_file(AbsoluteFilenameCsv, Table).
list_tables :-
......
A <=> B.
list_ODE.
numerical_simulation.
quit.
\ No newline at end of file
% BIOCHAM model file
% Reaction rules
[a] for a=>b.
% Initial state
absent(a).
absent(b).
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