Parse a structured list of reactions as obtained from a YAML file

    Yields tuples of reaction ID and reaction object. Path can be given as a
    string or a context.

def parse_reaction_list(path, reactions, default_compartment=None):
    """Parse a structured list of reactions as obtained from a YAML file

    Yields tuples of reaction ID and reaction object. Path can be given as a
    string or a context.
    """

    context = FilePathContext(path)

    for reaction_def in reactions:
        if 'include' in reaction_def:
            include_context = context.resolve(reaction_def['include'])
            for reaction in parse_reaction_file(
                    include_context, default_compartment):
                yield reaction
        else:
            yield parse_reaction(reaction_def, default_compartment, context)