def main()

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


def main(script_name, argv):
    species, read_type, job_name, dir_out, feature_reference, fastq_list, fastq_list_r2, libtype, master, \
        expected_cells, forced_cells, chemistry, nosecondary, r1_length, r2_length, genome_build, transcriptome, \
        vdj_genome, detect_doublet, project, run, toolset, cores_per_sample, verbose, sync, sample_name_list, \
        master_mode, toolchain, target_panel, mem_free = parse_arguments(script_name, argv)

    library_type = "scRNASeq"
    if not read_type:
        read_type = "paired"
    if not job_name:
        job_name = "{}_job".format(library_type)
    if not run:
        run = "{}_run".format(library_type)
    if not expected_cells:
        expected_cells = "3000"
    if not forced_cells:
        forced_cells = "NA"
    if not nosecondary:
        nosecondary = "FALSE"
    if not cores_per_sample:
        cores_per_sample = "8"
    if not target_panel:
        target_panel = "NA"
    additional_options = {"feature_reference": feature_reference,
                          "genome_build": genome_build,
                          "genome": transcriptome,
                          "transcriptome": transcriptome,
                          "vdj_genome": vdj_genome,
                          "expected_cells": expected_cells,
                          "forced_cells": forced_cells,
                          "chemistry": chemistry,
                          "nosecondary": nosecondary,
                          "r1_length": r1_length,
                          "r2_length": r2_length,
                          "target_panel": target_panel,
                          "maxmem": mem_free}
    if not toolset:
        toolset = "count+vdj+qc"
    if detect_doublet and "doubletdetection" not in toolset:
        toolset += "+doubletdetection"
    global_config = GlobalConfig(species, read_type, TEMPLATE, WORKFLOW_NAME, toolset)
    if species == "human":
        global_config_tool_template_name = GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_TOOLCHAIN2 \
            if toolchain == "Cellranger_v6" else GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_HUMAN_TOOLCHAIN1
    elif species == "mouse":
        global_config_tool_template_name = GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_MOUSE_TOOLCHAIN2 \
            if toolchain == "Cellranger_v6" else GLOBAL_CONFIG_TOOL_TEMPLATE_NAME_MOUSE_TOOLCHAIN1
    else:
        raise RuntimeError('Failed to determine "species" parameter. Available species: "human" and "mouse"')

    global_config_path = global_config.create(global_config_tool_template_name, additional_options,
                                              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_libtype = list(str(libtype).split(',')) if libtype else None
        sample_master = list(str(master).split(',')) if master else None
        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_libtype=sample_libtype,
                                                                   sample_master=sample_master,
                                                                   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)