def create_metabolic_model(self):
        """Create a :class:`psamm.metabolicmodel.MetabolicModel`."""

        def _translate_compartments(reaction, compartment):
            """Translate compound with missing compartments.

            These compounds will have the specified compartment in the output.
            """
            left = (((c.in_compartment(compartment), v)
                     if c.compartment is None else (c, v))
                    for c, v in reaction.left)
            right = (((c.in_compartment(compartment), v)
                      if c.compartment is None else (c, v))
                     for c, v in reaction.right)
            return Reaction(reaction.direction, left, right)

        # Create metabolic model
        database = DictDatabase()
        for reaction in self.reactions:
            if reaction.equation is not None:
                equation = _translate_compartments(
                    reaction.equation, self.default_compartment)
                database.set_reaction(reaction.id, equation)

        undefined_compartments = set()
        undefined_compounds = set()
        extracellular_compounds = set()
        extracellular = self.extracellular_compartment
        for reaction in database.reactions:
            for compound, _ in database.get_reaction_values(reaction):
                if compound.name not in self.compounds:
                    undefined_compounds.add(compound.name)
                if compound.compartment == extracellular:
                    extracellular_compounds.add(compound.name)
                if compound.compartment not in self.compartments:
                    undefined_compartments.add(compound.compartment)

        for compartment in sorted(undefined_compartments):
            logger.warning(
                'The compartment {} was not defined in the list'
                ' of compartments'.format(compartment))

        for compound in sorted(undefined_compounds):
            logger.warning(
                'The compound {} was not defined in the list'
                ' of compounds'.format(compound))

        exchange_compounds = set()
        for exchange_compound in self.exchange:
            if exchange_compound.compartment == extracellular:
                exchange_compounds.add(exchange_compound.name)

        for compound in sorted(extracellular_compounds - exchange_compounds):
            logger.warning(
                'The compound {} was in the extracellular compartment'
                ' but not defined in the exchange compounds'.format(compound))
        for compound in sorted(exchange_compounds - extracellular_compounds):
            logger.warning(
                'The compound {} was defined in the exchange compounds but'
                ' is not in the extracellular compartment'.format(compound))

        model_definition = None
        if len(self.model) > 0:
            model_definition = self.model

        return MetabolicModel.load_model(
            database, model_definition, itervalues(self.exchange),
            itervalues(self.limits), v_max=self.default_flux_limit)