예제 #1
0
    def setUp(self):
        self._database = DictDatabase()
        self._database.set_reaction('rxn_1', parse_reaction('A[e] => B[e]'))
        self._database.set_reaction('rxn_2', parse_reaction('B[e] => C[e]'))
        self._database.set_reaction('rxn_3', parse_reaction('B[e] <=> D[e]'))
        self._database.set_reaction('rxn_4', parse_reaction('C[e] <=> E[e]'))
        self._database.set_reaction('rxn_5', parse_reaction('D[e] => E[e]'))
        self._database.set_reaction('rxn_6', parse_reaction('E[e] =>'))
        self._database.set_reaction('ex_A', parse_reaction('A[e] <=>'))

        self._mm = MetabolicModel.load_model(
            self._database, self._database.reactions)
        self._assoc = {
            'rxn_1': str('gene_1'),
            'rxn_2': str('gene_2'),
            'rxn_3': str('gene_5'),
            'rxn_4': str('gene_3 or gene_4'),
            'rxn_5': str('gene_5 and gene_6')
        }
        self._obj_reaction = 'rxn_6'

        try:
            self._solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')
        try:
            self.solver = generic.Solver(integer=True)
        except generic.RequirementsError:
            self.skipTest('Needs and integer programming solver')
예제 #2
0
    def setUp(self):
        self._database = DictDatabase()
        self._database.set_reaction('rxn_1', parse_reaction('A[e] => B[e]'))
        self._database.set_reaction('rxn_2', parse_reaction('B[e] => C[e]'))
        self._database.set_reaction('rxn_3', parse_reaction('B[e] => D[e]'))
        self._database.set_reaction('rxn_4', parse_reaction('C[e] => E[e]'))
        self._database.set_reaction('rxn_5', parse_reaction('D[e] => E[e]'))
        self._database.set_reaction('rxn_6', parse_reaction('E[e] =>'))
        self._database.set_reaction('ex_A', parse_reaction('A[e] <=>'))

        self._mm = MetabolicModel.load_model(self._database,
                                             self._database.reactions)
        self._assoc = {
            'rxn_1': boolean.Expression('gene_1'),
            'rxn_2': boolean.Expression('gene_2 or gene_3'),
            'rxn_5': boolean.Expression('gene_3 and gene_4')
        }
        self._obj_reaction = 'rxn_6'

        try:
            self._solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')

        self._prob = fluxanalysis.FluxBalanceProblem(self._mm, self._solver)
예제 #3
0
    def is_solver_available(self, **kwargs):
        try:
            generic.Solver(**kwargs)
        except generic.RequirementsError:
            return False

        return True
예제 #4
0
    def test_run_fastgapfill(self):
        # Skip test if solver is GLPK because of issue #61.
        try:
            solver = generic.Solver()
            if solver.properties['name'] == 'glpk':
                self.skipTest('Test has known issue with GLPK')
        except generic.RequirementsError:
            pass

        self.run_solver_command(FastGapFillCommand)
예제 #5
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('|A| + |B| => |C|'))
        self.database.set_reaction('rxn_2',
                                   parse_reaction('|C| + |Z| => |A| + |B|'))
        self.model = MetabolicModel.load_model(self.database,
                                               self.database.reactions)

        try:
            self.solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')
예제 #6
0
    def setUp(self):
        # TODO use mock model instead of actual model
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> |A|'))
        self.database.set_reaction('rxn_2',
                                   parse_reaction('(0.000001) |A| =>'))
        self.model = MetabolicModel.load_model(self.database,
                                               self.database.reactions)

        try:
            self.solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')
예제 #7
0
 def test_gimme_model(self):
     f = ['gene\texpression', 'gene_1\t15', 'gene_2\t20',
          'gene_3\t15', 'gene_4\t25', 'gene_5\t10', 'gene_6\t25']
     threshold_dict = gimme.parse_transcriptome_file(f, 20)
     mm_irreversible, reversible_gene_assoc, split_rxns = \
         gimme.make_irreversible(self._mm, self._assoc,
         exclude_list=['ex_A', 'rxn_6'])
     p = fluxanalysis.FluxBalanceProblem(mm_irreversible, generic.Solver())
     final_model, used_exchange, below_threshold_ids, incon_score = \
         gimme.solve_gimme_problem(p, mm_irreversible, 'rxn_6',
         reversible_gene_assoc, split_rxns, threshold_dict, MaybeRelative(20))
     self.assertEqual(incon_score, 100)
     self.assertEqual(final_model, set(['rxn_1', 'rxn_2', 'rxn_4']))
     self.assertEqual(below_threshold_ids, set(['rxn_1', 'rxn_3', 'rxn_5']))
예제 #8
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> |A|'))
        self.database.set_reaction('rxn_2', parse_reaction('|A| <=> |B|'))
        self.database.set_reaction('rxn_3', parse_reaction('|A| => |C|'))
        self.database.set_reaction('rxn_4', parse_reaction('|C| => |D|'))
        self.database.set_reaction('rxn_5', parse_reaction('|D| <=> |E|'))
        self.model = MetabolicModel.load_model(
            self.database, self.database.reactions)

        try:
            self.solver = generic.Solver(integer=True)
        except generic.RequirementsError:
            self.skipTest('Unable to find an MILP solver for tests')
