Beispiel #1
0
    def __init__(self,
                 id=None,
                 name="",
                 subsystem="",
                 lower_bound=0.0,
                 upper_bound=None):
        Object.__init__(self, id, name)
        self._gene_reaction_rule = ""
        self.subsystem = subsystem

        # The cobra.Genes that are used to catalyze the reaction
        self._genes = set()

        # A dictionary of metabolites and their stoichiometric coefficients in
        # this reaction.
        self._metabolites = {}

        # self.model is None or refers to the cobra.Model that
        # contains self
        self._model = None

        # from cameo ...
        self._lower_bound = (lower_bound if lower_bound is not None else
                             config.lower_bound)
        self._upper_bound = (upper_bound if upper_bound is not None else
                             config.upper_bound)
Beispiel #2
0
    def __init__(self, list_of_models=[], identifier=None, name=None):
        Object.__init__(self, identifier, name)
        if len(list_of_models) > 1:
            if not all(isinstance(x, Model) for x in list_of_models):
                raise AttributeError(
                    "list_of_models may only contain cobra.core.Model objects")
            if len([model.id for model in list_of_models]) > \
                            len(set([model.id for model in list_of_models])):
                raise AssertionError(
                    "Ensemble members cannot have duplicate model ids.")
            self.features = DictList()
            self._populate_features_base(list_of_models)

            self.members = DictList()
            self._populate_members(list_of_models)

        else:
            if len(list_of_models) == 0:
                self.base_model = Model(id_or_model=identifier+'_base_model',\
                                        name=name)
            else:
                if not isinstance(list_of_models[0], Model):
                    raise AttributeError(
                        "list_of_models may only contain cobra.core.Model objects"
                    )
                self.base_model = list_of_models[0]
Beispiel #3
0
    def __init__(self, id_or_model=None, name=None):
        if isinstance(id_or_model, Model):
            Object.__init__(self, name=name)
            self.__setstate__(id_or_model.__dict__)
            if not hasattr(self, "name"):
                self.name = None
            self._solver = id_or_model.solver
        else:
            Object.__init__(self, id_or_model, name=name)
            self._trimmed = False
            self._trimmed_genes = []
            self._trimmed_reactions = {}
            self.genes = DictList()
            self.reactions = DictList()  # A list of cobra.Reactions
            self.metabolites = DictList()  # A list of cobra.Metabolites
            # genes based on their ids {Gene.id: Gene}
            self.compartments = dict()
            self._contexts = []

            # from cameo ...

            # if not hasattr(self, '_solver'):  # backwards compatibility
            # with older cobrapy pickles?
            interface = solvers[get_solver_name()]
            self._solver = interface.Model()
            self._solver.objective = interface.Objective(S.Zero)
            self._populate_solver(self.reactions, self.metabolites)
Beispiel #4
0
    def __init__(self, id_or_model=None, name=None):
        if isinstance(id_or_model, Model):
            Object.__init__(self, name=name)
            self.__setstate__(id_or_model.__dict__)
            if not hasattr(self, "name"):
                self.name = None
            self._solver = id_or_model.solver
        else:
            Object.__init__(self, id_or_model, name=name)
            self._trimmed = False
            self._trimmed_genes = []
            self._trimmed_reactions = {}
            self.genes = DictList()
            self.reactions = DictList()  # A list of cobra.Reactions
            self.metabolites = DictList()  # A list of cobra.Metabolites
            # genes based on their ids {Gene.id: Gene}
            self._compartments = dict()
            self._contexts = []

            # from cameo ...

            # if not hasattr(self, '_solver'):  # backwards compatibility
            # with older cobrapy pickles?
            interface = solvers[get_solver_name()]
            self._solver = interface.Model()
            self._solver.objective = interface.Objective(Zero)
            self._populate_solver(self.reactions, self.metabolites)
Beispiel #5
0
    def __init__(self, id=None, name='', subsystem='', lower_bound=0.0,
                 upper_bound=None, objective_coefficient=0.0):
        Object.__init__(self, id, name)
        self._gene_reaction_rule = ''
        self.subsystem = subsystem

        # The cobra.Genes that are used to catalyze the reaction
        self._genes = set()

        # A dictionary of metabolites and their stoichiometric coefficients in
        # this reaction.
        self._metabolites = {}

        # The set of compartments that partaking metabolites are in.
        self._compartments = None

        # self.model is None or refers to the cobra.Model that
        # contains self
        self._model = None

        if objective_coefficient != 0:
            raise NotImplementedError('setting objective coefficient when '
                                      'creating reaction is no longer '
                                      'supported. Use the model.objective '
                                      'setter')

        # from cameo ...
        self._lower_bound = lower_bound if lower_bound is not None else \
            CONFIGURATION.lower_bound
        self._upper_bound = upper_bound if upper_bound is not None else \
            CONFIGURATION.upper_bound
