def execute(run, output_filename):
    for dirname in os.listdir(run["path"]):
        # To check it is dir, not file
        if os.path.isdir(run["path"] + dirname):
            # BaseSpace (Illumina) directory structure
            data_path = (run["path"] + dirname +
                         "/Data/Intensities/BaseCalls/")
            sample = dir_tools.get_sample_info(run["path"] + dirname)
            prefix = run["name"] + "_" + sample["num"]

            varscan_results = run_varscan(
                prefix,
                data_path)

            if varscan_results != "no reads.":
                annotate_results(varscan_results,
                                 output_filename,
                                 sample["num"],
                                 sample["name"],
                                 data_path + prefix)
def main(shell_args):
    global MODE, OUTPUT_FILENAME
    MODE = str.upper(shell_args.mode)
    OUTPUT_FILENAME = shell_args.output_filename
    run = dir_tools.get_run_info(shell_args.run_path)
    init_output()

    for dirname in os.listdir(run['path']):
        # To check it is dir, not file
        if os.path.isdir(run['path'] + dirname):
            # BaseSpace (Illumina) directory structure
            data_path = (run['path'] + dirname +
                         '/Data/Intensities/BaseCalls/')

            sample = dir_tools.get_sample_info(run['path'] + dirname)
            prefix = run['name'] + '_' + sample['num']

            if MODE == 'READS':
                run_reads(data_path, sample, prefix)
            elif MODE == 'VARIANTS':
                run_variants(data_path, sample, prefix)