def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "input_gff_file" if args.input_gff_file is None: xlib.Message.print('error', '*** The input GFF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.input_gff_file): xlib.Message.print('error', f'*** The file {args.input_gff_file} does not exist.') OK = False # check "gff_format" if args.gff_format is None: args.gff_format = 'GFF3' elif args.gff_format.upper() != 'GFF3': xlib.Message.print('error', '*** The format of the GFF file has to be GFF3.') OK = False else: args.gff_format = args.gff_format.upper() # check "vcf_file" if args.vcf_file is None: xlib.Message.print('error', '*** The VCF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.vcf_file): xlib.Message.print('error', f'*** The file {args.vcf_file} does not exist.') OK = False # check "output_gff_file" if args.output_gff_file is None: xlib.Message.print('error', '*** The output VCF file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "annotation_file" if args.annotation_file is None: xlib.Message.print('error', '*** The annotation file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.annotation_file): xlib.Message.print('error', f'*** The file {args.annotation_file} does not exist.') OK = False # check "type" if args.type is None: xlib.Message.print('error', '*** The type of annotation file is not indicated in the input arguments.') OK = False elif not xlib.check_code(args.type, xlib.get_type2_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** The type of annotation file has to be {xlib.get_type2_code_list_text()}.') OK = False else: args.type = args.type.upper() # check "score_file" if args.score_file is None: xlib.Message.print('error', '*** The sequence score file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.score_file): xlib.Message.print('error', f'*** The file {args.score_file} does not exist.') OK = False # check "go_file" if args.go_file is None: xlib.Message.print('error', '*** The file with GO terms per sequence is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "toa_database" if args.toa_database is None: xlib.Message.print( 'error', '*** The TOA database is not indicated in the input arguments.') OK = False # check "table_group" if args.table_group is None: xlib.Message.print( 'error', '*** The table group is not indicated in the input arguments.') OK = False elif not xlib.check_code(args.table_group, xlib.get_table_group_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The table group has to be {xlib.get_table_group_code_list_text()}.' ) OK = False else: args.table_group = args.table_group.lower() # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "input_vcf_file" if args.input_vcf_file is None: xlib.Message.print('error', '*** The VCF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.input_vcf_file): xlib.Message.print('error', f'*** The file {args.input_vcf_file} does not exist.') OK = False # check "imputed_md_id" if args.imputed_md_id is None: args.imputed_md_id = xlib.Const.DEFAULT_IMPUTED_MD_ID # check "output_genotype_file" if args.output_genotype_file is None: xlib.Message.print('error', '*** The output genotype data file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check "tvi_list" if args.tvi_list is None or args.tvi_list == 'NONE': args.tvi_list = [] else: args.tvi_list = xlib.split_literal_to_string_list(args.tvi_list) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "ngshelper_database" if args.ngshelper_database is None: xlib.Message.print('error', '*** The NGShelper database is not indicated in the input arguments.') OK = False # check "alignment_file" if args.alignment_file is None: xlib.Message.print('error', '*** The alignment file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.alignment_file): xlib.Message.print('error', f'*** The file {args.alignment_file} does not exist.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "annotation_file" if args.annotation_file is None: xlib.Message.print( 'error', '*** The annotation file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.annotation_file): xlib.Message.print( 'error', f'*** The file {args.annotation_file} does not exist.') OK = False # check "type" if args.type is None: xlib.Message.print( 'error', '*** The type of annotation file is not indicated in the input arguments.' ) OK = False elif not xlib.check_code( args.type, xlib.get_type_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The type of annotation file has to be {xlib.get_type_code_list_text()}.' ) OK = False else: args.type = args.type.upper() # check "header" if args.header is None: args.header = xlib.Const.DEFAULT_HEADER elif not xlib.check_code( args.header, xlib.get_header_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** header has to be {xlib.get_header_code_list_text()}.') OK = False else: args.header = args.header.upper() # check "record_number_per_file" if args.record_number_per_file is None: args.record_number_per_file = xlib.Const.DEFAULT_RNUM elif not xlib.check_int(args.record_number_per_file, minimum=1): xlib.Message.print( 'error', '*** The record number per splitted file has to be an integer number greater than 0.' ) OK = False else: args.record_number_per_file = int(args.record_number_per_file) # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_express_config_file(strict): ''' Check the eXpress config file of a run. ''' # initialize the control variable and the error list OK = True error_list = [] # intitialize variable used when value is not found not_found = '***NOTFOUND***'.upper() # get the option dictionary try: express_option_dict = xlib.get_option_dict(get_express_config_file()) except Exception as e: error_list.append(f'*** EXCEPTION: "{e}".') error_list.append('*** ERROR: The option dictionary could not be built from the config file') OK = False else: # get the sections list sections_list = [] for section in express_option_dict.keys(): sections_list.append(section) sections_list.sort() # check section "identification" if 'identification' not in sections_list: error_list.append('*** ERROR: the section "identification" is not found.') OK = False else: # check section "identification" - key "experiment_id" experiment_id = express_option_dict.get('identification', {}).get('experiment_id', not_found) if experiment_id == not_found: error_list.append('*** ERROR: the key "experiment_id" is not found in the section "identification".') OK = False # check section "identification" - key "assembly_software" assembly_software = express_option_dict.get('identification', {}).get('assembly_software', not_found) if assembly_software == not_found: error_list.append('*** ERROR: the key "assembly_software" is not found in the section "identification".') OK = False elif not xlib.check_code(assembly_software, get_assembly_software_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "assembly_software" has to be {get_assembly_software_code_list_text()}.') OK = False # check section "identification" - key "assembly_dataset_id" assembly_dataset_id = express_option_dict.get('identification', {}).get('assembly_dataset_id', not_found) if assembly_dataset_id == not_found: error_list.append('*** ERROR: the key "assembly_dataset_id" is not found in the section "identification".') OK = False elif not xlib.check_startswith(assembly_dataset_id, get_assembly_software_code_list(), case_sensitive=True): error_list.append(f'*** ERROR: the key "assembly_dataset_id" has to start with {get_assembly_software_code_list_text()}.') OK = False # check section "identification" - key "assembly_type" assembly_type = express_option_dict.get('identification', {}).get('assembly_type', not_found) if assembly_type == not_found: error_list.append('*** ERROR: the key "assembly_type" is not found in the section "identification".') OK = False elif assembly_dataset_id.startswith(xlib.get_soapdenovotrans_code()) and assembly_type.upper() not in ['CONTIGS', 'SCAFFOLDS'] or \ not assembly_dataset_id.startswith(xlib.get_soapdenovotrans_code()) and assembly_type.upper() != 'NONE': error_list.append(f'*** ERROR: the key "assembly_type" has to be CONTIGS or SCAFFOLDS in {xlib.get_soapdenovotrans_name()} or NONE in any other case.') OK = False # check section "alignment-dataset-1" if 'alignment-dataset-1' not in sections_list: error_list.append('*** ERROR: the section "alignment-dataset-1" is not found.') OK = False # check all sections "alignment-dataset-n" for section in sections_list: if section not in ['identification', 'eXpress parameters']: # check than the section identification is like alignment-dataset-n if not re.match('^alignment-dataset-[0-9]+$', section): error_list.append(f'*** ERROR: the section "{section}" has a wrong identification.') OK = False else: # check section "alignment-dataset-n" - key "alignment_software" alignment_software = express_option_dict.get(section, {}).get('alignment_software', not_found) if alignment_software == not_found: error_list.append(f'*** ERROR: the key "alignment_software" is not found in the section "{section}".') OK = False elif not xlib.check_code(alignment_software, get_alignment_software_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "alignment_software" has to be {get_alignment_software_code_list_text()}.') OK = False # check section "alignment-dataset-n" - key "alignment_dataset_id" alignment_dataset_id = express_option_dict.get(section, {}).get('alignment_dataset_id', not_found) if alignment_dataset_id == not_found: error_list.append(f'*** ERROR: the key "alignment_dataset_id" is not found in the section "{section}".') OK = False elif not xlib.check_startswith(alignment_dataset_id, get_alignment_software_code_list(), case_sensitive=True): error_list.append(f'*** ERROR: the key "alignment_dataset_id" has to start with {get_alignment_software_code_list_text()}.') OK = False # check section "eXpress parameters" if 'eXpress parameters' not in sections_list: error_list.append('*** ERROR: the section "eXpress parameters" is not found.') OK = False else: # check section "express parameters" - key "frag-len-mean" frag_len_mean = express_option_dict.get('eXpress parameters', {}).get('frag-len-mean', not_found) if frag_len_mean == not_found: error_list.append('*** ERROR: the key "frag-len-mean" is not found in the section "eXpress parameters".') OK = False elif not xlib.check_int(frag_len_mean, minimum=1): error_list.append('*** ERROR: the key "frag-len-mean" has to be an integer number greater than or equal to 1.') OK = False # check section "express parameters" - key "frag-len-stddev" frag_len_stddev = express_option_dict.get('eXpress parameters', {}).get('frag-len-stddev', not_found) if frag_len_stddev == not_found: error_list.append('*** ERROR: the key "frag-len-stddev" is not found in the section "eXpress parameters".') OK = False elif not xlib.check_int(frag_len_stddev, minimum=1): error_list.append('*** ERROR: the key "frag-len-stddev" has to be an integer number greater than or equal to 1.') OK = False # check section "eXpress parameters" - key "library_type" library_type = express_option_dict.get('eXpress parameters', {}).get('library_type', not_found) if library_type == not_found: error_list.append('*** ERROR: the key "library_type" is not found in the section "eXpress parameters".') OK = False elif not xlib.check_code(library_type, get_library_type_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "library_type" has to be {get_library_type_code_list_text()}.') OK = False # check section "eXpress parameters" - key "max-indel-size" max_indel_size = express_option_dict.get('eXpress parameters', {}).get('max-indel-size', not_found) if max_indel_size == not_found: error_list.append('*** ERROR: the key "max-indel-size" is not found in the section "eXpress parameters".') OK = False elif not xlib.check_int(max_indel_size, minimum=0): error_list.append('*** ERROR: the key "max-indel-size" has to be an integer number greater than or equal to 0.') OK = False # check section "eXpress parameters" - key "no-bias-correct" no_bias_correct = express_option_dict.get('eXpress parameters', {}).get('no-bias-correct', not_found) if no_bias_correct == not_found: error_list.append('*** ERROR: the key "no-bias-correct" is not found in the section "eXpress parameters".') OK = False elif not xlib.check_code(no_bias_correct, get_no_bias_correct_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "no-bias-correct" has to be {get_no_bias_correct_code_list_text()}.') OK = False # check section "eXpress parameters" - key "no-error-model" no_error_model = express_option_dict.get('eXpress parameters', {}).get('no-error-model', not_found) if no_error_model == not_found: error_list.append('*** ERROR: the key "no-error-model" is not found in the section "eXpress parameters".') OK = False elif not xlib.check_code(no_error_model, get_no_error_model_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "no-error-model" has to be {get_no_error_model_code_list_text()}.') OK = False # check section "eXpress parameters" - key "other_parameters" not_allowed_parameters_list = ['no-update-check', 'frag-len-mean', 'frag-len-stddev', 'max-indel-size', 'fr-stranded', 'rf-stranded', 'f-stranded', 'r-stranded', 'no-bias-correct', 'no-error-model', 'output-dir'] other_parameters = express_option_dict.get('eXpress parameters', {}).get('other_parameters', not_found) if other_parameters == not_found: error_list.append('*** ERROR: the key "other_parameters" is not found in the section "eXpress parameters".') OK = False elif other_parameters.upper() != 'NONE': (OK, error_list2) = xlib.check_parameter_list(other_parameters, "other_parameters", not_allowed_parameters_list) error_list = error_list + error_list2 # warn that the results config file is not valid if there are any errors if not OK: error_list.append(f'\nThe {xlib.get_express_name()} config file is not valid. Please, correct this file or recreate it.') # return the control variable and the error list return (OK, error_list)
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "ngshelper_database" if args.ngshelper_database is None: xlib.Message.print( 'error', '*** The NGShelper database is not indicated in the input arguments.' ) OK = False # check "sp1_id" if args.sp1_id is None: xlib.Message.print( 'error', '*** The identification of the first species is not indicated in the input arguments.' ) OK = False # check "sp2_id" if args.sp2_id is None: xlib.Message.print( 'error', '*** The identification of the second species is not indicated in the input arguments.' ) OK = False # check "hybrid_id" if args.hybrid_id is None: args.hybrid_id = 'NONE' # check "max_separation" if args.max_separation is None: xlib.Message.print( 'error', '*** The maximum separation between variants of the same intergenic fragment is not indicated in the input arguments.' ) OK = False elif not xlib.check_int(args.max_separation, minimum=1): xlib.Message.print( 'error', 'The maximum separation between variants of the same intergenic fragment has to be a integer number greater than 1.' ) OK = False else: args.max_separation = int(args.max_separation) # check "output_dir" if args.output_dir is None: xlib.Message.print( 'error', '*** The output directy is not indicated in the input arguments.') OK = False elif not os.path.isdir(args.output_dir): xlib.Message.print('error', '*** The output directy does not exist.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check "tsi_list" if args.tsi_list is None or args.tsi_list == 'NONE': args.tsi_list = [] else: args.tsi_list = xlib.split_literal_to_string_list(args.tsi_list) # check the identification set if OK: if args.sp1_id == args.sp2_id or (args.sp1_id == args.hybrid_id or args.sp2_id == args.hybrid_id): xlib.Message.print('error', 'The identifications must be different.') OK = False # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "input_vcf_file" if args.input_vcf_file is None: xlib.Message.print( 'error', '*** The VCF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.input_vcf_file): xlib.Message.print( 'error', f'*** The file {args.input_vcf_file} does not exist.') OK = False # check "purge_operation" is_ok_purge_operation = False if args.purge_operation is None: xlib.Message.print( 'error', '*** The purge operation is not indicated in the input arguments.') OK = False elif not xlib.check_code(args.purge_operation, xlib.get_vcf_purge_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The purge operation has to be {xlib.get_vcf_purge_code_list_text()}.' ) OK = False else: args.purge_operation = args.purge_operation.upper() is_ok_purge_operation = True # check "value" if args.value is None: xlib.Message.print( 'error', '*** The value to perform the purge operation is not indicated the input arguments.' ) OK = False # check "new_value" if args.new_value is None and is_ok_purge_operation and args.purge_operation == 'CHAVAR': xlib.Message.print( 'error', '*** The new value to perform the purge operation is not indicated the input arguments.' ) OK = False elif args.new_value is None: args.new_value = ' NONE' # check "output_purged_file" if args.output_purged_file is None: xlib.Message.print( 'error', '*** The purged file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_htseq_count_config_file(strict): ''' Check the htseq-count config file of a run. ''' # initialize the control variable and the error list OK = True error_list = [] # intitialize variable used when value is not found not_found = '***NOTFOUND***'.upper() # get the option dictionary try: htseq_count_option_dict = xlib.get_option_dict( get_htseq_count_config_file()) except Exception as e: error_list.append(f'*** EXCEPTION: "{e}".') error_list.append( '*** ERROR: The option dictionary could not be built from the config file' ) OK = False else: # get the sections list sections_list = [] for section in htseq_count_option_dict.keys(): sections_list.append(section) sections_list.sort() # check section "identification" if 'identification' not in sections_list: error_list.append( '*** ERROR: the section "identification" is not found.') OK = False else: # check section "identification" - key "experiment_id" experiment_id = htseq_count_option_dict.get( 'identification', {}).get('experiment_id', not_found) if experiment_id == not_found: error_list.append( '*** ERROR: the key "experiment_id" is not found in the section "identification".' ) OK = False # check section "identification" - key "reference_dataset_id" reference_dataset_id = htseq_count_option_dict.get( 'identification', {}).get('reference_dataset_id', not_found) if reference_dataset_id == not_found: error_list.append( '*** ERROR: the key "reference_dataset_id" is not found in the section "identification".' ) OK = False # check section "identification" - key "annotation_file" annotation_file = htseq_count_option_dict.get( 'identification', {}).get('annotation_file', not_found) if annotation_file == not_found: error_list.append( '*** ERROR: the key "annotation_file" is not found in the section "identification".' ) OK = False elif os.path.splitext(annotation_file)[1] not in ['.gtf', '.gff']: error_list.append( '*** ERROR: the key "annotation_file" has to be a file name with .gtf/.gff extension.' ) OK = False # check section "alignment-dataset-1" if 'alignment-dataset-1' not in sections_list: error_list.append( '*** ERROR: the section "alignment-dataset-1" is not found.') OK = False # check all sections "alignment-dataset-n" for section in sections_list: if section not in ['identification', 'htseq-count parameters']: # check than the section identification is like alignment-dataset-n if not re.match('^alignment-dataset-[0-9]+$', section): error_list.append( f'*** ERROR: the section "{section}" has a wrong identification.' ) OK = False else: # check section "alignment-dataset-n" - key "alignment_software" alignment_software = htseq_count_option_dict.get( section, {}).get('alignment_software', not_found) if alignment_software == not_found: error_list.append( f'*** ERROR: the key "alignment_software" is not found in the section "{section}".' ) OK = False elif not xlib.check_code( alignment_software, get_alignment_software_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "alignment_software" has to be {get_alignment_software_code_list_text()}.' ) OK = False # check section "alignment-dataset-n" - key "alignment_dataset_id" alignment_dataset_id = htseq_count_option_dict.get( section, {}).get('alignment_dataset_id', not_found) if alignment_dataset_id == not_found: error_list.append( f'*** ERROR: the key "alignment_dataset_id" is not found in the section "{section}".' ) OK = False elif not xlib.check_startswith( alignment_dataset_id, get_alignment_software_code_list(), case_sensitive=True): error_list.append( f'*** ERROR: the key "alignment_dataset_id" has to start with {get_alignment_software_code_list_text()}.' ) OK = False # check section "htseq-count parameters" if 'htseq-count parameters' not in sections_list: error_list.append( '*** ERROR: the section "htseq-count parameters" is not found.' ) OK = False else: # check section "htseq-count parameters" - key "nprocesses" nprocesses = htseq_count_option_dict.get( 'htseq-count parameters', {}).get('nprocesses', not_found) if nprocesses == not_found: error_list.append( '*** ERROR: the key "nprocesses" is not found in the section "htseq-count parameters".' ) OK = False elif not xlib.check_int(nprocesses, minimum=1): error_list.append( '*** ERROR: the key "nprocesses" has to be an integer number greater than or equal to 1.' ) OK = False # check section "htseq-count parameters" - key "stranded" stranded = htseq_count_option_dict.get('htseq-count parameters', {}).get( 'stranded', not_found) if stranded == not_found: error_list.append( '*** ERROR: the key "stranded" is not found in the section "htseq-count parameters".' ) OK = False elif not xlib.check_code( stranded, get_stranded_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "stranded" has to be {get_stranded_code_list_text()}.' ) OK = False # check section "htseq-count parameters" - key "minaqual" minaqual = htseq_count_option_dict.get('htseq-count parameters', {}).get( 'minaqual', not_found) if minaqual == not_found: error_list.append( '*** ERROR: the key "minaqual" is not found in the section "htseq-count parameters".' ) OK = False elif not xlib.check_int(minaqual): error_list.append( '*** ERROR: the key "minaqual" has to be an integer number.' ) OK = False # check section "htseq-count parameters" - key "type" type = htseq_count_option_dict.get('htseq-count parameters', {}).get('type', not_found) if type == not_found: error_list.append( '*** ERROR: the key "type" is not found in the section "htseq-count parameters".' ) OK = False # check section "htseq-count parameters" - key "idattr" idattr = htseq_count_option_dict.get('htseq-count parameters', {}).get('idattr', not_found) if idattr == not_found: error_list.append( '*** ERROR: the key "idattr" is not found in the section "htseq-count parameters".' ) OK = False # check section "htseq-count parameters" - key "mode" mode = htseq_count_option_dict.get('htseq-count parameters', {}).get('mode', not_found) if mode == not_found: error_list.append( '*** ERROR: the key "mode" is not found in the section "htseq-count parameters".' ) OK = False elif not xlib.check_code( mode, get_mode_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "mode" has to be {get_mode_code_list_text()}.' ) OK = False # check section "htseq-count parameters" - key "nonunique" nonunique = htseq_count_option_dict.get('htseq-count parameters', {}).get( 'nonunique', not_found) if nonunique == not_found: error_list.append( '*** ERROR: the key "nonunique" is not found in the section "htseq-count parameters".' ) OK = False elif not xlib.check_code(nonunique, get_nonunique_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "nonunique" has to be {get_nonunique_code_list_text()}.' ) OK = False # check section "htseq-count parameters" - key "other_parameters" not_allowed_parameters_list = [ 'nprocesses', 'format', 'stranded', 'minaqual', 'type', 'idattr', 'mode', 'nonunique', 'quiet' ] other_parameters = htseq_count_option_dict.get( 'htseq-count parameters', {}).get('other_parameters', not_found) if other_parameters == not_found: error_list.append( '*** ERROR: the key "other_parameters" is not found in the section "htseq-count parameters".' ) OK = False elif other_parameters.upper() != 'NONE': (OK, error_list2) = xlib.check_parameter_list( other_parameters, "other_parameters", not_allowed_parameters_list) error_list = error_list + error_list2 # warn that the results config file is not valid if there are any errors if not OK: error_list.append( f'\nThe {xlib.get_htseq_count_name()} config file is not valid. Please, correct this file or recreate it.' ) # return the control variable and the error list return (OK, error_list)
def check_cutadapt_config_file(strict): ''' Check the cutadapt config file of a run. ''' # initialize the control variable and the error list OK = True error_list = [] # intitialize variable used when value is not found not_found = '***NOTFOUND***'.upper() # get the option dictionary try: cutadapt_option_dict = xlib.get_option_dict(get_cutadapt_config_file()) except Exception as e: error_list.append(f'*** EXCEPTION: "{e}".') error_list.append('*** ERROR: The option dictionary could not be built from the config file') OK = False else: # get the sections list sections_list = [] for section in cutadapt_option_dict.keys(): sections_list.append(section) sections_list.sort() # check section "identification" if 'identification' not in sections_list: error_list.append('*** ERROR: the section "identification" is not found.') OK = False else: # check section "identification" - key "experiment_id" experiment_id = cutadapt_option_dict.get('identification', {}).get('experiment_id', not_found) if experiment_id == not_found: error_list.append('*** ERROR: the key "experiment_id" is not found in the section "identification".') OK = False # check section "identification" - key "read_dataset_id" read_dataset_id = cutadapt_option_dict.get('identification', {}).get('read_dataset_id', not_found) if read_dataset_id == not_found: error_list.append('*** ERROR: the key "read_dataset_id" is not found in the section "identification".') OK = False # check section "cutadapt parameters" if 'cutadapt parameters' not in sections_list: error_list.append('*** ERROR: the section "cutadapt parameters" is not found.') OK = False else: # check section "cutadapt parameters" - key "cores" cores = cutadapt_option_dict.get('cutadapt parameters', {}).get('cores', not_found) if cores == not_found: error_list.append('*** ERROR: the key "cores" is not found in the section "cutadapt parameters".') OK = False elif not xlib.check_int(cores, minimum=0): error_list.append('*** ERROR: the key "cores" has to be an integer number greater than or equal to 0.') OK = False # check section "cutadapt parameters" - key "adapter" adapter = cutadapt_option_dict.get('cutadapt parameters', {}).get('adapter', not_found) if adapter == not_found: error_list.append('*** ERROR: the key "adapter" is not found in the section "cutadapt parameters".') OK = False elif adapter.upper() == 'NONE': error_list.append('*** ERROR: the key "adapter" has to be different from NONE.') OK = False # check section "cutadapt parameters" - key "adapter_pe" adapter_pe = cutadapt_option_dict.get('cutadapt parameters', {}).get('adapter_pe', not_found) is_ok_adapter_pe = False if adapter_pe == not_found: error_list.append('*** ERROR: the key "adapter_pe" is not found in the section "cutadapt parameters".') OK = False else: is_ok_adapter_pe = True # check section "cutadapt parameters" - key "front" front = cutadapt_option_dict.get('cutadapt parameters', {}).get('front', not_found) if front == not_found: error_list.append('*** ERROR: the key "front" is not found in the section "cutadapt parameters".') OK = False # check section "cutadapt parameters" - key "front_pe" front_pe = cutadapt_option_dict.get('cutadapt parameters', {}).get('front_pe', not_found) is_ok_front_pe = False if front_pe == not_found: error_list.append('*** ERROR: the key "front_pe" is not found in the section "cutadapt parameters".') OK = False else: is_ok_front_pe = True # check section "cutadapt parameters" - key "anywhere" anywhere = cutadapt_option_dict.get('cutadapt parameters', {}).get('anywhere', not_found) if anywhere == not_found: error_list.append('*** ERROR: the key "anywhere" is not found in the section "cutadapt parameters".') OK = False # check section "cutadapt parameters" - key "anywhere_pe" anywhere_pe = cutadapt_option_dict.get('cutadapt parameters', {}).get('anywhere_pe', not_found) is_ok_anywhere_pe = False if anywhere_pe == not_found: error_list.append('*** ERROR: the key "anywhere_pe" is not found in the section "cutadapt parameters".') OK = False else: is_ok_anywhere_pe = True # check section "cutadapt parameters" - key "other_parameters" not_allowed_parameters_list = ['cores', 'adapter', 'front', 'anywhere'] other_parameters = cutadapt_option_dict.get('cutadapt parameters', {}).get('other_parameters', not_found) if other_parameters == not_found: error_list.append('*** ERROR: the key "other_parameters" is not found in the section "cutadapt parameters".') OK = False elif other_parameters.upper() != 'NONE': (OK, error_list2) = xlib.check_parameter_list(other_parameters, "other_parameters", not_allowed_parameters_list) error_list = error_list + error_list2 # check section "library" if 'library' not in sections_list: error_list.append('*** ERROR: the section "library" is not found.') OK = False else: # check section "library" - key "format" format = cutadapt_option_dict.get('library', {}).get('format', not_found) if format == not_found: error_list.append('*** ERROR: the key "format" is not found in the section "library".') OK = False elif not xlib.check_code(format, get_format_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "format" has to be {get_format_code_list_text()}.') OK = False # check section "library" - key "read_type" read_type = cutadapt_option_dict.get('library', {}).get('read_type', not_found) is_ok_read_type = False if read_type == not_found: error_list.append('*** ERROR: the key "read_type" is not found in the section "library".') OK = False elif not xlib.check_code(read_type, get_read_type_code_list(), case_sensitive=False): error_list.append(f'*** ERROR: the key "read_type" has to be {get_read_type_code_list_text()}.') OK = False else: is_ok_read_type = True # check "adapter_pe" is NONE if read type es SE if is_ok_read_type and is_ok_adapter_pe and read_type.upper() == 'SE' and adapter_pe.upper() != 'NONE': error_list.append('*** ERROR: the key "adapter_pe" has to be NONE when de read type is SE.') OK = False # check "front_pe" is NONE if read type es SE if is_ok_read_type and is_ok_front_pe and read_type.upper() == 'SE' and front_pe.upper() != 'NONE': error_list.append('*** ERROR: the key "front_pe" has to be NONE when de read type is SE.') OK = False # check "anywhere_pe" is NONE if read type es SE if is_ok_read_type and is_ok_anywhere_pe and read_type.upper() == 'SE' and anywhere_pe.upper() != 'NONE': error_list.append('*** ERROR: the key "anywhere_pe" has to be NONE when de read type is SE.') OK = False # check section "library-1" if 'library-1' not in sections_list: error_list.append('*** ERROR: the section "library-1" is not found.') OK = False # check all sections "library-n" for section in sections_list: if section not in ['identification', 'cutadapt parameters', 'library']: # check than the section identification is like library-n if not re.match('^library-[0-9]+$', section): error_list.append(f'*** ERROR: the section "{section}" has a wrong identification.') OK = False else: # check section "library-n" - key "read_file_1" read_file_1 = cutadapt_option_dict.get(section, {}).get('read_file_1', not_found) if read_file_1 == not_found: error_list.append(f'*** ERROR: the key "read_file_1" is not found in the section "{section}"') OK = False # check section "library-n" - key "read_file_2" read_file_2 = cutadapt_option_dict.get(section, {}).get('read_file_2', not_found) if read_file_2 == not_found: error_list.append(f'*** ERROR: the key "read_file_2" is not found in the section "{section}"') OK = False # warn that the results config file is not valid if there are any errors if not OK: error_list.append(f'\nThe {xlib.get_kallisto_name()} config file is not valid. Please, correct this file or recreate it.') # return the control variable and the error list return (OK, error_list)
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "vcf_file" if args.vcf_file is None: xlib.Message.print( 'error', '*** The VCF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.vcf_file): xlib.Message.print('error', f'*** The file {args.vcf_file} does not exist.') OK = False # check "sample_file" if args.sample_file is None: xlib.Message.print( 'error', '*** The sample file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.sample_file): xlib.Message.print('error', f'*** The file {args.sample_file} does not exist.') OK = False # check "sp1_id" if args.sp1_id is None: xlib.Message.print( 'error', '*** The identification of the first species is not indicated in the input arguments.' ) OK = False # check "sp2_id" if args.sp2_id is None: xlib.Message.print( 'error', '*** The identification of the second species is not indicated in the input arguments.' ) OK = False # check "hybrid_id" if args.hybrid_id is None: args.hybrid_id = 'NONE' # check "output_dir" if args.output_dir is None: xlib.Message.print( 'error', '*** The output directy is not indicated in the input arguments.') OK = False elif not os.path.isdir(args.output_dir): xlib.Message.print('error', '*** The output directy does not exist.') OK = False # check "variant_number_per_file" if args.variant_number_per_file is None: args.variant_number_per_file = xlib.Const.DEFAULT_VARIANT_NUMBER_PER_FILE elif not xlib.check_int(args.variant_number_per_file, minimum=1): xlib.Message.print( 'error', 'The variant number per file has to be an integer number greater than 0.' ) OK = False else: args.variant_number_per_file = int(args.variant_number_per_file) # check "allele_transformation" if args.allele_transformation is None: args.allele_transformation = 'NONE' elif not xlib.check_code(args.allele_transformation, xlib.get_allele_transformation_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The allele transformation has to be {xlib.get_allele_transformation_code_list_text()}.' ) OK = False else: args.allele_transformation = args.allele_transformation.upper() # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check "tvi_list" if args.tvi_list is None or args.tvi_list == 'NONE': args.tvi_list = [] else: args.tvi_list = xlib.split_literal_to_string_list(args.tvi_list) # check the identification set if OK: if args.sp1_id == args.sp2_id or \ args.hybrid_id is not None and (args.sp1_id == args.hybrid_id or args.sp2_id == args.hybrid_id): xlib.Message.print('error', 'The identifications must be different.') OK = False # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "annotation_file_1" if args.annotation_file_1 is None: xlib.Message.print('error', '*** The first annotation file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.annotation_file_1): xlib.Message.print('error', f'*** The file {args.annotation_file_1} does not exist.') OK = False # check "type_1" if args.type_1 is None: xlib.Message.print('error', '*** The type of first annotation file is not indicated in the input arguments.') OK = False elif not xlib.check_code(args.type_1, xlib.get_type_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** The type of annotation file has to be {xlib.get_type_code_list_text()}.') OK = False else: args.type_1 = args.type_1.upper() # check "annotation_file_2" if args.annotation_file_2 is None: xlib.Message.print('error', '*** The second annotation file is not indicated in the input arguments.') OK = False elif args.annotation_file_2.upper() == 'NONE': args.annotation_file_2 = args.annotation_file_2.upper() elif not os.path.isfile(args.annotation_file_2): xlib.Message.print('error', f'*** The file {args.annotation_file_2} does not exist.') OK = False # check "type_2" if args.type_2 is None: xlib.Message.print('error', '*** The format of second annotation file is not indicated in the input arguments.') OK = False elif args.type_2.upper() == 'NONE' and args.annotation_file_2 != 'NONE': xlib.Message.print('error', '*** The format of second annotation file has to be NONE if the second annotation file is NONE') OK = False elif args.type_2.upper() == 'NONE' and args.annotation_file_2 == 'NONE': args.type_2 = args.type_2.upper() elif not xlib.check_code(args.type_2, xlib.get_type_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** The type of annotation file has to be {xlib.get_type_code_list_text()}.') OK = False else: args.type_2 = args.type_2.upper() # check "merger_file" if args.merger_file is None: xlib.Message.print('error', '*** The merged file is not indicated in the input arguments.') OK = False # check "merger_operation" if args.merger_operation is None: xlib.Message.print('error', '*** The merger operation is not indicated in the input arguments.') OK = False elif args.merger_operation.upper() == 'SAVE1' and args.annotation_file_2 != 'NONE': xlib.Message.print('error', '*** The merger operation SAVE1 is only valid when the second annotation file is NONE.') OK = False elif args.merger_operation.upper() != 'SAVE1' and not xlib.check_code(args.merger_operation, xlib.get_annotation_merger_operation_code_list(), case_sensitive=False) : xlib.Message.print('error', f'*** The merger operation has to be {xlib.get_annotation_merger_operation_code_list_text()}.') OK = False else: args.merger_operation = args.merger_operation.upper() # check "header" if args.header is None: args.header = xlib.Const.DEFAULT_HEADER elif not xlib.check_code(args.header, xlib.get_header_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** header has to be {xlib.get_header_code_list_text()}.') OK = False else: args.header = args.header.upper() # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_busco_config_file(strict): ''' Check the BUSCO config file of a run. ''' # initialize the control variable and the error list OK = True error_list = [] # intitialize variable used when value is not found not_found = '***NOTFOUND***'.upper() # get the option dictionary try: busco_option_dict = xlib.get_option_dict(get_busco_config_file()) except Exception as e: error_list.append(f'*** EXCEPTION: "{e}".') error_list.append( '*** ERROR: The option dictionary could not be built from the config file' ) OK = False else: # get the sections list sections_list = [] for section in busco_option_dict.keys(): sections_list.append(section) sections_list.sort() # check section "identification" if 'identification' not in sections_list: error_list.append( '*** ERROR: the section "identification" is not found.') OK = False else: # check section "identification" - key "experiment_id" experiment_id = busco_option_dict.get('identification', {}).get( 'experiment_id', not_found) if experiment_id == not_found: error_list.append( '*** ERROR: the key "experiment_id" is not found in the section "identification".' ) OK = False # check section "identification" - key "assembly_software" assembly_software = busco_option_dict.get( 'identification', {}).get('assembly_software', not_found) if assembly_software == not_found: error_list.append( '*** ERROR: the key "assembly_software" is not found in the section "identification".' ) OK = False elif not xlib.check_code(assembly_software, get_assembly_software_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "assembly_software" has to be {get_assembly_software_code_list_text()}.' ) OK = False # check section "identification" - key "assembly_dataset_id" assembly_dataset_id = busco_option_dict.get( 'identification', {}).get('assembly_dataset_id', not_found) if assembly_dataset_id == not_found: error_list.append( '*** ERROR: the key "assembly_dataset_id" is not found in the section "identification".' ) OK = False elif not xlib.check_startswith(assembly_dataset_id, get_assembly_software_code_list(), case_sensitive=True): error_list.append( f'*** ERROR: the key "assembly_dataset_id" has to start with {get_assembly_software_code_list_text()}.' ) OK = False # check section "identification" - key "assembly_type" assembly_type = busco_option_dict.get('identification', {}).get( 'assembly_type', not_found) if assembly_type == not_found: error_list.append( '*** ERROR: the key "assembly_type" is not found in the section "identification".' ) OK = False elif assembly_dataset_id.startswith(xlib.get_soapdenovotrans_code()) and assembly_type.upper() not in ['CONTIGS', 'SCAFFOLDS'] or \ not assembly_dataset_id.startswith(xlib.get_soapdenovotrans_code()) and assembly_type.upper() != 'NONE': error_list.append( f'*** ERROR: the key "assembly_type" has to be CONTIGS or SCAFFOLDS in {xlib.get_soapdenovotrans_name()} or NONE in any other case.' ) OK = False # check section "BUSCO parameters" if 'BUSCO parameters' not in sections_list: error_list.append( '*** ERROR: the section "BUSCO parameters" is not found.') OK = False else: # check section "BUSCO parameters" - key "ncpu" ncpu = busco_option_dict.get('BUSCO parameters', {}).get('ncpu', not_found) if ncpu == not_found: error_list.append( '*** ERROR: the key "ncpu" is not found in the section "BUSCO parameters".' ) OK = False elif not xlib.check_int(ncpu, minimum=1): error_list.append( '*** ERROR: the key "ncpu" has to be an integer number greater than or equal to 1.' ) OK = False # check section "BUSCO parameters" - key "lineage_data_url" lineage_data_url = busco_option_dict.get( 'BUSCO parameters', {}).get('lineage_data_url', not_found) if lineage_data_url == not_found: error_list.append( '*** ERROR: the key "lineage_data_url" is not found in the section "BUSCO parameters"' ) OK = False else: try: urllib.request.urlopen(lineage_data_url) except Exception as e: error_list.append(f'*** EXCEPTION: "{e}".') error_list.append( '*** ERROR: the key "lineage_data_url" has to be a reachable address.' ) OK = False # check section "BUSCO parameters" - key "mode" mode = busco_option_dict.get('BUSCO parameters', {}).get('mode', not_found) if mode == not_found: error_list.append( '*** ERROR: the key "mode" is not found in the section "BUSCO parameters".' ) OK = False elif not xlib.check_code( mode, get_mode_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "mode" has to be {get_mode_code_list_text()}.' ) OK = False # check section "BUSCO parameters" - key "evalue" evalue = busco_option_dict.get('BUSCO parameters', {}).get('evalue', not_found) if evalue == not_found: error_list.append( '*** ERROR: the key "evalue" is not found in the section "BUSCO parameters".' ) OK = False elif not xlib.check_float(evalue, minimum=0., mne=1E-12): error_list.append( '*** ERROR: the key "evalue" has to be a float number greater than 0.' ) OK = False # check section "BUSCO parameters" - key "limit" limit = busco_option_dict.get('BUSCO parameters', {}).get('limit', not_found) if limit == not_found: error_list.append( '*** ERROR: the key "limit" is not found in the section "BUSCO parameters".' ) OK = False elif not xlib.check_int(limit, minimum=1): error_list.append( '*** ERROR: the key "limit" has to be an integer number greater than or equal to 1.' ) OK = False # check section "BUSCO parameters" - key "species" species = busco_option_dict.get('BUSCO parameters', {}).get('species', not_found) if species == not_found: error_list.append( '*** ERROR: the key "species" is not found in the section "BUSCO parameters"' ) OK = False # check section "BUSCO parameters" - key "long" long = busco_option_dict.get('BUSCO parameters', {}).get('long', not_found) if long == not_found: error_list.append( '*** ERROR: the key "long" is not found in the section "BUSCO parameters".' ) OK = False elif not xlib.check_code( long, get_long_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "long" has to be {get_long_code_list_text()}.' ) OK = False # check section "BUSCO parameters" - key "augustus_options" augustus_options = busco_option_dict.get( 'BUSCO parameters', {}).get('augustus_options', not_found) if augustus_options == not_found: error_list.append( '*** ERROR: the key "augustus_options" is not found in the section "BUSCO parameters".' ) OK = False elif augustus_options.upper() != 'NONE': (OK, error_list2) = xlib.check_parameter_list( augustus_options, "augustus_options", []) error_list = error_list + error_list2 # warn that the results config file is not valid if there are any errors if not OK: error_list.append( f'\nThe {xlib.get_busco_name()} config file is not valid. Please, correct this file or recreate it.' ) # return the control variable and the error list return (OK, error_list)
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "toa_database" if args.toa_database is None: xlib.Message.print( 'error', '*** The TOA database is not indicated in the input arguments.') OK = False # check "dataset_id" if args.dataset_id is None: xlib.Message.print( 'error', '*** The dataset identification is not indicated in the input arguments.' ) OK = False else: args.dataset_id = args.dataset_id.lower() # check "blast_file_format" if args.blast_file_format is None: xlib.Message.print( 'error', '*** The BLAST file format is not indicated in the input arguments.' ) OK = False elif not xlib.check_code(args.blast_file_format, xlib.get_blast_file_format_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The BLAST file format has to be {xlib.get_blast_file_format_code_list_text()}.' ) OK = False # check "blast_file" if args.blast_file is None: xlib.Message.print( 'error', '*** The BLAST file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.blast_file): xlib.Message.print('error', f'*** The file {args.blast_file} does not exist.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # initialize the list used to control variables with NONE values none_variable_list = [] # check "toa_database" if args.toa_database is None: xlib.Message.print('error', '*** The TOA database is not indicated in the input arguments.') OK = False # check "transcriptome_file" if args.transcriptome_file is None: xlib.Message.print('error', '*** The transcriptome file is not indicated in the input arguments.') OK = False elif args.transcriptome_file.upper() == 'NONE': args.transcriptome_file = args.transcriptome_file.upper() none_variable_list.append('transcriptome_file') elif not os.path.isfile(args.transcriptome_file): xlib.Message.print('error', f'*** The file {args.transcriptome_file} does not exist.') OK = False # check "peptide_file" if args.peptide_file is None: xlib.Message.print('error', '*** The peptide file is not indicated in the input arguments.') OK = False elif args.peptide_file.upper() == 'NONE': args.peptide_file = args.peptide_file.upper() none_variable_list.append('peptide_file') elif not os.path.isfile(args.peptide_file): xlib.Message.print('error', f'*** The file {args.peptide_file} does not exist.') OK = False # check "dataset_list" if args.dataset_list is None: xlib.Message.print('error', '*** The list of annotation databases is not indicated in the input arguments.') OK = False elif args.dataset_list.upper() == 'NONE': args.dataset_list = args.dataset_list.upper() none_variable_list.append('dataset_list') else: args.dataset_list = xlib.split_literal_to_string_list(args.dataset_list) # check "non_annotation_file_list" if args.non_annotation_file_list is None: xlib.Message.print('error', '*** The list of non annotated file paths is not indicated in the input arguments.') OK = False elif args.non_annotation_file_list.upper() == 'NONE': args.non_annotation_file_list = args.non_annotation_file_list.upper() none_variable_list.append('non_annotation_file_list') else: args.non_annotation_file_list = xlib.split_literal_to_string_list(args.non_annotation_file_list) for non_annotation_file in args.non_annotation_file_list: if not os.path.isfile(non_annotation_file): xlib.Message.print('error', f'*** The file {non_annotation_file} does not exist.') OK = False # check relationships between "transcriptome_file", "peptide_file", "dataset_list" and "non_annotation_file_list" if len(none_variable_list) not in [0, 4] and len(none_variable_list) == 1 and args.peptide_file != 'NONE': xlib.Message.print('error', '*** all values of "transcriptome_file", "peptide_file", "dataset_list" and "non_annotation_file_list" have to be distinct to NONE or all values have to be NONE.') OK = False # check "annotation_file" if args.annotation_file is None: xlib.Message.print('error', '*** The annotation file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.annotation_file): xlib.Message.print('error', f'*** The file {args.annotation_file} does not exist.') OK = False # check "type" if args.type is None: xlib.Message.print('error', '*** The type of annotation file is not indicated in the input arguments.') OK = False elif not xlib.check_code(args.type, xlib.get_type_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** The type of annotation file has to be {xlib.get_type_code_list_text()}.') OK = False else: args.type = args.type.upper() # check "stats_file" if args.stats_file is None: xlib.Message.print('error', '*** The statistics file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Verity the input arguments data. ''' # initialize the control variable OK = True # check "fasta_file" if args.fasta_file is None: xlib.Message.print( 'error', '*** The input FASTA file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.fasta_file): xlib.Message.print('error', f'*** The file {args.fasta_file} does not exist.') OK = False # check the output_file value if args.output_file is None: xlib.Message.print( 'error', '*** A output file where filtered transcripts will be saved is not indicated in the input arguments.' ) OK = False else: try: if not os.path.exists(os.path.dirname(args.output_file)): os.makedirs(os.path.dirname(args.output_file)) except Exception as e: xlib.Message.print('error', f'*** EXCEPTION: "{e}".') xlib.Message.print( 'error', f'*** The directory {os.path.dirname(args.output_file)} of the file {args.output_file} is not valid.' ) OK = False # check the minlen value if args.minlen is None: args.minlen = xlib.Const.DEFAULT_MINLEN elif not xlib.check_int(args.minlen, minimum=1): xlib.Message.print( 'error', '*** The minlen has to be a integer number greater than 0.') OK = False else: args.minlen = int(args.minlen) # check the maxlen value if args.maxlen is None: args.maxlen = xlib.Const.DEFAULT_MAXLEN elif not xlib.check_int(args.maxlen, minimum=1): xlib.Message.print( 'error', '*** The maxlen has to be a integer number greater than 0.') OK = False else: args.maxlen = int(args.maxlen) # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check if maxlen value is greater or equal than minlen value if OK: if args.maxlen < args.minlen: xlib.Message.print( 'error', '*** The maxlen value has to be greater than or equal to minlen.' ) OK = False # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "input_vcf_file" if args.input_vcf_file is None: xlib.Message.print( 'error', '*** The VCF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.input_vcf_file): xlib.Message.print( 'error', f'*** The file {args.input_vcf_file} does not exist.') OK = False # check "sample_file" if args.sample_file is None: xlib.Message.print( 'error', '*** The sample file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.sample_file): xlib.Message.print('error', f'*** The file {args.sample_file} does not exist.') OK = False # check "fix" if args.fix is None: xlib.Message.print('error', '*** Fix is not indicated in the input arguments.') OK = False elif not xlib.check_code( args.fix, xlib.get_fix_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** fix has to be {xlib.get_fix_code_list_text()}.') OK = False else: args.fix = args.fix.upper() # check "scenario" if args.scenario is None: xlib.Message.print( 'error', '*** The scenario is not indicated in the input arguments.') OK = False elif not xlib.check_code(args.scenario, xlib.get_scenario_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The scenario has to be {xlib.get_scenario_code_list_text()}.' ) OK = False # check "min_aa_percentage" if args.min_aa_percentage is None: xlib.Message.print( 'error', '*** The minimum percent of alternative alleles per species is not indicated in the input arguments.' ) OK = False elif not xlib.check_float( args.min_aa_percentage, minimum=0.0, maximum=100.0): xlib.Message.print( 'error', 'The minimum percent of alternative alleles per species has to be a float number between 0.0 and 100.0.' ) OK = False else: args.min_aa_percentage = float(args.min_aa_percentage) # check "min_md_imputation_percentage" if args.min_md_imputation_percentage is None: xlib.Message.print( 'error', '*** The minimum percentage of missing data imputation to a new alternative allele per species is not indicated in the input arguments.' ) OK = False elif not xlib.check_float( args.min_md_imputation_percentage, minimum=0.0, maximum=100.0): xlib.Message.print( 'error', 'The minimum percentage of missing data imputation to a new alternative allele per species has to be a float number between 0.0 and 100.0.' ) OK = False else: args.min_md_imputation_percentage = float( args.min_md_imputation_percentage) # check "imputed_md_id" if args.imputed_md_id is None: args.imputed_md_id = xlib.Const.DEFAULT_IMPUTED_MD_ID # check "sp1_id" if args.sp1_id is None: xlib.Message.print( 'error', '*** The identification of the first species is not indicated in the input arguments.' ) OK = False # check "sp1_max_md_percentage" if args.sp1_max_md_percentage is None: xlib.Message.print( 'error', '*** The maximum percentage of missing data of the first species is not indicated in the input arguments.' ) OK = False elif not xlib.check_float( args.sp1_max_md_percentage, minimum=0.0, maximum=100.0): xlib.Message.print( 'error', 'The maximum percentage of missing data of the first species has to be a float number between 0.0 and 100.0.' ) OK = False else: args.sp1_max_md_percentage = float(args.sp1_max_md_percentage) # check "sp2_id" if args.sp2_id is None: xlib.Message.print( 'error', '*** The identification of the second species is not indicated in the input arguments.' ) OK = False # check "sp2_max_md_percentage" if args.sp2_max_md_percentage is None: xlib.Message.print( 'error', '*** The maximum percentage of missing data of the second species is not indicated in the input arguments.' ) OK = False elif not xlib.check_float( args.sp2_max_md_percentage, minimum=0.0, maximum=100.0): xlib.Message.print( 'error', 'The maximum percentage of missing data of the second species has to be a float number between 0.0 and 100.0.' ) OK = False else: args.sp2_max_md_percentage = float(args.sp2_max_md_percentage) # check "hybrid_id" if args.hybrid_id is None: args.hybrid_id = 'NONE' # check "min_afr_percentage" if args.min_afr_percentage is None: xlib.Message.print( 'error', '*** The minimum percentage of allele frequency per species is not indicated in the input arguments.' ) OK = False elif not xlib.check_float( args.min_afr_percentage, minimum=0.0, maximum=100.0): xlib.Message.print( 'error', 'The minimum percentage of allele frequency per species has to be a float number between 0.0 and 100.0.' ) OK = False else: args.min_afr_percentage = float(args.min_afr_percentage) # check "min_depth" if args.min_depth is None: args.min_depth = xlib.Const.DEFAULT_MIN_DEPTH elif not xlib.check_int(args.min_depth, minimum=1): xlib.Message.print( 'error', 'The minimum combined depth across samples has to be an integer number greater than or equal to 1.' ) OK = False else: args.min_depth = int(args.min_depth) # check "output_vcf_file" if args.output_vcf_file is None: xlib.Message.print( 'error', '*** The output VCF file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check "tvi_list" if args.tvi_list is None or args.tvi_list == 'NONE': args.tvi_list = [] else: args.tvi_list = xlib.split_literal_to_string_list(args.tvi_list) # check the identification set if OK: if args.sp1_id == args.sp2_id or \ args.hybrid_id is not None and (args.sp1_id == args.hybrid_id or args.sp2_id == args.hybrid_id): xlib.Message.print('error', 'The identifications must be different.') OK = False # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "fasta_file_1" if args.fasta_file_1 is None: xlib.Message.print( 'error', '*** The first FASTA file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.fasta_file_1): xlib.Message.print( 'error', f'*** The file {args.fasta_file_1} does not exist.') OK = False # check "fasta_file_2" if args.fasta_file_2 is None: xlib.Message.print( 'error', '*** The second FASTA file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.fasta_file_2): xlib.Message.print( 'error', f'*** The file {args.fasta_file_2} does not exist.') OK = False # check "merged_file" if args.merged_file is None: xlib.Message.print( 'error', '*** The merged file is not indicated in the input arguments.') OK = False # check "merger_operation" if args.merger_operation is None: xlib.Message.print( 'error', '*** The merger operation is not indicated in the input arguments.' ) OK = False elif not xlib.check_code(args.merger_operation, xlib.get_fasta_merger_operation_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The merger operation has to be {xlib.get_fasta_merger_operation_code_list_text()}.' ) OK = False else: args.merger_operation = args.merger_operation.upper() # check "toa_transcriptome_relationship_file" if args.toa_transcriptome_relationship_file is None: args.toa_transcriptome_relationship_file = 'NONE' elif args.toa_transcriptome_relationship_file.upper() == 'NONE': args.toa_transcriptome_relationship_file = args.toa_transcriptome_relationship_file.upper( ) elif not os.path.isfile(args.toa_transcriptome_relationship_file): xlib.Message.print( 'error', f'*** The file {args.toa_transcriptome_relationship_file} does not exist.' ) OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "toa_database" if args.toa_database is None: xlib.Message.print( 'error', '*** The TOA database is not indicated in the input arguments.') OK = False # check "dataset_id" if args.dataset_id is None: xlib.Message.print( 'error', '*** The dataset identification is not indicated in the input arguments.' ) OK = False else: args.dataset_id = args.dataset_id.lower() # check "species_id" if args.species_id is None: xlib.Message.print( 'error', '*** The species identification is not indicated in the input arguments.' ) OK = False else: args.species_id = args.species_id.lower() # check "gene_desc_dir" if args.gene_desc_dir is None: xlib.Message.print( 'error', '*** The gene description file directoty is not indicated in the input arguments.' ) OK = False elif not os.path.isdir(args.gene_desc_dir): xlib.Message.print( 'error', f'*** The directory {args.gene_desc_dir} does not exist.') OK = False # check "interpro_file" if args.interpro_file is None: xlib.Message.print( 'error', '*** The InterPro file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.interpro_file): xlib.Message.print( 'error', f'*** The file {args.interpro_file} does not exist.') OK = False # check "go_file" if args.go_file is None: xlib.Message.print( 'error', '*** The Gene Ontology file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.go_file): xlib.Message.print('error', f'*** The file {args.go_file} does not exist.') OK = False # check "mapman_file" if args.mapman_file is None: xlib.Message.print( 'error', '*** The MapMan file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.mapman_file): xlib.Message.print('error', f'*** The file {args.mapman_file} does not exist.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_cd_hit_est_config_file(strict): ''' check the CD-HIT-EST config file of a run. ''' # initialize the control variable and the error list OK = True error_list = [] # intitialize variable used when value is not found not_found = '***NOTFOUND***'.upper() # get the option dictionary try: cd_hit_est_option_dict = xlib.get_option_dict( get_cd_hit_est_config_file()) except Exception as e: error_list.append(f'*** EXCEPTION: "{e}".') error_list.append( '*** ERROR: The option dictionary could not be built from the config file' ) OK = False else: # get the sections list sections_list = [] for section in cd_hit_est_option_dict.keys(): sections_list.append(section) sections_list.sort() # check section "identification" if 'identification' not in sections_list: error_list.append( '*** ERROR: the section "identification" is not found.') OK = False else: # check section "identification" - key "experiment_id" experiment_id = cd_hit_est_option_dict.get( 'identification', {}).get('experiment_id', not_found) if experiment_id == not_found: error_list.append( '*** ERROR: the key "experiment_id" is not found in the section "identification".' ) OK = False # check section "identification" - key "assembly_software" assembly_software = cd_hit_est_option_dict.get( 'identification', {}).get('assembly_software', not_found) if assembly_software == not_found: error_list.append( '*** ERROR: the key "assembly_software" is not found in the section "identification".' ) OK = False elif not xlib.check_code(assembly_software, get_assembly_software_code_list(), case_sensitive=False): error_list.append( f'*** ERROR: the key "assembly_software" has to be {get_assembly_software_code_list_text()}.' ) OK = False # check section "identification" - key "assembly_dataset_id" assembly_dataset_id = cd_hit_est_option_dict.get( 'identification', {}).get('assembly_dataset_id', not_found) if assembly_dataset_id == not_found: error_list.append( '*** ERROR: the key "assembly_dataset_id" is not found in the section "identification".' ) OK = False elif not xlib.check_startswith(assembly_dataset_id, get_assembly_software_code_list(), case_sensitive=True): error_list.append( f'*** ERROR: the key "assembly_dataset_id" has to start with {get_assembly_software_code_list_text()}.' ) OK = False # check section "identification" - key "assembly_type" assembly_type = cd_hit_est_option_dict.get( 'identification', {}).get('assembly_type', not_found) if assembly_type == not_found: error_list.append( '*** ERROR: the key "assembly_type" is not found in the section "identification".' ) OK = False elif assembly_dataset_id.startswith(xlib.get_soapdenovotrans_code()) and assembly_type.upper() not in ['CONTIGS', 'SCAFFOLDS'] or \ not assembly_dataset_id.startswith(xlib.get_soapdenovotrans_code()) and assembly_type.upper() != 'NONE': error_list.append( f'*** ERROR: the key "assembly_type" has to be CONTIGS or SCAFFOLDS in {xlib.get_soapdenovotrans_name()} or NONE in any other case.' ) OK = False # check section "CD-HIT-EST parameters" if 'CD-HIT-EST parameters' not in sections_list: error_list.append( '*** ERROR: the section "CD-HIT-EST parameters" is not found.') OK = False else: # check section "CD-HIT-EST parameters" - key "threads" threads = cd_hit_est_option_dict.get('CD-HIT-EST parameters', {}).get('threads', not_found) if threads == not_found: error_list.append( '*** ERROR: the key "threads" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif not xlib.check_int(threads, minimum=0): error_list.append( '*** ERROR: the key "threads" has to be an integer number greater than or equal to 0.' ) OK = False # check section "CD-HIT-EST parameters" - key "memory_limit" memory_limit = cd_hit_est_option_dict.get( 'CD-HIT-EST parameters', {}).get('memory_limit', not_found) if memory_limit == not_found: error_list.append( '*** ERROR: the key "memory_limit" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif not xlib.check_int(memory_limit, minimum=0): error_list.append( '*** ERROR: the key "memory_limit" has to be an integer number greater than or equal to 0.' ) OK = False # check section "CD-HIT-EST parameters" - key "seq_identity_threshold" seq_identity_threshold = cd_hit_est_option_dict.get( 'CD-HIT-EST parameters', {}).get('seq_identity_threshold', not_found) if seq_identity_threshold == not_found: error_list.append( '*** ERROR: the key "seq_identity_threshold" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif not xlib.check_float( seq_identity_threshold, minimum=0., maximum=1.): error_list.append( '*** ERROR: the key "seq_identity_threshold" has to be a float number between 0.0 and 1.0.' ) OK = False # check section "CD-HIT-EST parameters" - key "word_length" word_length = cd_hit_est_option_dict.get( 'CD-HIT-EST parameters', {}).get('word_length', not_found) if word_length == not_found: error_list.append( '*** ERROR: the key "word_length" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif not xlib.check_int(word_length, minimum=1): error_list.append( '*** ERROR: the key "word_length" has to be an integer number greater than or equal to 1.' ) OK = False # check section "CD-HIT-EST parameters" - key "mask" mask = cd_hit_est_option_dict.get('CD-HIT-EST parameters', {}).get('mask', not_found) if mask == not_found: error_list.append( '*** ERROR: the key "mask" is not found in the section "CD-HIT-EST parameters".' ) OK = False # check section "CD-HIT-EST parameters" - key "match" match = cd_hit_est_option_dict.get('CD-HIT-EST parameters', {}).get('match', not_found) if match == not_found: error_list.append( '*** ERROR: the key "match" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif not xlib.check_int(match): error_list.append( '*** ERROR: the key "match" has to be an integer number.') OK = False # check section "CD-HIT-EST parameters" - key "mismatch" mismatch = cd_hit_est_option_dict.get('CD-HIT-EST parameters', {}).get( 'mismatch', not_found) if mismatch == not_found: error_list.append( '*** ERROR: the key "mismatch" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif not xlib.check_int(mismatch): error_list.append( '*** ERROR: the key "mismatch" has to be an integer number.' ) OK = False # check section "CD-HIT-EST parameters" - key "other_parameters" not_allowed_parameters_list = [ 'T', 'M', 'c', 'n', 'mask', 'match', 'mismatch' ] other_parameters = cd_hit_est_option_dict.get( 'CD-HIT-EST parameters', {}).get('other_parameters', not_found) if other_parameters == not_found: error_list.append( '*** ERROR: the key "other_parameters" is not found in the section "CD-HIT-EST parameters".' ) OK = False elif other_parameters.upper() != 'NONE': (OK, error_list2) = xlib.check_parameter_list( other_parameters, "other_parameters", not_allowed_parameters_list) error_list = error_list + error_list2 # warn that the results config file is not valid if there are any errors if not OK: error_list.append( f'\nThe {xlib.get_cd_hit_est_name()} config file is not valid. Please, correct this file or recreate it.' ) # return the control variable and the error list return (OK, error_list)
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "xml_file_list" if args.xml_file_list is None: xlib.Message.print( 'error', '*** The list of XML file paths is not indicated in the input arguments.' ) OK = False else: # initialize the XML file list xml_file_list = [] # split "xml_file_list" in a string values list xml_file_list = args.xml_file_list.split(',') # check if XML file exist for i in range(len(xml_file_list)): xml_file_list[i] = xml_file_list[i].strip() if not os.path.isfile(xml_file_list[i]): xlib.Message.print( 'error', f'*** The file {xml_file_list[i].strip()} does not exist.') OK = False # set the argument value args.xml_file_list = xml_file_list # check "toa_transcriptome_relationship_file" if args.toa_transcriptome_relationship_file is None: args.toa_transcriptome_relationship_file = 'NONE' elif args.toa_transcriptome_relationship_file.upper() == 'NONE': args.toa_transcriptome_relationship_file = args.toa_transcriptome_relationship_file.upper( ) elif not os.path.isfile(args.toa_transcriptome_relationship_file): xlib.Message.print( 'error', f'*** The file {args.toa_transcriptome_relationship_file} does not exist.' ) OK = False # check "toa_transdecoder_relationship_file" if args.toa_transdecoder_relationship_file is None: args.toa_transdecoder_relationship_file = 'NONE' elif args.toa_transdecoder_relationship_file.upper() == 'NONE': args.toa_transdecoder_relationship_file = args.toa_transdecoder_relationship_file.upper( ) elif args.toa_transdecoder_relationship_file.upper( ) != 'NONE' and args.toa_transcriptome_relationship_file.upper() == 'NONE': xlib.Message.print( 'error', '*** The TOA-TransDecoder identification relationships file has to be NONE when TOA-transcriptome identification relationships file is NONE.' ) OK = False elif not os.path.isfile(args.toa_transdecoder_relationship_file): xlib.Message.print( 'error', f'*** The file {args.toa_transdecoder_relationship_file} does not exist.' ) OK = False # check "merged_file" if args.merged_file is None: xlib.Message.print( 'error', '*** The merged file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "simhyb_file" if args.simhyb_file is None: xlib.Message.print( 'error', '*** The SimHyb file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.simhyb_file): xlib.Message.print('error', f'*** The file {args.simhyb_file} does not exist.') OK = False # check "header_row_number" if args.header_row_number is None: xlib.Message.print( 'error', '*** The header row number in the SimHyb file is not indicated in the input arguments.' ) OK = False elif not xlib.check_int(args.header_row_number, minimum=0): xlib.Message.print( 'error', 'The header row number in the SimHyb file has to be an integer number greater than or equalt to 0.' ) OK = False else: args.header_row_number = int(args.header_row_number) # check "structure_file" if args.structure_file is None: xlib.Message.print( 'error', '*** The converted Structure file is not indicated in the input arguments.' ) OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "toa_database" if args.toa_database is None: xlib.Message.print( 'error', '*** The TOA database is not indicated in the input arguments.') OK = False # check "ontology_file" if args.ontology_file is None: xlib.Message.print( 'error', '*** The ontology file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.ontology_file): xlib.Message.print( 'error', f'*** The file {args.ontology_file} does not exist.') OK = False # check "ec2go_file" if args.ec2go_file is None: xlib.Message.print( 'error', '*** The ec2go file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.ec2go_file): xlib.Message.print('error', f'*** The file {args.ec2go_file} does not exist.') OK = False # check "kegg2go_file" if args.kegg2go_file is None: xlib.Message.print( 'error', '*** The kegg2go file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.kegg2go_file): xlib.Message.print( 'error', f'*** The file {args.kegg2go_file} does not exist.') OK = False # check "metacyc2go_file" if args.metacyc2go_file is None: xlib.Message.print( 'error', '*** The metacyc2go file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.metacyc2go_file): xlib.Message.print( 'error', f'*** The file {args.metacyc2go_file} does not exist.') OK = False # check "interpro2go_file" if args.interpro2go_file is None: xlib.Message.print( 'error', '*** The interpro2go file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.interpro2go_file): xlib.Message.print( 'error', f'*** The file {args.interpro2go_file} does not exist.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "ngshelper_database" if args.ngshelper_database is None: xlib.Message.print('error', '*** The NGShelper database is not indicated in the input arguments.') OK = False # check "vcf_file" if args.vcf_file is None: xlib.Message.print('error', '*** The VCF file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.vcf_file): xlib.Message.print('error', f'*** The file {args.vcf_file} does not exist.') OK = False # check "sample_file" if args.sample_file is None: xlib.Message.print('error', '*** The sample file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.sample_file): xlib.Message.print('error', f'*** The file {args.sample_file} does not exist.') OK = False # check "sp1_id" if args.sp1_id is None: xlib.Message.print('error', '*** The identification of the first species is not indicated in the input arguments.') OK = False # check "sp2_id" if args.sp2_id is None: xlib.Message.print('error', '*** The identification of the second species is not indicated in the input arguments.') OK = False # check "hybrid_id" if args.hybrid_id is None: args.hybrid_id = 'NONE' # check "imputed_md_id" if args.imputed_md_id is None: args.imputed_md_id = xlib.Const.DEFAULT_IMPUTED_MD_ID # check "new_md_id" if args.new_md_id is None: args.new_md_id = xlib.Const.DEFAULT_NEW_MD_ID # check "allele_transformation" if args.allele_transformation is None: args.allele_transformation = 'NONE' elif not xlib.check_code(args.allele_transformation, xlib.get_allele_transformation_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** The allele transformation has to be {xlib.get_allele_transformation_code_list_text()}.') OK = False else: args.allele_transformation = args.allele_transformation.upper() # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check "tvi_list" if args.tvi_list is None or args.tvi_list == 'NONE': args.tvi_list = [] else: args.tvi_list = xlib.split_literal_to_string_list(args.tvi_list) # check the identification set if OK: if args.sp1_id == args.sp2_id or \ args.hybrid_id is not None and (args.sp1_id == args.hybrid_id or args.sp2_id == args.hybrid_id): xlib.Message.print('error', 'The identifications must be different.') OK = False # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "phase_dir" if args.phase_dir is None: xlib.Message.print('error', '*** The PHASE file directory is not indicated in the input arguments.') OK = False elif not os.path.isdir(args.phase_dir): xlib.Message.print('error', f'*** The directory {args.phase_dir} does not exist.') OK = False # check "phase_extension" if args.phase_extension is None: xlib.Message.print('error', '*** The extension of PHASE files is not indicated in the input arguments.') OK = False # check "sample_file" if args.sample_file is None: xlib.Message.print('error', '*** The sample file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.sample_file): xlib.Message.print('error', f'*** The file {args.sample_file} does not exist.') OK = False # check "sp1_id" if args.sp1_id is None: xlib.Message.print('error', '*** The identification of the first species is not indicated the input arguments.') OK = False # check "sp2_id" if args.sp2_id is None: xlib.Message.print('error', '*** The identification of the second species is not indicated in the input arguments.') OK = False # check "hybrid_id" if args.hybrid_id is None: args.hybrid_id = 'NONE' # check "structure_file" if args.structure_file is None: xlib.Message.print('error', '*** The converted Structure file is not indicated in the input arguments.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code(args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code(args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print('error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Verity the input arguments data. ''' # initialize the control variable OK = True # check the assembly_software_code value if args.assembly_software_code is None: xlib.Message.print( 'error', '*** The assembly software that generated the transcritpme file is not indicated in the input arguments.' ) OK = False elif args.assembly_software_code not in [ xlib.Const.AS_TRINITY_CODE, xlib.Const.AS_SOAPDENOVOTRANS_CODE, xlib.Const.AS_GENERATED_BY_NGSCLOUD ]: xlib.Message.print( 'error', f'*** {args.assembly_software_code} is not a valid code of assembly software.' ) OK = False # check the transcriptome_file value if args.transcriptome_file is None: xlib.Message.print( 'error', '*** A transcritpme file in Fasta format is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.transcriptome_file): xlib.Message.print( 'error', f'*** The file {args.transcriptome_file} does not exist.') OK = False # check the score_file value if args.score_file is None: xlib.Message.print( 'error', '*** A score file where RSEM-EVAL (DETONATE package) saved the score of the transcriptome file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.score_file): xlib.Message.print('error', f'*** The file {args.score_file} does not exist.') OK = False # check the output_file value if args.output_file is None: xlib.Message.print( 'error', '*** A output file where filtered transcripts will be saved is not indicated in the input arguments.' ) OK = False else: try: if not os.path.exists(os.path.dirname(args.output_file)): os.makedirs(os.path.dirname(args.output_file)) except Exception as e: xlib.Message.print( 'error', f'*** The directory {os.path.dirname(args.output_file)} of the file {args.output_file} is not valid.' ) OK = False # check the minlen value if args.minlen is None: args.minlen = xlib.Const.DEFAULT_MINLEN elif not xlib.check_int(args.minlen, minimum=1): xlib.Message.print( 'error', '*** The minlen has to be a integer number greater than 0.') OK = False else: args.minlen = int(args.minlen) # check the maxlen value if args.maxlen is None: args.maxlen = xlib.Const.DEFAULT_MAXLEN elif not xlib.check_int(args.maxlen, minimum=1): xlib.Message.print( 'error', '*** The maxlen has to be a integer number greater than 0.') OK = False else: args.maxlen = int(args.maxlen) # check the minFPKM value if args.minFPKM is None: args.minFPKM = xlib.Const.DEFAULT_MINFPKM elif not xlib.check_float(args.minFPKM, minimum=0.0): print( '*** FPKM has to be a float number greater than or equal to 0.0.') OK = False else: args.minFPKM = float(args.minFPKM) # check the minTPM value if args.minTPM is None: args.minTPM = xlib.Const.DEFAULT_MINTPM elif not xlib.check_float(args.minTPM, minimum=0.0): print( '*** FPKM has to be a float number greater than or equal to 0.0.') OK = False else: args.minTPM = float(args.minTPM) # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # check if maxlen value is greater or equal than minlen value if OK: if args.maxlen < args.minlen: xlib.Message.print( 'error', '*** The maxlen value has to be greater than or equal to minlen.' ) OK = False # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "app" if args.app is None: xlib.Message.print( 'error', '*** The application is not indicated in the input arguments.') OK = False elif not xlib.check_code( args.app, xlib.get_go_app_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** The application has to be {xlib.get_go_app_code_list_text()}.' ) OK = False else: args.app = args.app.upper() # check "annotation_file" if args.annotation_file is None: xlib.Message.print( 'error', '*** The annotation file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.annotation_file): xlib.Message.print( 'error', f'*** The file {args.annotation_file} does not exist.') OK = False # check "ontology_file" if args.ontology_file is None: xlib.Message.print( 'error', '*** The ontology file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.ontology_file): xlib.Message.print( 'error', f'*** The file {args.ontology_file} does not exist.') OK = False # check "output_dir" if args.output_dir is None: xlib.Message.print( 'error', '*** The output directy is not indicated in the input arguments.') OK = False elif not os.path.isdir(args.output_dir): xlib.Message.print('error', '*** The output directy does not exist.') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Verity the input arguments. ''' # initialize the control variable OK = True # check loci_file_path if args.loci_file_path is None: xlib.Message.print( 'error', '*** A loci file path is not indicated in the input arguments.') OK = False else: if not os.path.isfile(args.loci_file_path): xlib.Message.print( 'error', f'*** The file {args.loci_file_path} does not exist.') OK = False if not args.loci_file_path.endswith('.loci'): xlib.Message.print( 'error', f'*** The file {args.loci_file_path} does not end in ".loci".') OK = False # check stats_file_path if args.stats_file_path is None: xlib.Message.print( 'error', '*** A statistics path is not indicated in the input arguments.') OK = False else: if not args.stats_file_path.endswith('.csv'): xlib.Message.print( 'error', f'*** The file {args.stats_file_path} does not end in ".csv".') OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')
def check_args(args): ''' Verity the input arguments data. ''' # initialize the control variable OK = True # check "cos_file" if args.cos_file is None: xlib.Message.print( 'error', '*** The input COS file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.cos_file): xlib.Message.print('error', f'*** The file {args.cos_file} does not exist.') OK = False # check "ssr_file" if args.ssr_file is None: xlib.Message.print( 'error', '*** The input SSR file is not indicated in the input arguments.') OK = False elif not os.path.isfile(args.ssr_file): xlib.Message.print('error', f'*** The file {args.ssr_file} does not exist.') OK = False # check the output_file value if args.output_file is None: xlib.Message.print( 'error', '*** A output file where filtered SSR will be saved is not indicated in the input arguments.' ) OK = False else: try: if not os.path.exists(os.path.dirname(args.output_file)): os.makedirs(os.path.dirname(args.output_file)) except Exception as e: xlib.Message.print('error', f'*** EXCEPTION: "{e}".') xlib.Message.print( 'error', f'*** The directory {os.path.dirname(args.output_file)} of the file {args.output_file} is not valid.' ) OK = False # check "verbose" if args.verbose is None: args.verbose = xlib.Const.DEFAULT_VERBOSE elif not xlib.check_code( args.verbose, xlib.get_verbose_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** verbose has to be {xlib.get_verbose_code_list_text()}.') OK = False if args.verbose.upper() == 'Y': xlib.Message.set_verbose_status(True) # check "trace" if args.trace is None: args.trace = xlib.Const.DEFAULT_TRACE elif not xlib.check_code( args.trace, xlib.get_trace_code_list(), case_sensitive=False): xlib.Message.print( 'error', f'*** trace has to be {xlib.get_trace_code_list_text()}.') OK = False if args.trace.upper() == 'Y': xlib.Message.set_trace_status(True) # if there are errors, exit with exception if not OK: raise xlib.ProgramException('', 'P001')