-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposed two HMC walks with exponential and Gaussian sampling from Vol…
…esti (#68) * Exposed two HMC exact walks with exponential and Gaussian sampling from Volesti * Modified the parameters used to call the Gaussian and exponential HMC walks in bindings. Added tests to check they work as expected * Implemented variance and bias vector as user-defined parameters * Deleted redundant bias_vector_final and added sampling tests to workflow * Excluded sampling.py from github actions * modified sampling_no_multiphase.py to investigate the error in the github actions * modified sampling_no_multiphase.py to investigate the error in the github actions associated to the mean * Changed sampling.py to check with github actions * Modified sampling_no_multiphase.py to account for the behaviour of the mean. Now it checks if the size of the matrix steady_states is correct * Changed variance of exponential distribution to 50 in sampling_no_multiphase.py * Changed n to 500 in sampling_no_multiphase.py
- Loading branch information
Showing
7 changed files
with
145 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# dingo : a python library for metabolic networks sampling and analysis | ||
# dingo is part of GeomScale project | ||
|
||
# Copyright (c) 2022 Apostolos Chalkis | ||
# Copyright (c) 2022 Vissarion Fisikopoulos | ||
# Copyright (c) 2022 Haris Zafeiropoulos | ||
|
||
# Licensed under GNU LGPL.3, see LICENCE file | ||
|
||
import unittest | ||
import os | ||
from dingo import MetabolicNetwork, PolytopeSampler | ||
|
||
|
||
class TestSampling(unittest.TestCase): | ||
|
||
def test_sample_json(self): | ||
|
||
input_file_json = os.getcwd() + "/ext_data/e_coli_core.json" | ||
model = MetabolicNetwork.from_json( input_file_json ) | ||
sampler = PolytopeSampler(model) | ||
|
||
#gaussian hmc sampling | ||
steady_states = sampler.generate_steady_states_no_multiphase(method = 'gaussian_hmc_walk', n=500) | ||
|
||
self.assertTrue( steady_states.shape[0] == 95 ) | ||
self.assertTrue( steady_states.shape[1] == 500 ) | ||
#steady_states[12].mean() seems to have a lot of discrepancy between experiments, so we won't check the mean for now | ||
#self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-03 ) | ||
|
||
#exponential hmc sampling | ||
steady_states = sampler.generate_steady_states_no_multiphase(method = 'exponential_hmc_walk', n=500, variance=50) | ||
|
||
self.assertTrue( steady_states.shape[0] == 95 ) | ||
self.assertTrue( steady_states.shape[1] == 500 ) | ||
#steady_states[12].mean() seems to have a lot of discrepancy between experiments, so we won't check the mean for now | ||
#self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-03 ) | ||
|
||
def test_sample_mat(self): | ||
|
||
input_file_mat = os.getcwd() + "/ext_data/e_coli_core.mat" | ||
model = MetabolicNetwork.from_mat(input_file_mat) | ||
sampler = PolytopeSampler(model) | ||
|
||
#gaussian hmc sampling | ||
steady_states = sampler.generate_steady_states_no_multiphase(method = 'gaussian_hmc_walk', n=500) | ||
|
||
self.assertTrue( steady_states.shape[0] == 95 ) | ||
self.assertTrue( steady_states.shape[1] == 500 ) | ||
#steady_states[12].mean() seems to have a lot of discrepancy between experiments, so we won't check the mean for now | ||
#self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-03 ) | ||
|
||
#exponential hmc sampling | ||
steady_states = sampler.generate_steady_states_no_multiphase(method = 'exponential_hmc_walk', n=500, variance=50) | ||
|
||
self.assertTrue( steady_states.shape[0] == 95 ) | ||
self.assertTrue( steady_states.shape[1] == 500 ) | ||
#steady_states[12].mean() seems to have a lot of discrepancy between experiments, so we won't check the mean for now | ||
#self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-03 ) | ||
|
||
|
||
def test_sample_sbml(self): | ||
|
||
input_file_sbml = os.getcwd() + "/ext_data/e_coli_core.xml" | ||
model = MetabolicNetwork.from_sbml( input_file_sbml ) | ||
sampler = PolytopeSampler(model) | ||
|
||
#gaussian hmc sampling | ||
steady_states = sampler.generate_steady_states_no_multiphase(method = 'gaussian_hmc_walk', n=500) | ||
|
||
self.assertTrue( steady_states.shape[0] == 95 ) | ||
self.assertTrue( steady_states.shape[1] == 500 ) | ||
#steady_states[12].mean() seems to have a lot of discrepancy between experiments, so we won't check the mean for now | ||
#self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-03 ) | ||
|
||
#exponential hmc sampling | ||
steady_states = sampler.generate_steady_states_no_multiphase(method = 'exponential_hmc_walk', n=500, variance=50) | ||
|
||
self.assertTrue( steady_states.shape[0] == 95 ) | ||
self.assertTrue( steady_states.shape[1] == 500 ) | ||
#steady_states[12].mean() seems to have a lot of discrepancy between experiments, so we won't check the mean for now | ||
#self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-03 ) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |