示例#1
0
    def _prepare_specs(self):
        with open(self.yaml_path, "r") as file:
            specs = yaml.safe_load(file)

        ParameterValidator.assert_keys_present(specs.keys(),
                                               ["definitions", "instructions"],
                                               GalaxyTrainMLModel.__name__,
                                               "YAML specification")
        ParameterValidator.assert_all_in_valid_list(
            specs.keys(), ["definitions", "instructions", "output"],
            GalaxyTrainMLModel.__name__, "YAML specification")

        ParameterValidator.assert_type_and_value(specs["instructions"], dict,
                                                 GalaxyTrainMLModel.__name__,
                                                 "instructions")

        assert len(list(specs["instructions"].keys())) == 1, f"{GalaxyTrainMLModel.__name__}: one instruction has to be specified under " \
                                                             f"`instructions`, got the following instead: {list(specs['instructions'].keys())}."

        self.instruction_name = list(specs["instructions"].keys())[0]

        ParameterValidator.assert_type_and_value(
            specs['instructions'][self.instruction_name], dict,
            GalaxyTrainMLModel.__name__, self.instruction_name)
        ParameterValidator.assert_keys_present(
            specs['instructions'][self.instruction_name].keys(), ['type'],
            GalaxyTrainMLModel.__name__, self.instruction_name)

        assert specs['instructions'][self.instruction_name]['type'] == TrainMLModelInstruction.__name__[:-11], \
            f"{GalaxyTrainMLModel.__name__}: instruction `type` under {self.instruction_name} has to be {TrainMLModelInstruction.__name__[:-11]} " \
            f"for this tool."

        Util.check_paths(specs, GalaxyTrainMLModel.__name__)
        Util.update_result_paths(specs, self.result_path, self.yaml_path)
示例#2
0
    def update_specs(self):
        with open(self.yaml_path, 'r') as file:
            specs = yaml.safe_load(file)

        ParameterValidator.assert_keys_present(specs.keys(), ["definitions", "instructions"], DatasetGenerationTool.__name__, "YAML specification")
        ParameterValidator.assert_all_in_valid_list(specs.keys(), ["definitions", "instructions", "output"], DatasetGenerationTool.__name__, "YAML specification")

        self._check_dataset(specs)
        self._check_instruction(specs)

        Util.check_paths(specs, DatasetGenerationTool.__name__)
        Util.update_result_paths(specs, self.result_path, self.yaml_path)
示例#3
0
    def _run(self):
        self.prepare_specs()

        Util.run_tool(self.yaml_path, self.result_path)

        dataset_location = list(
            glob(self.result_path + "/*/exported_dataset/*/"))[0]
        shutil.copytree(dataset_location, self.result_path + 'result/')

        logging.info(
            f"{GalaxySimulationTool.__name__}: immuneML has finished and the signals were implanted in the dataset."
        )
示例#4
0
    def _check_instruction(self, specs):
        instruction_name = Util.check_instruction_type(specs, DatasetGenerationTool.__name__, DatasetExportInstruction.__name__[:-11])

        for key in ['datasets', 'export_formats']:
            ParameterValidator.assert_keys_present(list(specs['instructions'][instruction_name].keys()), [key], DatasetGenerationTool.__name__,
                                                   instruction_name)
            ParameterValidator.assert_type_and_value(specs["instructions"][instruction_name][key], list, DatasetGenerationTool.__name__,
                                                     f"{instruction_name}/{key}")

            assert len(specs['instructions'][instruction_name][key]) == 1, \
                f"{DatasetGenerationTool.__name__}: this tool accepts only one item under {key}, got {specs['instructions'][instruction_name][key]} " \
                f"instead."
示例#5
0
    def prepare_specs(self):
        with open(self.yaml_path, "r") as file:
            specs = yaml.safe_load(file)

        instruction_name = Util.check_instruction_type(
            specs, GalaxySimulationTool.__name__,
            SimulationInstruction.__name__[:-11])
        Util.check_export_format(specs, GalaxySimulationTool.__name__,
                                 instruction_name)

        Util.check_paths(specs, "GalaxySimulationTool")
        Util.update_result_paths(specs, self.result_path, self.yaml_path)
示例#6
0
 def __init__(self, specification_path, result_path, **kwargs):
     Util.check_parameters(specification_path, result_path, kwargs,
                           "GalaxyYamlTool")
     super().__init__(specification_path, result_path, **kwargs)
示例#7
0
    def update_specs(self):
        with open(self.yaml_path, "r") as file:
            specs_dict = yaml.safe_load(file)

        Util.check_paths(specs_dict, 'GalaxyYamlTool')
        Util.update_result_paths(specs_dict, self.result_path, self.yaml_path)
示例#8
0
 def __init__(self, specification_path, result_path, **kwargs):
     Util.check_parameters(specification_path, result_path, kwargs,
                           GalaxyTrainMLModel.__name__)
     super().__init__(specification_path, result_path, **kwargs)
     self.instruction_name = None
示例#9
0
 def __init__(self, specification_path, result_path, **kwargs):
     Util.check_parameters(specification_path, result_path, kwargs, "Dataset generation tool")
     super().__init__(specification_path, result_path, **kwargs)
示例#10
0
 def __init__(self, specification_path, result_path, **kwargs):
     Util.check_parameters(specification_path, result_path, kwargs,
                           GalaxySimulationTool.__name__)
     super().__init__(specification_path, result_path, **kwargs)