Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lifeware
biocham
Commits
ff0b45ba
Commit
ff0b45ba
authored
Nov 21, 2019
by
HEMERY Mathieu
Browse files
Rewrite print_constraint and concat_species
parent
a3497ba4
Changes
1
Hide whitespace changes
Inline
Side-by-side
hybrid.pl
View file @
ff0b45ba
...
...
@@ -730,67 +730,44 @@ print_if_then_else([[Lower, Upper], Change, Constraint | Change_Tail], Stream) :
print_if_then_else
(
Change_Tail
,
Stream
).
print_single_reaction_constraints
(
Constraint
s
,
Total
,
Curren
t
,
Stream
)
:-
(
Current
<
Total
->
nth1
(
Current
,
Constraints
,
To_print
),
write
(
Stream
,
To_print
),
write
(
Stream
,
'
and
'
),
Next
is
Current
+
1
,
print_single_reaction_constraints
(
Constraints
,
Total
,
Next
,
Stream
)
;
nth1
(
Current
,
Constraints
,
To_print
),
write
(
Stream
,
To_print
),
!
).
%!
print_single_reaction_constraints(Constraint
_lis
t, Stream)
print_single_reaction_constraints
([
To_print
],
Stream
)
:-
format
(
Stream
,
"~w"
,
[
To_print
]),
!.
print_single_reaction_constraints
([
To_print
|
Tail
],
Stream
)
:-
format
(
Stream
,
"~w
and
"
,
[
To_print
]
),
print_single_reaction_constraints
(
Tail
,
Stream
).
%! print_hybrid_species_constraint(Hybrid_reactants_list, Stream)
print_hybrid_species_constraint
(
Constraints_list
,
Stream
)
:-
print_hybrid_species_constraint
(
Constraints_list
,
1
,
Stream
).
print_hybrid_species_constraint
(
Hybrid_reactants_list
,
Current_counter
,
Stream
)
:-
length
(
Hybrid_reactants_list
,
Total_count
),
nth1
(
Current_counter
,
Hybrid_reactants_list
,
This_reaction_constraints
),
length
(
This_reaction_constraints
,
Number_of_constraints
),
print_hybrid_species_constraint
([],
_Counter
,
_Stream
).
print_hybrid_species_constraint
([
Constraints
|
Tail
],
Counter
,
Stream
)
:-
(
This_reaction_c
onstraints
\
==
[
0
]
C
onstraints
\
==
[
0
]
->
write
(
Stream
,
' lower_level'
),
write
(
Stream
,
Current_counter
),
write
(
Stream
,
' = (if '
),
print_single_reaction_constraints
(
This_reaction_constraints
,
Number_of_constraints
,
1
,
Stream
),
write
(
Stream
,
' then 1 else 0),'
),
nl
(
Stream
)
format
(
Stream
,
" lower_level~w = (if "
,
[
Counter
]),
print_single_reaction_constraints
(
Constraints
,
Stream
),
format
(
Stream
,
" then 1 else 0),~n"
,
[])
;
!
!
),
(
Current_counter
<
Total_count
->
Next_counter
is
Current_counter
+
1
,
print_hybrid_species_constraint
(
Hybrid_reactants_list
,
Next_counter
,
Stream
)
;
!
).
Counterp
is
Counter
+
1
,
print_hybrid_species_constraint
(
Tail
,
Counterp
,
Stream
).
concat_species
(
Species
,
Count
,
Init
,
Results
)
:-
length
(
Species
,
L
),
(
Count
=<
L
->
nth1
(
Count
,
Species
,
Species1
),
species_to_total
(
Species1
,
Species1_processed
),
atom_concat
(
', '
,
Species1_processed
,
Species2_processed
),
atom_concat
(
Init
,
Species2_processed
,
NewSubstring
),
Next_count
is
Count
+
1
,
concat_species
(
Species
,
Next_count
,
NewSubstring
,
Results
)
;
Init
=
Results
).
concat_species
([
Sp
|
Sp_tail
],
Result
)
:-
species_to_total
(
Sp
,
Sp_tot
),
foldl
(
concat_species_sr
,
Sp_tail
,
Sp_tot
,
Result
).
concat_species2
(
Species
,
Init
,
Results
)
:-
nth1
(
1
,
Species
,
First
),
species_to_total
(
First
,
First1
),
atom_concat
(
Init
,
First1
,
Newsubstring
),
concat_species
(
Species
,
2
,
Newsubstring
,
Results
).
concat_species_sr
(
Sp
,
Acc
,
Accn
)
:-
species_to_total
(
Sp
,
Sp_tot
),
atomic_list_concat
([
Acc
,
', '
,
Sp_tot
],
Accn
).
print_show_option
(
Hybrid_original_list
,
Stream
)
:-
(
...
...
@@ -798,7 +775,7 @@ print_show_option(Hybrid_original_list,Stream) :-
->
write
(
Stream
,
'%option(show: {}).'
),
nl
(
Stream
)
;
concat_species
2
(
Hybrid_original_list
,
''
,
SpeciesList
),
concat_species
(
Hybrid_original_list
,
SpeciesList
),
write
(
Stream
,
'option(show: {'
),
write
(
Stream
,
SpeciesList
),
write
(
Stream
,
'}). % Choose here the species to plot'
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment