diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 00000000..4e316eec --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,53 @@ +# dingo : a python library for metabolic networks sampling and analysis +# dingo is part of GeomScale project + +# Copyright (c) 2021 Vissarion Fisikopoulos + +# Licensed under GNU LGPL.3, see LICENCE file + +name: dingo-ubuntu + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + #python-version: [2.7, 3.5, 3.6, 3.7, 3.8] + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Load submodules + run: | + git submodule update --init; + - name: Download and unzip the boost library + run: | + wget -O boost_1_76_0.tar.bz2 https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2; + tar xjf boost_1_76_0.tar.bz2; + rm boost_1_76_0.tar.bz2; + - name: Install dependencies + run: | + sudo apt-get install libsuitesparse-dev; + curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -; + source $HOME/.poetry/env; + export POETRY_VIRTUALENVS_PATH=/home/runner/.cache/pypoetry/virtualenvs + poetry config virtualenvs.create false --local + #source $(dirname $(poetry run which python))/activate + poetry install; + #pip3 install numpy scipy; + - name: Run tests + run: | + #python3 tests/fba.py; + #python3 tests/full_dimensional.py; + python3 tests/max_ball.py; + #python3 tests/scaling.py; + #run all tests + #python -m unittest discover test + #TODO: use pytest diff --git a/README.md b/README.md index 189f4250..1e22ea6f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,18 @@ # dingo -dingo is a python package that analyzes metabolic networks. It relies on high dimensional sampling with Markov Chain Monte Carlo (MCMC) methods and fast optimization methods to analyze the possible states of a metabolic network. To perform MCMC sampling, dingo relies on the C++ package [volesti](https://github.com/GeomScale/volume_approximation), which provides several algorithms for sampling convex polytopes. dingo is part of [GeomScale](https://geomscale.github.io/) project. - -dingo also performs two standard methods to analyze the flux space of a metabolic network, namely Flux Balance Analysis and Flux Variability Analysis. - - +`dingo` is a python package that analyzes metabolic networks. +It relies on high dimensional sampling with Markov Chain Monte Carlo (MCMC) +methods and fast optimization methods to analyze the possible states of a +metabolic network. To perform MCMC sampling, `dingo` relies on the `C++` package +[volesti](https://github.com/GeomScale/volume_approximation), which provides +several algorithms for sampling convex polytopes. +`dingo` also performs two standard methods to analyze the flux space of a +metabolic network, namely Flux Balance Analysis and Flux Variability Analysis. + +`dingo` is part of [GeomScale](https://geomscale.github.io/) project. + +[![unit-tests](https://github.com/GeomScale/dingo/workflows/dingo-ubuntu/badge.svg)](https://github.com/GeomScale/dingo/actions?query=workflow%3Adingo-ubuntu) +[![Chat](https://badges.gitter.im/boostorg/geometry.png)](https://gitter.im/GeomScale/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link) ## Installation diff --git a/tests/fba.py b/tests/fba.py new file mode 100644 index 00000000..ab0981eb --- /dev/null +++ b/tests/fba.py @@ -0,0 +1,32 @@ +# dingo : a python library for metabolic networks sampling and analysis +# dingo is part of GeomScale project + +# Copyright (c) 2021 Apostolos Chalkis + +# Licensed under GNU LGPL.3, see LICENCE file + +import unittest +import os +import scipy +import numpy as np +from dingo import MetabolicNetwork, PolytopeSampler +from dingo.inner_ball import slow_inner_ball +from dingo.scaling import gmscale + + +class TestFba(unittest.TestCase): + + def test_ecoli(self): + + current_directory = os.getcwd() + input_file_json = current_directory + "/ext_data/e_coli_core.json" + + model = MetabolicNetwork.from_json(input_file_json) + model.set_slow_mode() + + res = model.fba() + + self.assertTrue(abs(res[1] - 0.8739215067486387) < 1e-03) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/full_dimensional.py b/tests/full_dimensional.py new file mode 100644 index 00000000..17ca4e1c --- /dev/null +++ b/tests/full_dimensional.py @@ -0,0 +1,34 @@ +# dingo : a python library for metabolic networks sampling and analysis +# dingo is part of GeomScale project + +# Copyright (c) 2021 Apostolos Chalkis +# Copyright (c) 2021 Vissarion Fisikopoulos + +# Licensed under GNU LGPL.3, see LICENCE file + +import unittest +import os +import scipy +import numpy as np +from dingo import MetabolicNetwork, PolytopeSampler +from dingo.inner_ball import slow_inner_ball +from dingo.scaling import gmscale + + +class TestFullDim(unittest.TestCase): + + def test_ecoli(self): + + current_directory = os.getcwd() + input_file_json = current_directory + "/ext_data/e_coli_core.json" + + model = MetabolicNetwork.from_json(input_file_json) + sampler = PolytopeSampler(model) + sampler.set_slow_mode() + sampler.get_polytope() + + self.assertEqual(sampler.A.shape[0], 175) + self.assertEqual(sampler.A.shape[1], 24) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/max_ball.py b/tests/max_ball.py new file mode 100644 index 00000000..cd403e2f --- /dev/null +++ b/tests/max_ball.py @@ -0,0 +1,33 @@ +# dingo : a python library for metabolic networks sampling and analysis +# dingo is part of GeomScale project + +# Copyright (c) 2021 Apostolos Chalkis +# Copyright (c) 2021 Vissarion Fisikopoulos + +# Licensed under GNU LGPL.3, see LICENCE file + +import unittest +import os +import scipy +import numpy as np +from dingo import MetabolicNetwork, PolytopeSampler +from dingo.inner_ball import slow_inner_ball +from dingo.scaling import gmscale + + +class TestMaxBall(unittest.TestCase): + + def test_simple(self): + m = 2 + n = 5 + A = np.zeros((2 * n, n), dtype="float") + A[0:n] = np.eye(n) + A[n:] -= np.eye(n, n, dtype="float") + b = np.ones(2 * n, dtype="float") + + max_ball = slow_inner_ball(A, b) + + self.assertTrue(abs(max_ball[1] - 1) < 1e-04) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/scaling.py b/tests/scaling.py new file mode 100644 index 00000000..4d85e74e --- /dev/null +++ b/tests/scaling.py @@ -0,0 +1,33 @@ +# dingo : a python library for metabolic networks sampling and analysis +# dingo is part of GeomScale project + +# Copyright (c) 2021 Apostolos Chalkis +# Copyright (c) 2021 Vissarion Fisikopoulos + +# Licensed under GNU LGPL.3, see LICENCE file + +import unittest +import os +import scipy +import numpy as np +from dingo import MetabolicNetwork, PolytopeSampler +from dingo.inner_ball import slow_inner_ball +from dingo.scaling import gmscale + + +class TestScaling(unittest.TestCase): + + def test_ecoli(self): + + current_directory = os.getcwd() + input_file_json = current_directory + "/ext_data/e_coli_core.json" + + model = MetabolicNetwork.from_json(input_file_json) + + res = gmscale(model.S, 0.99) + + self.assertTrue(abs(scipy.linalg.norm(res[0]) - 15.285577732002883) < 1e-03) + self.assertTrue(abs(scipy.linalg.norm(res[1]) - 23.138373030721855) < 1e-03) + +if __name__ == "__main__": + unittest.main()