Skip to content

Commit

Permalink
Add github actions (GeomScale#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
vissarion authored May 18, 2021
1 parent bc6fa3b commit a7e980e
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 5 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
32 changes: 32 additions & 0 deletions tests/fba.py
Original file line number Diff line number Diff line change
@@ -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()
34 changes: 34 additions & 0 deletions tests/full_dimensional.py
Original file line number Diff line number Diff line change
@@ -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()
33 changes: 33 additions & 0 deletions tests/max_ball.py
Original file line number Diff line number Diff line change
@@ -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()
33 changes: 33 additions & 0 deletions tests/scaling.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit a7e980e

Please sign in to comment.