예제 #9
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> |A|'))
        self.database.set_reaction('rxn_2',
            parse_reaction('(0.000001) |A| =>'))
        self.model = MetabolicModel.load_model(
            self.database, self.database.reactions)

        try:
            self.solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')

        # Skip these tests with GLPK because of issue #61.
        if self.solver.properties['name'] == 'glpk':
            self.skipTest('Test has known issue with GLPK')
예제 #10
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('=> (2) |A|'))
        self.database.set_reaction('rxn_2', parse_reaction('|A| <=> |B|'))
        self.database.set_reaction('rxn_3', parse_reaction('|A| => |D|'))
        self.database.set_reaction('rxn_4', parse_reaction('|A| => |C|'))
        self.database.set_reaction('rxn_5', parse_reaction('|C| => |D|'))
        self.database.set_reaction('rxn_6', parse_reaction('|D| =>'))
        self.database.set_reaction('rxn_7', parse_reaction('|E| => |F|'))
        self.database.set_reaction('rxn_8', parse_reaction('|F| => |E|'))

        self.model = MetabolicModel.load_model(self.database,
                                               self.database.reactions)
        self.model.limits['rxn_5'].upper = 100

        try:
            self.solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')
예제 #11
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('ex_A', parse_reaction('|A| <=>'))
        self.database.set_reaction('ex_D', parse_reaction('|D| <=>'))
        self.database.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        self.database.set_reaction('rxn_2', parse_reaction('|B| <=> |C|'))
        self.database.set_reaction('rxn_3', parse_reaction('|C| <=> |D|'))
        self.database.set_reaction('rxn_4', parse_reaction('|D| <=> |E|'))
        self.database.set_reaction('rxn_5', parse_reaction('|E| => |B|'))

        self.model = MetabolicModel.load_model(self.database,
                                               self.database.reactions)
        self.model.limits['ex_A'].lower = -10  # Low uptake
        self.model.limits['ex_D'].lower = 0  # No uptake

        try:
            self.solver = generic.Solver(integer=True)
        except generic.RequirementsError:
            self.skipTest('Unable to find an MILP solver for tests')
예제 #12
0
    def setUp(self):
        self.database = DictDatabase()
        self.database.set_reaction('rxn_1', parse_reaction('|A| => |B|'))
        self.database.set_reaction('rxn_2', parse_reaction('|B| => |G|'))
        self.database.set_reaction('rxn_3', parse_reaction('|A| => |G|'))
        self.database.set_reaction('rxn_4', parse_reaction('|B| => |H|'))
        self.database.set_reaction('rxn_5', parse_reaction('|B| => |C| + |F|'))
        self.database.set_reaction('rxn_6', parse_reaction('|C| => |D|'))
        self.database.set_reaction('rxn_7', parse_reaction('|E| <=> |D|'))
        self.database.set_reaction('rxn_9', parse_reaction('|I| => |J|'))
        self.database.set_reaction('rxn_10', parse_reaction('|J| => |K|'))
        self.database.set_reaction('rxn_A', parse_reaction('=> |A|'))
        self.database.set_reaction('rxn_G', parse_reaction('|G| =>'))
        self.database.set_reaction('rxn_E', parse_reaction('|E| =>'))
        self.database.set_reaction(
            'rxn_bio', parse_reaction('|D| + (2.5) |F| =>'))
        self.model = MetabolicModel.load_model(
            self.database, self.database.reactions)

        try:
            self.solver = generic.Solver()
        except generic.RequirementsError:
            self.skipTest('Unable to find an LP solver for tests')
예제 #13
0
# Notes for me

# Removing the second glucose exp for anaerobe. It yields a biomass of 0 and I am
# not sure why.

from psamm.lpsolver import generic

solver = generic.Solver()

import sys
sys.path.insert(0, '.')
import moma
import sys
import moma_test
import csv
import math


# Run the moma tests with a certain cutoff for viable/not viable
def run_tests(algorithm):
    gene_dict = {}
    # The medium that we are limiting in each of the experiments
    medium_ids = ['R_EX_glc_e_', 'R_EX_gal_e_', 'R_EX_glyc_e_', 'R_EX_etoh_e_']
    aerobe = True  # Our first glucose exp will be aerobe
    for exp in medium_ids:
        print("Removing: " + exp)
        # We are working on a glucose exp
        if exp == 'R_EX_glc_e_':
            if aerobe == True:
                mm.limits['R_EX_o2_e_'].lower = -2.0
                mm.limits['R_EX_co2_e_'].lower = 0.0
예제 #14
0
 def setUp(self):
     try:
         self.solver = generic.Solver()
     except generic.RequirementsError:
         self.skipTest('Unable to find an LP solver for tests')