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 "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 "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 "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 # 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): ''' Check the input arguments. ''' # initialize the control variable OK = True # check "gff_file" if args.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.gff_file): xlib.Message.print('error', f'*** The file {args.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 "genome_file" if args.genome_file is None: xlib.Message.print( 'error', '*** The FASTA genome file is not indicated in the input arguments.' ) OK = False elif not os.path.isfile(args.genome_file): xlib.Message.print('error', f'*** The file {args.genome_file} does not exist.') OK = False # check "rna_file" if args.rna_file is None: xlib.Message.print( 'error', '*** The output FASTA file with the RNA sequences 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 "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')