def repair(self, rebuild_index=True, rebuild_relationships=True):
if rebuild_index:  <EOL><INDENT>self.reactions._generate_index()<EOL>self.metabolites._generate_index()<EOL>self.genes._generate_index()<EOL>self.groups._generate_index()<EOL><DEDENT>if rebuild_relationships:<EOL><INDENT>for met in self.metabolites:<EOL><INDENT>met._reaction.clear()<EOL><DEDENT>for gene in self.genes:<EOL><INDENT>gene._reaction.clear()<EOL><DEDENT>for rxn in self.reactions:<EOL><INDENT>for met in rxn._metabolites:<EOL><INDENT>met._reaction.add(rxn)<EOL><DEDENT>for gene in rxn._genes:<EOL><INDENT>gene._reaction.add(rxn)<EOL><DEDENT><DEDENT><DEDENT>for l in (self.reactions, self.genes, self.metabolites, self.groups):<EOL><INDENT>for e in l:<EOL><INDENT>e._model = self<EOL><DEDENT><DEDENT>
Update all indexes and pointers in a model

        Parameters
        ----------
        rebuild_index : bool
            rebuild the indices kept in reactions, metabolites and genes
        rebuild_relationships : bool
             reset all associations between genes, metabolites, model and
             then re-add them.