For future reference - the command for this in vg convert is somewhat unclear - you need to have a vg format graph in the command, that is, you cannot just directly convert gam to gaf or vice versa.
vg convert --threads $task.cpus $vg --gam-to-gaf $gam > ${prefix}.gaf