Delete the specified gene and solve using the desired method.

def run(self):
        """Delete the specified gene and solve using the desired method."""
        obj_reaction = self._get_objective()

        genes = set()
        gene_assoc = {}
        for reaction in self._model.reactions:
            assoc = None
            if reaction.genes is None:
                continue
            elif isinstance(reaction.genes, string_types):
                assoc = boolean.Expression(reaction.genes)
            else:
                variables = [boolean.Variable(g) for g in reaction.genes]
                assoc = boolean.Expression(boolean.And(*variables))
            genes.update(v.symbol for v in assoc.variables)
            gene_assoc[reaction.id] = assoc

        reactions = set(self._mm.reactions)
        start_time = time.time()
        testing_genes = set(self._args.gene)
        deleted_reactions = set()

        logger.info('Trying model without genes: {}...'.format(
                    ', '.join(sorted(testing_genes))))

        for reaction in reactions:
            if reaction not in gene_assoc:
                continue
            assoc = gene_assoc[reaction]
            if any(boolean.Variable(gene) in assoc.variables
                    for gene in testing_genes):
                new_assoc = assoc.substitute(
                    lambda v: v if v.symbol not in testing_genes else False)
                if new_assoc.has_value() and not new_assoc.value:
                    logger.info('Deleting reaction {}...'.format(reaction))
                    deleted_reactions.add(reaction)

        if self._args.method in ['moma', 'moma2']:
            solver = self._get_solver(quadratic=True)
        else:
            solver = self._get_solver()

        if self._args.method == 'fba':
            logger.info('Solving using FBA...')
            prob = fluxanalysis.FluxBalanceProblem(self._mm, solver)

            try:
                prob.maximize(obj_reaction)
            except fluxanalysis.FluxBalanceError as e:
                self.report_flux_balance_error(e)

            wild = prob.get_flux(obj_reaction)

            for reaction in deleted_reactions:
                flux_var = prob.get_flux_var(reaction)
                prob.prob.add_linear_constraints(flux_var == 0)

            prob.maximize(obj_reaction)
            deleteflux = prob.get_flux(obj_reaction)
        elif self._args.method in ['lin_moma', 'lin_moma2', 'moma', 'moma2']:
            prob = moma.MOMAProblem(self._mm, solver)
            wt_fluxes = prob.get_minimal_fba_flux(obj_reaction)
            wild = wt_fluxes[obj_reaction]

            for reaction in deleted_reactions:
                flux_var = prob.get_flux_var(reaction)
                prob.prob.add_linear_constraints(flux_var == 0)

            try:
                if self._args.method == 'moma':
                    logger.info('Solving using MOMA...')
                    prob.moma(wt_fluxes)
                elif self._args.method == 'lin_moma':
                    logger.info('Solving using linear MOMA...')
                    prob.lin_moma(wt_fluxes)
                elif self._args.method == 'moma2':
                    logger.info('Solving using combined-model MOMA...')
                    prob.moma2(obj_reaction, wild)
                elif self._args.method == 'lin_moma2':
                    logger.info('Solving using combined-model linear MOMA...')
                    prob.lin_moma2(obj_reaction, wild)
            except moma.MOMAError:
                self.fail('Error computing the MOMA result.')

            deleteflux = prob.get_flux(obj_reaction)

        logger.info(
            'Solving took {:.2f} seconds'.format(time.time() - start_time))
        logger.info(
            'Objective reaction after gene deletion has flux {}'.format(
                deleteflux + 0))
        if wild != 0:
            logger.info(
                'Objective reaction has {:.2%} flux of wild type flux'.format(
                    abs(deleteflux / wild)))