def set_up_manager_and_out(): """ Function to set up the CapiceManager and testing output location :return: manager instance, output_directory """ manager = CapiceManager() manager.critical_logging_only = True root_dir = _project_root_directory output_directory = os.path.join(root_dir, '.test_output') if not os.path.exists(output_directory): os.makedirs(output_directory) return manager, output_directory
def __init__(self): self.version = __version__ self.parser = argparse.ArgumentParser( description= "CAPICE, a machine-learning-based method for prioritizing pathogenic" " variants https://doi.org/10.1186/s13073-020-00775-w") self.manager = CapiceManager()
def setUpClass(cls): print('Setting up.') cls.manager = CapiceManager() cls.manager.loglevel = 10 with open( os.path.join(_project_root_directory, 'tests', 'resources', 'xgb_booster_poc.pickle.dat'), 'rb') as model_file: cls.model = pickle.load(model_file)
def _handle_module_specific_args(self, input_path, output_path, output_filename, output_given, args): model_path = input_path with open(model_path, 'rb') as model_file: model = pickle.load(model_file) validator = ModelValidator() validator.validate_is_xgb_classifier(model) validator.validate_has_required_attributes(model) CapiceManager().output_filename = output_filename CapiceExplain(model, output_path, output_given).run()
def __init__(self): self.global_settings = CapiceManager() self.stdout = False self.stdout_filter = [] self.stderr_loglevel = 50 self.min_loglevel = 50 self.set_stderr_loglevel() self.logger = None if self.logger is None: self.load_logger()
def __init__(self, file_path, output_given): self.log = Logger().logger self.capice_filename = CapiceManager().output_filename self.file_path = file_path self.output_given = output_given self.export_cols = [ Column.chr.value, Column.pos.value, Column.ref.value, Column.alt.value, Column.gene_name.value, Column.gene_id.value, Column.id_source.value, Column.feature.value, Column.feature_type.value, Column.score.value, Column.suggested_class.value ]
def setUpClass(cls) -> None: with open( os.path.join( _project_root_directory, 'tests', 'resources', 'xgb_booster_poc.pickle.dat' ), 'rb' ) as model_file: cls.model = pickle.load(model_file) if not os.path.isdir(cls.output_path): os.makedirs(cls.output_path) CapiceManager().output_filename = cls.output_filename
def _handle_module_specific_args(self, input_path, output_path, output_filename, output_given, args): impute = self.validate_length_one(args.impute, '-m/--impute') self.validate_input_json(impute) test_split = self.validate_length_one(args.split, '-s/--split') if test_split is None: test_split = self.split_default # Since argparse doesn't cooperate well with default values and always # returns them as a list, this has to be done. if isinstance(test_split, list): test_split = test_split[0] self.validate_test_split(test_split) n_threads = args.threads self.validate_n_threads(n_threads) CapiceManager().output_filename = output_filename CapiceTrain(input_path, impute, test_split, output_path, output_given, n_threads).run()
def __init__(self, exclude_features: list, model_features: list = None): """ :param exclude_features: list, all the features that the preprocessor should not process. Features that are already excluded include: chr_pos_ref_alt, chr and pos. :param model_features: list (default None), a list containing all the features present within a model file. """ self.log = Logger().logger self.manager = CapiceManager() self.log.info('Preprocessor started.') self.train = False self.exclude_features = [ Column.chr_pos_ref_alt.value, Column.chr.value, Column.pos.value ] self.exclude_features += exclude_features self.model_features = model_features self.objects = []
def __init__(self, input_path, output_path, output_given): # Assumes CapiceManager has been initialized & filled. self.manager = CapiceManager() self.log = Logger().logger self.log.info('Initiating selected mode.') # Input file. self.infile = input_path self.log.debug('Input argument -i / --input confirmed: %s', self.infile) # Output file. self.output = output_path self.log.debug('Output directory -o / --output confirmed: %s', self.output) self.output_given = output_given # Preprocessor global exclusion features # Overwrite in specific module if features are incorrect self.exclude_features = [Column.gene_name.value, Column.gene_id.value, Column.id_source.value, Column.feature.value, Column.feature_type.value]
def _export(self, dataset, output): output_path = os.path.join(output, CapiceManager().output_filename) dataset.to_csv(output_path, compression='gzip', index=False, sep='\t') if not self.output_given: print(f'Successfully exported explain to: {output_path}')
def _handle_module_specific_args(self, input_path, output_path, output_filename, output_given, args): model_path = self.validate_length_one(args.model, '-m/--model') model = self.validate_model(model_path) CapiceManager().output_filename = output_filename CapicePredict(input_path, model, output_path, output_given).run()
def setUpClass(cls): print('Setting up.') cls.manager = CapiceManager() cls.manager.critical_logging_only = False cls.not_present_string = 'Not present string'