def count_genes(model):
genes = set()<EOL>for reaction in model.reactions:<EOL><INDENT>if reaction.genes is None:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(reaction.genes, boolean.Expression):<EOL><INDENT>genes.update(v.symbol for v in reaction.genes.variables)<EOL><DEDENT>else:<EOL><INDENT>genes.update(reaction.genes)<EOL><DEDENT><DEDENT>return len(genes)<EOL>
Count the number of distinct genes in model reactions.