fixed input/bamlist. and moved external programs to external.c