import re


def genes_for_gene_reaction_rule(rule):
    """ Find genes in gene_reaction_rule string.

    Arguments
    ---------

    rule: A boolean string containing gene names, parentheses, AND's and
    OR's.

    """

    # remove ANDs and ORs, surrounded by space or parentheses
    rule = re.sub(r'([()\s])(?:and|or)([)(\s])', r'\1\2', rule)
    # remove parentheses
    rule = re.sub(r'\(|\)', r'', rule)
    # split on whitespace
    genes = [x for x in rule.split(' ') if x != '']
    return genes