Returns a line of text to add to an environment file, initializing a
    reaction that uses the resource specified in the first
    argument to perform the associated task (resource names are expected to
    be of the form "resTASK#" where "TASK" corresponds
    to the task the resource is associated with and # is an integer uniquely
    identifying that specific gradient resource. For
    example, the first AND resource would be named resAND0). An optional
    second argument (int) specifies whether or not the reaction
    should deplete the resource (by default it will not).

def gen_reaction(args, resource, depletable=0):
    """
    Returns a line of text to add to an environment file, initializing a
    reaction that uses the resource specified in the first
    argument to perform the associated task (resource names are expected to
    be of the form "resTASK#" where "TASK" corresponds
    to the task the resource is associated with and # is an integer uniquely
    identifying that specific gradient resource. For
    example, the first AND resource would be named resAND0). An optional
    second argument (int) specifies whether or not the reaction
    should deplete the resource (by default it will not).
    """
    task = resource.lower()
    if task[:3] == "res":
        task = task[3:]
    while task[-1].isdigit():
        task = task[:-1]

    name = resource[3:]
    return "".join(["REACTION ", name, " ", task, " process:resource=",
                    resource, ":value=", str(args.taskValDict[task]), ":type=",
                    args.rxnType, ":frac=", str(args.frac), ":max=",
                    str(args.resMax), ":depletable=", str(int(depletable)),
                    " requisite:max_count=", str(args.maxCount), "\n"])