示例#1
0
    def __init__(self,
                 model_code='ecoli:iJO1366',
                 solver='gurobi',
                 min_biomass=0.55):
        self.logger = get_bistream_logger(
            (model_code + ':' + self.__class__.__name__).replace(':', '_'))
        self.logger.setLevel(logging.INFO)
        self.species = model_code.split(':')[0]
        self.model_name = model_code.split(':')[-1]
        if self.species.lower() == 'ecoli':
            if self.model_name.lower() == 'iml1515':
                self.model = load_json_model(
                    os.path.dirname(os.path.abspath(__file__)) +
                    '/data/ecoli/iML1515.json')
                self.biomass_reaction = 'BIOMASS_Ec_iML1515_core_75p37M'
            else:
                self.model = load_json_model(
                    os.path.dirname(os.path.abspath(__file__)) +
                    '/data/ecoli/iJO1366.json')
                self.biomass_reaction = 'BIOMASS_Ec_iJO1366_core_53p95M'
            self.model.objective = self.biomass_reaction
            self.model.reactions.get_by_id(
                self.biomass_reaction).lower_bound = min_biomass
            self.model.solver = solver
        self._init_model()
        self._print_summary()

        self.reserved_bounds = {}
        self.dummy_reactions = set()
示例#2
0
    def __init__(
        self,
        thermo_data,
        model=Model(),
        name=None,
        growth_reaction='',
        mu=None,
        mu_error=0,
        mu_range=None,
        n_mu_bins=1,
        big_M=1000,
        temperature=std.TEMPERATURE_0,
        min_ph=std.MIN_PH,
        max_ph=std.MAX_PH,
        prot_scaling=1000,
        mrna_scaling=None,
    ):

        if name is None:
            name = 'ETFL_' + name if name else 'ETFL model'

        LCSBModel.__init__(self, model, name)

        ###############
        #   ME part   #
        ###############

        self.logger = get_bistream_logger('ME model' + str(self.name))
        self.parent = model
        if model is not None:
            self.sanitize_varnames()

        self.init_etfl(big_M, growth_reaction, mu_range, n_mu_bins, name)

        ###############
        # Thermo part #
        ###############

        self.TEMPERATURE = temperature
        self.thermo_data = thermo_data
        self.thermo_unit = thermo_data['units']
        self.reaction_cues_data = thermo_data['cues']
        self.compounds_data = thermo_data['metabolites']
        self.Debye_Huckel_B = get_debye_huckel_b(temperature)
        self.parent = model

        self.logger = get_bistream_logger('thermomodel_' + str(self.name))

        # Compute internal values to adapt the the thermo_unit provided
        if self.thermo_unit == "kJ/mol":
            self.GAS_CONSTANT = 8.314472 / 1000  # kJ/(K mol)
            self.Adjustment = 1
        else:
            self.GAS_CONSTANT = 1.9858775 / 1000  # Kcal/(K mol)
            self.Adjustment = 4.184

        self.RT = self.GAS_CONSTANT * self.TEMPERATURE

        # CONSTANTS
        self.MAX_pH = max_ph
        self.MIN_pH = min_ph

        self.logger.info('# Model initialized with units {} and temperature {} K'  \
                    .format(self.thermo_unit, self.TEMPERATURE))
示例#3
0
def _silence_pytfa(logger_name):
    # Disables the stream logs produced by the pytfa module, keeps file logs
    logger = get_bistream_logger(logger_name)
    for handler in logger.handlers:
        if not isinstance(handler, logging.FileHandler):
            handler.setLevel(logging.ERROR)