Replace the default behaviour of make_links. More specifically, this method
        implements the logic required to connect DFPT calculation to `DDK` files.
        Remember that DDK is an extension introduced in AbiPy to deal with the
        irdddk input variable and the fact that the 3 files with du/dk produced by Abinit
        have a file extension constructed from the number of atom (e.g. 1WF[3natom +1]).

        AbiPy uses the user-friendly syntax deps={node: "DDK"} to specify that
        the children will read the DDK from `node` but this also means that
        we have to implement extract logic to handle this case at runtime.

def make_links(self):
        """
        Replace the default behaviour of make_links. More specifically, this method
        implements the logic required to connect DFPT calculation to `DDK` files.
        Remember that DDK is an extension introduced in AbiPy to deal with the
        irdddk input variable and the fact that the 3 files with du/dk produced by Abinit
        have a file extension constructed from the number of atom (e.g. 1WF[3natom +1]).

        AbiPy uses the user-friendly syntax deps={node: "DDK"} to specify that
        the children will read the DDK from `node` but this also means that
        we have to implement extract logic to handle this case at runtime.
        """
        for dep in self.deps:
            for d in dep.exts:

                if d == "DDK":
                    ddk_task = dep.node
                    out_ddk = ddk_task.outdir.has_abiext("DDK")
                    if not out_ddk:
                        raise RuntimeError("%s didn't produce the DDK file" % ddk_task)

                    # Get (fortran) idir and costruct the name of the 1WF expected by Abinit
                    rfdir = list(ddk_task.input["rfdir"])
                    if rfdir.count(1) != 1:
                        raise RuntimeError("Only one direction should be specifned in rfdir but rfdir = %s" % rfdir)

                    idir = rfdir.index(1) + 1
                    ddk_case = idir + 3 * len(ddk_task.input.structure)

                    infile = self.indir.path_in("in_1WF%d" % ddk_case)
                    os.symlink(out_ddk, infile)

                elif d in ("WFK", "WFQ"):
                    gs_task = dep.node
                    out_wfk = gs_task.outdir.has_abiext(d)
                    if not out_wfk:
                        raise RuntimeError("%s didn't produce the %s file" % (gs_task, d))

                    if d == "WFK":
                        bname = "in_WFK"
                    elif d == "WFQ":
                        bname = "in_WFQ"
                    else:
                        raise ValueError("Don't know how to handle `%s`" % d)

                    if not os.path.exists(self.indir.path_in(bname)):
                            os.symlink(out_wfk, self.indir.path_in(bname))

                elif d == "DEN":
                    gs_task = dep.node
                    out_wfk = gs_task.outdir.has_abiext("DEN")
                    if not out_wfk:
                        raise RuntimeError("%s didn't produce the DEN file" % gs_task)
                    if not os.path.exists(self.indir.path_in("in_DEN")):
                        os.symlink(out_wfk, self.indir.path_in("in_DEN"))

                elif d == "1WF":
                    gs_task = dep.node
                    out_wfk = gs_task.outdir.has_abiext("1WF")
                    if not out_wfk:
                        raise RuntimeError("%s didn't produce the 1WF file" % gs_task)
                    dest = self.indir.path_in("in_" + out_wfk.split("_")[-1])
                    if not os.path.exists(dest):
                        os.symlink(out_wfk, dest)

                elif d == "1DEN":
                    gs_task = dep.node
                    out_wfk = gs_task.outdir.has_abiext("DEN")
                    if not out_wfk:
                        raise RuntimeError("%s didn't produce the 1DEN file" % gs_task)
                    dest = self.indir.path_in("in_" + out_wfk.split("_")[-1])
                    if not os.path.exists(dest):
                        os.symlink(out_wfk, dest)

                else:
                    raise ValueError("Don't know how to handle extension: %s" % str(dep.exts))