def add_groups(self, group_list):
def existing_filter(group):<EOL><INDENT>if group.id in self.groups:<EOL><INDENT>LOGGER.warning(<EOL>"<STR_LIT>", group.id)<EOL>return False<EOL><DEDENT>return True<EOL><DEDENT>if isinstance(group_list, string_types) orhasattr(group_list, "<STR_LIT:id>"):<EOL><INDENT>warn("<STR_LIT>")<EOL>group_list = [group_list]<EOL><DEDENT>pruned = DictList(filter(existing_filter, group_list))<EOL>for group in pruned:<EOL><INDENT>group._model = self<EOL>for member in group.members:<EOL><INDENT>if isinstance(member, Metabolite):<EOL><INDENT>if member not in self.metabolites:<EOL><INDENT>self.add_metabolites([member])<EOL><DEDENT><DEDENT>if isinstance(member, Reaction):<EOL><INDENT>if member not in self.reactions:<EOL><INDENT>self.add_reactions([member])<EOL><DEDENT><DEDENT><DEDENT>self.groups += [group]<EOL><DEDENT>
Add groups to the model.

        Groups with identifiers identical to a group already in the model are
        ignored.

        If any group contains members that are not in the model, these members
        are added to the model as well. Only metabolites, reactions, and genes
        can have groups.

        Parameters
        ----------
        group_list : list
            A list of `cobra.Group` objects to add to the model.