In your batch script, you can submit child jobs. You could for example have a general `snippy` batch script. From within this script, you submit another array job, that calls the SNPs for each sample. When all child jobs have finished, your script continues with any of the additional tasks, like generating the SNP alignment, which needs the output from all child jobs as input.
For this task it could make sense to write two scripts, with one being nested within the other.
For example, the SNP-calling step could be a job array script, that is called from within another script that then uses this output to generate the MSA and the tree.
In order for your main script to wait for the results of all child jobs, you add the option `-W` to your sbatch command, for example:
For this to work, you just submit your job array script from within the other submission script as usual with `sbatch`. However, in order for the "outer" script to wait for all launched child jobs to finish, you need to specify the flag `-W`.
this snippy.sh script submits another job array script within: