예제 #1
0
 def test_create_output_loc(self):
     print('Creating output location')
     dir_to_be_created = os.path.join(get_project_root_dir(),
                                      '.another_test_output')
     self.input_checker.check_output_loc(dir_to_be_created)
     self.assertTrue(
         '.another_test_output' in os.listdir(get_project_root_dir()))
예제 #2
0
 def setUpClass(cls):
     print('Setting up.')
     cls.input_loc = os.path.join(get_project_root_dir(), 'CAPICE_example')
     root_dir = get_project_root_dir()
     cls.output_directory = os.path.join(root_dir, '.test_output')
     if not os.path.exists(cls.output_directory):
         os.makedirs(cls.output_directory)
     cls.input_checker = InputChecker()
예제 #3
0
 def test_log_checker_both(self):
     print('Log checker with both output and log_loc given')
     log_output = os.path.join(get_project_root_dir(), '.test_log_output')
     logchecker = LogChecker(log_loc=log_output,
                             output_loc=self.output_directory)
     logchecker.check_log_loc()
     self.assertTrue(
         '.test_log_output' in os.listdir(get_project_root_dir()))
예제 #4
0
 def test_log_checker_output(self):
     print('Log checker with only output given')
     logchecker = LogChecker(log_loc=None,
                             output_loc=os.path.join(
                                 get_project_root_dir(),
                                 '.another_test_log_output'))
     logchecker.check_log_loc()
     self.assertTrue(
         '.another_test_log_output' in os.listdir(get_project_root_dir()))
예제 #5
0
 def _load_preprocessors(self):
     """
     Function to dynamically load in the preprocessors modules,
     but must have the following properties:
         name,
         supported_vep_version and
         supported_genomebuild_version.
     """
     self.log.info('Identifying preprocessing files.')
     directory = os.path.join(get_project_root_dir(),
                              'src',
                              'main',
                              'python',
                              'resources',
                              'models')
     usable_modules = load_modules(directory)
     if len(usable_modules) < 1:
         self._raise_no_module_found_error()
     imported_modules = importer(
         usable_modules=usable_modules,
         path=directory
     )
     for module in imported_modules:
         if "name" in dir(module) and "supported_vep_version" in dir(
                 module) and "supported_grch_build" in dir(module):
             self.preprocessors.append(module)
     if len(self.preprocessors) < 1:
         self._raise_no_module_found_error()
     self.log.info(
         'Succesfully loaded {} preprocessors.'.format(
             len(self.preprocessors)
         )
     )
예제 #6
0
 def setUpClass(cls):
     print('Setting up.')
     cls.manager, output_loc = set_up_manager_and_loc()
     input_file = os.path.join(get_project_root_dir(), 'CAPICE_example',
                               'CAPICE_input.tsv.gz')
     cls.main = set_up_main()
     cls.main.infile = input_file
예제 #7
0
 def _load_modules(self):
     """
     Method to dynamically load in all python files containing a class that
     contains the properties
         name and
         _json_name.
     If at the end of this function, the list of impute files is empty,
     will throw the module not found error.
     """
     self.log.info('Identifying imputing files.')
     directory = os.path.join(get_project_root_dir(), 'src', 'main',
                              'python', 'resources', 'data_files',
                              'imputing')
     usable_modules = load_modules(directory)
     if len(usable_modules) < 1:
         self._raise_no_module_found_error()
     loaded_modules = importer(usable_modules=usable_modules,
                               path=directory)
     for module in loaded_modules:
         if "name" in dir(module) and "_json_name" in dir(module):
             self.modules.append(module)
     if len(self.modules) < 1:
         self._raise_no_module_found_error()
     self.log.info(
         'Identified {} files available for usage in imputing.'.format(
             len(self.modules)))
예제 #8
0
 def test_unit_load_specified_defaults(self):
     """
     Unit test to see if specified default hyper parameters can be loaded.
     """
     print('Load_specified_defaults (unit)')
     self.main.specified_default = os.path.join(get_project_root_dir(), 'CAPICE_example', 'specified_defaults.json')
     self.main.load_defaults()
예제 #9
0
 def tearDownClass(cls):
     print('Tearing down.')
     to_remove = [
         '.another_test_log_output', '.test_log_output',
         '.another_test_output'
     ]
     for removal in to_remove:
         os.rmdir(os.path.join(get_project_root_dir(), removal))
     teardown()
