Move function definitions from top of Snakefile to separate module

Keep Snakefile clean, facilitate unit testing