def create_model(self):
        """Return :class:`NativeModel` fully loaded into memory."""

        properties = {
            'name': self.name,
            'biomass': self.biomass_reaction,
            'extracellular': self.extracellular_compartment,
            'default_compartment': self.default_compartment,
            'default_flux_limit': self.default_flux_limit
        }

        if self.context is not None:
            git_version = util.git_try_describe(self.context.basepath)
            properties['version_string'] = git_version

        model = NativeModel(properties)

        # Load compartments into model
        compartment_iter, boundaries = self.parse_compartments()
        for compartment in compartment_iter:
            model.compartments.add_entry(compartment)
        model.compartment_boundaries.update(boundaries)

        # Load compounds into model
        for compound in self.parse_compounds():
            if compound.id in model.compounds:
                existing_entry = model.compounds[compound.id]
                common_props = set(compound.properties).intersection(
                    existing_entry.properties).difference({'id'})
                if len(common_props) > 0:
                    logger.warning(
                        'Compound entry {} at {} overrides already defined'
                        ' properties: {}'.format(
                            compound.id, compound.filemark, common_props))

                properties = dict(compound.properties)
                properties.update(existing_entry.properties)
                compound = CompoundEntry(
                    properties, filemark=compound.filemark)
            model.compounds.add_entry(compound)

        # Load reactions into model
        for reaction in self.parse_reactions():
            if reaction.id in model.reactions:
                existing_entry = model.reactions[reaction.id]
                common_props = set(reaction.properties).intersection(
                    existing_entry.properties).difference({'id'})
                if len(common_props) > 0:
                    logger.warning(
                        'Reaction entry {} at {} overrides already defined'
                        ' properties: {}'.format(
                            reaction.id, reaction.filemark, common_props))

                properties = dict(reaction.properties)
                properties.update(existing_entry.properties)
                reaction = ReactionEntry(
                    properties, filemark=reaction.filemark)
            model.reactions.add_entry(reaction)

        for exchange_def in self.parse_exchange():
            model.exchange[exchange_def[0]] = exchange_def

        for limit in self.parse_limits():
            model.limits[limit[0]] = limit

        if self.has_model_definition():
            for model_reaction in self.parse_model():
                model.model[model_reaction] = None
        else:
            for reaction in model.reactions:
                model.model[reaction.id] = None

        return model
def create_model ( self ) : properties = { 'name' : self . name , 'biomass' : self . biomass_reaction , 'extracellular' : self . extracellular_compartment , 'default_compartment' : self . default_compartment , 'default_flux_limit' : self . default_flux_limit } if self . context is not None : git_version = util . git_try_describe ( self . context . basepath ) properties [ 'version_string' ] = git_version model = NativeModel ( properties ) compartment_iter , boundaries = self . parse_compartments ( ) for compartment in compartment_iter : model . compartments . add_entry ( compartment ) model . compartment_boundaries . update ( boundaries ) for compound in self . parse_compounds ( ) : if compound . id in model . compounds : existing_entry = model . compounds [ compound . id ] common_props = set ( compound . properties ) . intersection ( existing_entry . properties ) . difference ( { 'id' } ) if len ( common_props ) > 0 : logger . warning ( 'Compound entry {} at {} overrides already defined' ' properties: {}' . format ( compound . id , compound . filemark , common_props ) ) properties = dict ( compound . properties ) properties . update ( existing_entry . properties ) compound = CompoundEntry ( properties , filemark = compound . filemark ) model . compounds . add_entry ( compound ) for reaction in self . parse_reactions ( ) : if reaction . id in model . reactions : existing_entry = model . reactions [ reaction . id ] common_props = set ( reaction . properties ) . intersection ( existing_entry . properties ) . difference ( { 'id' } ) if len ( common_props ) > 0 : logger . warning ( 'Reaction entry {} at {} overrides already defined' ' properties: {}' . format ( reaction . id , reaction . filemark , common_props ) ) properties = dict ( reaction . properties ) properties . update ( existing_entry . properties ) reaction = ReactionEntry ( properties , filemark = reaction . filemark ) model . reactions . add_entry ( reaction ) for exchange_def in self . parse_exchange ( ) : model . exchange [ exchange_def [ 0 ] ] = exchange_def for limit in self . parse_limits ( ) : model . limits [ limit [ 0 ] ] = limit if self . has_model_definition ( ) : for model_reaction in self . parse_model ( ) : model . model [ model_reaction ] = None else : for reaction in model . reactions : model . model [ reaction . id ] = None return model
Return :class:`NativeModel` fully loaded into memory.