Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cobrapy-samples
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Egor Makarenko
cobrapy-samples
Commits
224fd7f4
Unverified
Commit
224fd7f4
authored
Oct 18, 2019
by
Egor Makarenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add COBRApy sample code
parents
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
.gitignore
.gitignore
+3
-0
install.sh
install.sh
+4
-0
run.py
run.py
+40
-0
No files found.
.gitignore
0 → 100644
View file @
224fd7f4
.idea/*
!.idea/runConfigurations/
venv/
install.sh
0 → 100644
View file @
224fd7f4
pip
install
git+https://github.com/shjchan/cobrapy.git@implement_find_act_rxns
pip
install
lxml
pip
install
scipy
\ No newline at end of file
run.py
0 → 100644
View file @
224fd7f4
#!/usr/bin/env python3
# coding: utf-8
from
argparse
import
ArgumentParser
from
os
import
path
,
mkdir
from
timeit
import
default_timer
as
timer
from
cobra.flux_analysis
import
flux_variability_analysis
,
add_loopless
from
cobra.io
import
read_sbml_model
parser
=
ArgumentParser
(
description
=
"FVA Solver"
)
parser
.
add_argument
(
"--model"
,
help
=
"SBML file with the model"
)
parser
.
add_argument
(
"--method"
,
help
=
"Loop removal method"
,
default
=
"fastSNP"
)
args
=
parser
.
parse_args
()
workdir
=
f"instances/
{
args
.
model
}
/"
outdir
=
path
.
join
(
workdir
,
"output"
)
if
not
path
.
exists
(
outdir
):
mkdir
(
outdir
)
file
=
path
.
join
(
workdir
,
f"
{
args
.
model
}
.xml"
)
model
=
read_sbml_model
(
file
)
model
.
solver
=
"cplex"
# model.objective = "FRD7"
print
(
f"Number of reactions:
{
len
(
model
.
reactions
)
}
"
)
print
(
f"Number of metabolites:
{
len
(
model
.
metabolites
)
}
"
)
time
=
timer
()
add_loopless
(
model
,
zero_cutoff
=
1E-6
,
method
=
args
.
method
)
fba
=
model
.
optimize
(
raise_error
=
True
)
time
=
timer
()
-
time
print
(
f"Time:
{
time
}
"
)
print
(
f"FBA objective:
{
fba
.
objective_value
}
"
)
fba
.
fluxes
.
to_csv
(
path
.
join
(
outdir
,
f"cobrapy-fba-
{
args
.
method
}
.tsv"
),
sep
=
'
\t
'
,
header
=
True
)
for
optimum
in
[
0.0
,
1.0
]:
fva
=
flux_variability_analysis
(
model
,
model
.
reactions
,
loopless
=
False
,
fraction_of_optimum
=
optimum
)
outfile
=
path
.
join
(
outdir
,
f"cobrapy-fva-
{
args
.
method
}
-opt
{
optimum
}
.tsv"
)
fva
.
to_csv
(
outfile
,
sep
=
'
\t
'
,
encoding
=
"utf-8"
,
float_format
=
"%.10f"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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