def main()

in src/main/scripts/dna_capture_var_fastq.py [0:0]


def main(script_name, argv):
    species, read_type, job_name, dir_out, fastq_list, fastq_list_r2, library_type, project, run, toolset, \
        flag_xenome, cores_per_sample, verbose, sync, genome, targeted_kit, sample_name_list, master_mode, \
        novoalign_tune = parse_arguments(script_name, argv)
    if not library_type:
        library_type = "DNASeq"
    if not job_name:
        job_name = "{}_job".format(library_type)
    if not run:
        run = "{}_run".format(library_type)
    if not cores_per_sample:
        cores_per_sample = "4"
    if not novoalign_tune:
        novoalign_tune = "NA"
    if species == "human":
        human_kit = {
            'SureSelect_v4': GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_SURE_SELECT_V4,
            'SureSelect_v5': GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_SURE_SELECT_V5,
            'SureSelect_v6': GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_SURE_SELECT_V6
        }
        try:
            global_config_tool_template_name = human_kit[targeted_kit]
        except KeyError as e:
            raise ValueError('Only SureSelect_v4, SureSelect_v5, SureSelect_v6 target kits are available for human.',
                             e.args[0])
    elif species == "mouse":
        if targeted_kit != "Mouse_Exome_v1":
            raise ValueError('Only Mouse_Exome_v1 target kit is available for mouse.')
        global_config_tool_template_name = GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_MOUSE_EXOME_V1
    else:
        raise ValueError('Failed to determine "species" parameter. Available species: "human"/"mouse"')

    additional_options = {"novoalign_tune": novoalign_tune}
    global_config = GlobalConfig(species, read_type, TEMPLATE, WORKFLOW_NAME, toolset)
    global_config_path = global_config.create(global_config_tool_template_name, additional_options,
                                              flag_xenome=flag_xenome, cores_per_sample=cores_per_sample)
    if os.path.isdir(fastq_list):
        fastq_list = FastqSampleManifest(read_type).create_by_folder(fastq_list, WORKFLOW_NAME, library_type)
    elif 'fastq.gz' in str(fastq_list).split(',')[0]:
        sample_name_list = list(str(sample_name_list).split(',')) if sample_name_list else None
        fastq_list = FastqSampleManifest(read_type).create_by_list(list(str(fastq_list).split(',')),
                                                                   list(str(fastq_list_r2).split(',')),
                                                                   WORKFLOW_NAME, library_type,
                                                                   sample_names=sample_name_list)
    study_config = StudyConfig(job_name, dir_out, fastq_list, None, library_type, run, project=project)
    study_config_path = study_config.parse(workflow=WORKFLOW_NAME)
    Launcher.launch(global_config_path, study_config_path, sync, java_path=global_config.java_path, verbose=verbose,
                    master=master_mode)