Commit eb7a836e authored by HEMERY Mathieu's avatar HEMERY Mathieu
Browse files

Rewrite and comment the convert_into_hybrid stuff

parent 784bcc96
......@@ -342,7 +342,9 @@ build_reactants([Species|SpTail], ODESpecies, [Reactant|ReacTail]) :-
build_reactants(SpTail, ODESpecies, ReacTail).
% write_hybrid_ode(+Stream, +Hybrid_list)
%! write_hybrid_ode(+Stream, +Hybrid_list)
%
% write the ode model in the output file
write_hybrid_ode(Stream, Hybrid_original_list) :-
list_hybrid_ode(Stream, Hybrid_original_list),
......@@ -351,6 +353,10 @@ write_hybrid_ode(Stream, Hybrid_original_list) :-
with_output_to(Stream, models:list_model_events),
with_output_to(Stream, models:list_model_macros(function)).
%! list_hybrid_ode(+Stream, +Hybrid_original_list)
%
%
list_hybrid_ode(Stream,Hybrid_original_list) :- % Only MA are converted, need to do others
all_items([kind: reaction], Reactions),
forall(
......@@ -375,10 +381,14 @@ list_hybrid_ode(Stream,Hybrid_original_list) :- % Only MA are converted, need to
/* Can try to get the kinetics function in BIOCHAM 4 directly and translate, but i didn't know how
Also can direclty adapt the kinetics with the hybrid species list, but need to translate the kinetics first if needed */
%! convert_MA()
%
%
convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
reaction(Reaction, [kinetics: Kinetics,reactants: Reactants,inhibitors: _, products: _]),
Kinetics =.. ['MA',K],
kinetics:eval_kinetics(Reactants, _, product('S'*'M' in [reactants], 'M'^'S'), Value),
kinetics:eval_kinetics(Reactants, _, product(in('S'*'M', [reactants]), 'M'^'S'), Value),
convert_into_hybrid(Value,Hybrid_original_list,NewValue),!,
(
nb_current(dynamic_parameters,_)
......@@ -393,42 +403,41 @@ convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
NewKinetics = K * NewValue
).
convert_into_hybrid(Value * 1, ODESpecies,NewValue) :-
convert_into_hybrid(Value,ODESpecies,NewValue).
convert_into_hybrid(Value ^ 1, ODESpecies,NewValue) :-
convert_into_hybrid(Value,ODESpecies,NewValue).
%! convert_into_hybrid(+Rate, +List_species, -NewRate)
%
% Rewrite the reaction rate using the species_total function
convert_into_hybrid(Value * 1, List_species, NewValue) :-
convert_into_hybrid(Value, List_species, NewValue).
convert_into_hybrid(Value ^ 1, List_species, NewValue) :-
convert_into_hybrid(Value, List_species, NewValue).
convert_into_hybrid(Value1 * Value2, Hybrid_original_list,NewValue1 * NewValue2) :-
convert_into_hybrid(Value1,Hybrid_original_list,NewValue1),
convert_into_hybrid(Value2,Hybrid_original_list,NewValue2).
convert_into_hybrid(Value1 * Value2, List_species, NewValue1 * NewValue2) :-
convert_into_hybrid(Value1, List_species, NewValue1),
convert_into_hybrid(Value2, List_species, NewValue2).
convert_into_hybrid(Value1 ^ Value2, Hybrid_original_list,NewValue1 ^ NewValue2) :-
convert_into_hybrid(Value1,Hybrid_original_list,NewValue1),
convert_into_hybrid(Value2,Hybrid_original_list,NewValue2).
convert_into_hybrid(Value1 ^ Value2, List_species, NewValue1 ^ NewValue2) :-
convert_into_hybrid(Value1, List_species, NewValue1),
convert_into_hybrid(Value2, List_species, NewValue2).
convert_into_hybrid(Number,_,Number) :-
convert_into_hybrid(Number, _, Number) :-
number(Number),
!.
convert_into_hybrid(Molecule,Hybrid_original_list,Molecule) :-
\+(member(Molecule,Hybrid_original_list)),
convert_into_hybrid(Molecule, List_species, Molecule) :-
\+(member(Molecule, List_species)),
!.
convert_into_hybrid(Molecule,Hybrid_original_list,HybridMolecule) :-
convert_into_hybrid(Molecule, List_species, HybridMolecule) :-
get_option(stochastic_conversion, Rate),
nb_getval(volume,Volume),
member(Molecule,Hybrid_original_list),
species_to_total(Molecule, Molecule_total),
atom_concat('(',Molecule_total,Molecule1),
atom_concat(Molecule1,'/(',Molecule2),
atom_concat(Molecule2,Rate,Molecule3),
atom_concat(Molecule3,'*',Molecule4),
atom_concat(Molecule4,Volume,Molecule5),
atom_concat(Molecule5,'))',HybridMolecule),
atomic_list_concat(['(',Molecule_total,'/(',Rate,'*',Volume,'))'], HybridMolecule),
!.
prepare_change_list(Reactions2,ODESpecies,List) :- % Only MA are converted, need to do others
findall([Reactants,Products,Kinetics],
(
......@@ -470,6 +479,7 @@ convert_into_hybrid2(Number,_,Number) :-
number(Number),
!.
% this is the part that differentiate it from convert_into_hybrid
convert_into_hybrid2(Molecule,ODESpecies,StochMolecule) :-
\+(member(Molecule,ODESpecies)),
species_to_stoch(Molecule,StochMolecule),
......
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