예제 #10
0
 def setUpClass(cls):
     print('Setting up.')
     manager, output_loc = set_up_manager_and_loc()
     cls.main = set_up_main()
     cls.main.infile = os.path.join(get_project_root_dir(),
                                    'CAPICE_example',
                                    'CAPICE_input.tsv.gz')
     manager.overwrite_model = 'CAPICE using XGBoost 0.72.1,' \
                               ' CADD 1.4 and genome build 37.'
예제 #11
0
 def _json_loc(self):
     path = os.path.join(get_project_root_dir(), 'src', 'main', 'python',
                         'resources', 'data_files', 'json_data')
     json_name = self._json_name()
     if json_name == 'none':
         error_message = 'Location of JSON must be specified!'
         self.log.critical(error_message)
         raise FileNotFoundError(error_message)
     return os.path.join(path, json_name)
예제 #12
0
 def setUpClass(cls):
     print('Setting up.')
     cls.manager, output_loc = set_up_manager_and_loc()
     cls.vep_version = 104.0
     cls.grch_build = 37
     cls.impute_overwrite = 'VEP104'
     cls.main = set_up_main()
     cls.main.infile = os.path.join(get_project_root_dir(),
                                    'CAPICE_example', 'CAPICE_input.tsv.gz')
예제 #13
0
def teardown():
    """
    Function to remove any and all files from the '.test_output' folder and
    remove the folder itself too.
    """
    test_folder = os.path.join(get_project_root_dir(), '.test_output')
    if len(os.listdir(test_folder)) > 0:
        for file in os.listdir(test_folder):
            os.remove(os.path.join(test_folder, file))
    os.rmdir(test_folder)
    Logger.instance = None
예제 #14
0
 def setUpClass(cls):
     print('Setting up.')
     cls.manager, cls.output_dir = set_up_manager_and_loc()
     cls.manager.overwrite_impute = 'CADD 1.4, GRCh build 37'
     train_file = os.path.join(get_project_root_dir(), 'CAPICE_example', 'train_dataset.tsv.gz')
     ConfigReader().parse()
     cls.main = Train(__program__=__program__,
                      __author__=__author__,
                      __version__=__version__,
                      input_loc=train_file,
                      output_loc=cls.output_dir)
예제 #15
0
 def test_component_load_specified_defaults(self):
     """
     Component test to see if specified default hyper parameters are loaded correctly.
     """
     print('Load_specified_defaults (component)')
     self.main.specified_default = os.path.join(get_project_root_dir(), 'CAPICE_example', 'specified_defaults.json')
     self.main.load_defaults()
     defaults = self.main.defaults
     self.assertEqual(defaults['learning_rate'], 0.5)
     self.assertEqual(defaults['max_depth'], 10)
     self.assertEqual(defaults['n_estimators'], 10)
예제 #16
0
 def setUpClass(cls):
     print('Setting up.')
     cls.manager = CapiceManager()
     cls.output_loc = os.path.join(get_project_root_dir(), '.test_output')
     if not os.path.exists(cls.output_loc):
         os.makedirs(cls.output_loc)
     cls.manager.now = datetime.now()
     cls.manager.log_loc = cls.output_loc
     cls.manager.critical_logging_only = False
     cls.manager.enable_logfile = True
     cls.log = Logger().logger
예제 #17
0
파일: manual.py 프로젝트: SietsmaRJ/capice
 def __init__(self):
     self.log = Logger().logger
     self.vep_annotators = []
     self.location = os.path.join(get_project_root_dir(),
                                  'src',
                                  'main',
                                  'python',
                                  'resources',
                                  'annotaters',
                                  'vep')
     self._load_vep_annotators()
예제 #18
0
def set_up_manager_and_loc():
    """
    Function to set up the CapiceManager and testing output location
    :return: manager instance, output_directory
    """
    manager = CapiceManager()
    manager.now = datetime.now()
    manager.enable_logfile = False
    manager.critical_logging_only = True
    manager.verbose = False
    root_dir = get_project_root_dir()
    output_directory = os.path.join(root_dir, '.test_output')
    if not os.path.exists(output_directory):
        os.makedirs(output_directory)
    config_reader = ConfigReader()
    config_reader.parse()
    manager.reference_genome = config_reader.get_datafiles_value('reference')
    return manager, output_directory
예제 #19
0
 def _get_model_loc():
     model_loc = os.path.join(get_project_root_dir(), 'CAPICE_model',
                              'GRCh37', 'xgb_booster.pickle.dat')
     return model_loc
예제 #20
0
 def _parse(self):
     self.config.read(os.path.join(get_project_root_dir(), 'config.cfg'))