Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-dfba-sampling
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SLIMMEST
python-dfba-sampling
Commits
3248158c
Commit
3248158c
authored
2 months ago
by
Simon Labarthe
Browse files
Options
Downloads
Plain Diff
conflict resolved
parents
d2a0d0dc
ab8fdeea
No related branches found
No related tags found
No related merge requests found
Pipeline
#1178731
passed with warnings
2 months ago
Stage: test
Stage: quality
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-0
2 additions, 0 deletions
.gitlab-ci.yml
src/dfba_sampling/metamodel.py
+27
-16
27 additions, 16 deletions
src/dfba_sampling/metamodel.py
with
29 additions
and
16 deletions
.gitlab-ci.yml
+
2
−
0
View file @
3248158c
...
...
@@ -32,6 +32,8 @@ check:
test
:
stage
:
test
script
:
-
python3 -m pip install cmake --user
-
python3 -m pip install swig --user
-
tox -e clean,py38,report
artifacts
:
reports
:
...
...
This diff is collapsed.
Click to expand it.
src/dfba_sampling/metamodel.py
+
27
−
16
View file @
3248158c
...
...
@@ -175,7 +175,7 @@ class Metamodel(object):
index_col
=
None
,
exp
=
None
,
metamodel_config
=
None
,
relative_path
=
'
./
'
,
relative_path
=
"
./
"
,
):
self
.
kernel_type
=
kernel_type
self
.
bact
=
bact
...
...
@@ -201,10 +201,11 @@ class Metamodel(object):
"
selected_hyperparameters
"
in
self
.
metamodel_yml
.
keys
()
and
"
identity
"
in
self
.
metamodel_yml
[
"
selected_hyperparameters
"
]
):
tmp_path
=
relative_path
+
self
.
metamodel_yml
[
"
selected_hyperparameters
"
][
"
identity
"
]
with
open
(
tmp_path
,
"
r
"
)
as
file
:
# Load the user parameter yml
tmp_path
=
(
relative_path
+
self
.
metamodel_yml
[
"
selected_hyperparameters
"
][
"
identity
"
]
)
with
open
(
tmp_path
,
"
r
"
)
as
file
:
# Load the user parameter yml
identity
=
yaml
.
safe_load
(
file
)
for
spec
in
identity
:
self
.
metamodel_yml
[
spec
][
"
identity
"
]
=
identity
[
spec
]
...
...
@@ -239,14 +240,15 @@ class Metamodel(object):
]
self
.
C_learn
=
self
.
C_learn
[
col_subset
]
self
.
constraint_ID_in_Y
=
np
.
array
([
self
.
exp
.
y_id
(
i
)
for
i
in
col_subset
])
if
(
self
.
metamodel_yml
is
not
None
if
(
self
.
metamodel_yml
is
not
None
and
"
selected_hyperparameters
"
in
self
.
metamodel_yml
.
keys
()
and
"
identity
"
in
self
.
metamodel_yml
[
"
selected_hyperparameters
"
]
):
self
.
constraint_Id_in_Y_identity
=
[
self
.
exp
.
y_id
(
comp
)
for
comp
in
self
.
metamodel_yml
[
self
.
bact
][
"
identity
"
]
]
self
.
exp
.
y_id
(
comp
)
for
comp
in
self
.
metamodel_yml
[
self
.
bact
][
"
identity
"
]
]
else
:
self
.
constraint_ID_in_Y
=
np
.
arange
(
self
.
C_learn
.
shape
[
1
])
self
.
substrate_metabolites
=
list
(
self
.
C_learn
.
columns
)
...
...
@@ -315,14 +317,15 @@ class Metamodel(object):
]
self
.
Flux_learn
=
self
.
Flux_learn
[
col_subset
]
self
.
Flux_ID_in_Y
=
np
.
array
([
self
.
exp
.
y_id
(
i
)
for
i
in
col_subset
])
if
(
self
.
metamodel_yml
is
not
None
if
(
self
.
metamodel_yml
is
not
None
and
"
selected_hyperparameters
"
in
self
.
metamodel_yml
.
keys
()
and
"
identity
"
in
self
.
metamodel_yml
[
"
selected_hyperparameters
"
]
):
self
.
Flux_Id_in_output_identity
=
[
col_subset
.
index
(
comp
)
for
comp
in
self
.
metamodel_yml
[
self
.
bact
][
"
identity
"
]
]
col_subset
.
index
(
comp
)
for
comp
in
self
.
metamodel_yml
[
self
.
bact
][
"
identity
"
]
]
else
:
self
.
Flux_ID_in_Y
=
np
.
arange
(
self
.
Flux_learn
.
shape
[
1
])
self
.
compound_name
=
list
(
self
.
Flux_learn
.
columns
)
...
...
@@ -608,18 +611,26 @@ class Metamodel(object):
)
if
self
.
Scaler_fluxes_flag
!=
"
None
"
:
output
=
self
.
Scaler_fluxes
.
inverse_transform
(
output
)
if
(
self
.
metamodel_yml
is
not
None
if
(
self
.
metamodel_yml
is
not
None
and
"
selected_hyperparameters
"
in
self
.
metamodel_yml
.
keys
()
and
"
identity
"
in
self
.
metamodel_yml
[
"
selected_hyperparameters
"
]
):
output
[:,
self
.
Flux_Id_in_output_identity
]
=
c_in
[:,
self
.
constraint_Id_in_Y_identity
]
output
[:,
self
.
Flux_Id_in_output_identity
]
=
c_in
[
:,
self
.
constraint_Id_in_Y_identity
]
output
=
output
.
clip
(
self
.
Clipping
.
data_min_
,
self
.
Clipping
.
data_max_
,
)
else
:
output
=
0.0
output_y0
[:,
self
.
Flux_ID_in_Y
]
=
output
output_y0
[:,
self
.
Flux_ID_in_Y
]
=
output
# clipping by constraint c_in since output cannot be lower than c_in input by definition of FBA constraints
# output_y0 is ordered as Y.
tmp_output_for_constraints
=
output_y0
[:,
self
.
constraint_ID_in_Y
]
tmp_output_for_constraints
=
np
.
maximum
(
tmp_output_for_constraints
,
c
)
output_y0
[:,
self
.
constraint_ID_in_Y
]
=
tmp_output_for_constraints
return
output_y0
def
Gram_matrix_sqrt
(
self
,
eps
=
1e-8
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment