def add_toffoli_to_line(local_qasm_line, qubit_1, qubit_2, target_qubit):
    """
    Add a single Toffoli gate application to the given line of qasm.

    Args:
        local_qasm_line: The line of qasm
        qubit_1: The first control qubit
        qubit_2: The second control qubit
        target_qubit: The target qubit

    Returns: The same line of qasm with the Toffoli gate added in parallel
    """

    single_application = "Toffoli q[{}],q[{}],q[{}]".format(qubit_1, qubit_2, target_qubit)

    # if the line is not empty, we need to consider what's already present
    if local_qasm_line != "":
        # a bracket indicates this line is parallelized with the { gate_1 | gate_2 | gate_3 } syntax
        if "{" in local_qasm_line:
            # remove } from the line and add it back at the end
            local_qasm_line = local_qasm_line.rstrip("}| \n") + \
                              " | " + \
                              single_application + \
                              "}\n"

        # no bracket means we have to add the parallelization syntax ourselves
        else:
            local_qasm_line = "{" + local_qasm_line.rstrip("\n") + \
                              " | " + \
                              single_application + "}\n"

    # else, if the line IS empty, we can just put this gate in directly
    else:
        local_qasm_line = single_application + "\n"
    return local_qasm_line