def parse_arguments()

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


def parse_arguments(script_name, argv):
    species = None
    read_type = None
    job_name = None
    dir_out = None
    fastq_list = None
    fastq_list_r2 = None
    cufflinks_library_type = None
    library_type = None
    project = None
    run = None
    toolset = None
    flag_xenome = None
    cores_per_sample = None
    genome_load = None
    sync = None
    master_mode = None
    verbose = None
    sample_name_list = None
    try:
        opts, args = getopt.getopt(argv, "hs:t:j:d:f:q:c:l:p:r:n:x:k:g:i:v", ["help", "species=", "read_type=",
                                                                              "job_name=", "dir_out=", "fastq_list=",
                                                                              "fastq_list_r2",
                                                                              "cufflinks_library_type=",
                                                                              "library_type=", "project=", "run=",
                                                                              "toolset=", "flag_xenome=",
                                                                              "cores_per_sample=", "genome_load=",
                                                                              "sync=", "sample_name_list", "master_mode",
                                                                              "verbose"])
        for opt, arg in opts:
            if opt == '-h':
                print(script_name + ' -s <species> -t <read_type> -j <job_name> -d <dir_out> -f <fastq_list> '
                                    '-q <fastq_list_r2> -c <cufflinks_library_type> -l <library_type> -p <project> '
                                    '-r <run> -n <toolset> -x <flag_xenome> -k <cores_per_sample> -g <genome_load> '
                                    '<sync> -i <sample_name_list> <master_mode> -v <verbose>')
                sys.exit()
            elif opt in ("-s", "--species"):
                species = arg
            elif opt in ("-t", "--read_type"):
                read_type = arg
            elif opt in ("-j", "--job_name"):
                job_name = arg
            elif opt in ("-d", "--dir_out"):
                dir_out = arg
            elif opt in ("-f", "--fastq_list"):
                fastq_list = arg
            elif opt in ("-q", "--fastq_list_r2"):
                fastq_list_r2 = arg
            elif opt in ("-c", "--cufflinks_library_type"):
                cufflinks_library_type = arg
            elif opt in ("-l", "--library_type"):
                library_type = arg
            elif opt in ("-p", "--project"):
                project = arg
            elif opt in ("-r", "--run"):
                run = arg
            elif opt in ("-n", "--toolset"):
                toolset = arg
            elif opt in ("-x", "--flag_xenome"):
                flag_xenome = arg
            elif opt in ("-k", "--cores_per_sample"):
                cores_per_sample = arg
            elif opt in ("-g", "--genome_load"):
                genome_load = arg
            elif opt in "--sync":
                sync = arg
            elif opt in "--master_mode":
                master_mode = True
            elif opt in ("-v", "--verbose"):
                verbose = 'True'
            elif opt in ("-i", "--sample_name_list"):
                sample_name_list = arg
        if not species:
            print('Species (-s <species>) is required')
            usage()
            sys.exit(2)
        if not read_type:
            print('Read type (-t <read_type>) is required')
            usage()
            sys.exit(2)
        if not fastq_list:
            print('The path to the input manifest fastq file (-f <fastq_list>) is required')
            usage()
            sys.exit(2)
        if not dir_out:
            print('The output directory for the analysis (-d <dir_out>) is required')
            usage()
            sys.exit(2)
        if not cufflinks_library_type:
            print('The cufflinks library type (-c <cufflinks_library_type>) is required')
            usage()
            sys.exit(2)
        if not toolset:
            print('The set of tools (-n <toolset>) is required')
            usage()
            sys.exit(2)
        return species, read_type, job_name, dir_out, fastq_list, fastq_list_r2, cufflinks_library_type, library_type, \
            project, run, toolset, flag_xenome, cores_per_sample, verbose, sync, genome_load, sample_name_list, \
            master_mode
    except getopt.GetoptError:
        usage()
        sys.exit(2)