Beispiel #6
0
 def __init__(self, identifier=None, name=None,ensemble=None,\
             base_component=None, component_attribute=None, states=None):
     Object.__init__(self, identifier, name)
     self.ensemble = ensemble
     self.base_component = base_component
     self.component_attribute = component_attribute
     self.states = states
Beispiel #7
0
    def __init__(self, id, name='', members=None, kind=None):
        Object.__init__(self, id, name)

        self._members = set() if members is None else set(members)
        self._kind = None
        self.kind = "collection" if kind is None else kind
        # self.model is None or refers to the cobra.Model that
        # contains self
        self._model = None
Beispiel #8
0
    def __init__(self, id, name="", members=None, kind=None):
        Object.__init__(self, id, name)

        self._members = DictList() if members is None else DictList(members)
        self._kind = None
        self.kind = "collection" if kind is None else kind
        # self.model is None or refers to the cobra.Model that
        # contains self
        self._model = None
Beispiel #9
0
    def __init__(self,
                 id=None,
                 name='',
                 subsystem='',
                 lower_bound=0.,
                 upper_bound=1000.,
                 objective_coefficient=0.):
        Object.__init__(self, id, name)
        self._gene_reaction_rule = ''
        self.subsystem = subsystem

        # The cobra.Genes that are used to catalyze the reaction
        self._genes = set()

        # A dictionary of metabolites and their stoichiometric coefficients in
        # this reaction.
        self._metabolites = {}

        # The set of compartments that partaking metabolites are in.
        self._compartments = None

        # self.model is None or refers to the cobra.Model that
        # contains self
        self._model = None

        if objective_coefficient != 0:
            raise NotImplementedError('setting objective coefficient when '
                                      'creating reaction is no longer '
                                      'supported. Use the model.objective '
                                      'setter')

        # Used during optimization.  Indicates whether the
        # variable is modeled as continuous, integer, binary, semicontinous, or
        # semiinteger.
        self.variable_kind = 'continuous'

        # from cameo ...
        self._lower_bound = lower_bound
        self._upper_bound = upper_bound

        self._reverse_variable = None
        self._forward_variable = None
Beispiel #10
0
    def __init__(self, id=None, name='', subsystem='', lower_bound=0.,
                 upper_bound=1000., objective_coefficient=0.):
        Object.__init__(self, id, name)
        self._gene_reaction_rule = ''
        self.subsystem = subsystem

        # The cobra.Genes that are used to catalyze the reaction
        self._genes = set()

        # A dictionary of metabolites and their stoichiometric coefficients in
        # this reaction.
        self._metabolites = dict()

        # The set of compartments that partaking metabolites are in.
        self._compartments = None

        # self.model is None or refers to the cobra.Model that
        # contains self
        self._model = None

        if objective_coefficient != 0:
            raise NotImplementedError('setting objective coefficient when '
                                      'creating reaction is no longer '
                                      'supported. Use the model.objective '
                                      'setter')

        # Used during optimization.  Indicates whether the
        # variable is modeled as continuous, integer, binary, semicontinous, or
        # semiinteger.
        self.variable_kind = 'continuous'

        # from cameo ...
        self._lower_bound = lower_bound
        self._upper_bound = upper_bound

        self._reverse_variable = None
        self._forward_variable = None
 def __init__(self, formula=None):
     Object.__init__(self, formula)
     self.formula = formula
     self.elements = {}
     if self.formula is not None:
         self.parse_composition()
Beispiel #12
0
 def __init__(self, id=None, name=None):
     Object.__init__(self, id, name)
     self._model = None
     # references to reactions that operate on this species
     self._reaction = set()
Beispiel #13
0
 def __init__(self, formula=None):
     Object.__init__(self, formula)
     self.formula = formula
     self.elements = {}
     if self.formula is not None:
         self.parse_composition()
Beispiel #14
0
 def __init__(self,ensemble=None, identifier=None, name=None, states=None):
     Object.__init__(self,identifier,name)
     self.ensemble = ensemble
     self.states = states