Commit b36ec00b authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Improve modifiers handling

parent 0830802c
......@@ -149,12 +149,56 @@ add_inhibitors([Head|Tail], Reaction, NewReaction) :-
models:formal_inhibitor(Head, Reaction),
!,
add_inhibitors(Tail, Reaction, NewReaction).
add_inhibitors([Head|Tail], Reactants => Products, NewReactants => Products) :-
add_inhibitors(Tail, Reactants => Products, NReactants => Products),
add_inhibitors([Head|Tail], Reactants => Products, NewReactants => NProducts) :-
add_inhibitors(Tail, Reactants => Products, ReactantsTempo => ProductsTempo),
(
remove_molecule(ReactantsTempo, Head, NReactants),
remove_molecule(ProductsTempo, Head, NProducts)
;
NReactants = ReactantsTempo,
NProducts = ProductsTempo
),
(
NReactants = Reac / Inhib
->
NewReactants = Reac / (Head,Inhib)
;
NewReactants = Reactants / Head
NewReactants = NReactants / Head
).
% remove_molecule(Species, Molecule, Without)
remove_molecule(Molecule, Molecule, '_') :- !.
remove_molecule(P*Molecule, Molecule, Result) :-
(
P = 1
->
Result = '_'
;
P = 2
->
Result = Molecule
;
Pm is P-1,
Result = Pm*Molecule
),!.
remove_molecule(Species+Molecule, Molecule, Species) :- !.
remove_molecule(Species+P*Molecule, Molecule, Result) :-
(
P = 1
->
Result = Species
;
P = 2
->
Result = Species+Molecule
;
Pm is P-1,
Result = Species+Pm*Molecule
),!.
remove_molecule(Molecule+Other, Molecule, Result) :- !,
remove_molecule(Other+Molecule, Molecule, Result).
remove_molecule(P*Molecule+Other, Molecule, Result) :- !,
remove_molecule(Other+P*Molecule, Molecule, Result).
remove_molecule(Species+Other, Molecule, Without+Other) :-
remove_molecule(Species, Molecule, Without).
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