def test_run(self): path = EnvironmentSettings.tmp_test_path / "galaxy_api_dataset_generation/" PathBuilder.build(path) yaml_path = path / "specs.yaml" result_path = path / "results/" PathBuilder.build(path) self.prepare_specs(yaml_path) run_immuneML( Namespace( **{ "specification_path": yaml_path, "result_path": result_path, 'tool': "DatasetGenerationTool" })) self.assertTrue( os.path.isfile(result_path / "result/dataset_metadata.csv")) self.assertTrue( os.path.isfile(result_path / "result/dataset.iml_dataset")) self.assertEqual( 200, len([ name for name in os.listdir(result_path / "result/repertoires/") if os.path.isfile( os.path.join(result_path / "result/repertoires/", name)) ])) shutil.rmtree(path)
def test_run(self): path = EnvironmentSettings.tmp_test_path / "galaxy_api_dataset_simulation/" PathBuilder.build(path) yaml_path = path / "specs.yaml" result_path = path / "results/" specs = {'definitions': { "datasets": { "d1": { "format": "RandomRepertoireDataset", "params": { "repertoire_count": 100, "sequence_count_probabilities": { 100: 1 }, "sequence_length_probabilities": { 10: 1 }, "labels": {} } } } }, "instructions": { "inst1": {"type": "DatasetExport", "export_formats": ["ImmuneML"], "datasets": ["d1"]} } } with open(yaml_path, "w") as file: yaml.dump(specs, file) PathBuilder.build(path) run_immuneML(Namespace(**{"specification_path": yaml_path, "result_path": result_path, 'tool': "DataSimulationTool"})) self.assertTrue(os.path.isfile(result_path / "result/dataset_metadata.csv")) self.assertTrue(os.path.isfile(result_path / "result/dataset.iml_dataset")) self.assertEqual(200, len([name for name in os.listdir(result_path / "result/repertoires/") if os.path.isfile(os.path.join(result_path / "result/repertoires/", name))])) shutil.rmtree(path)
def test_run1(self): path = PathBuilder.build(EnvironmentSettings.tmp_test_path / "api_galaxy_yaml_tool1/") result_path = path / "result/" dataset = RandomDatasetGenerator.generate_repertoire_dataset(10, {10: 1}, {12: 1}, {}, result_path) dataset.name = "d1" ImmuneMLExporter.export(dataset, result_path) specs = { "definitions": { "datasets": { "new_d1": { "format": "ImmuneML", "params": { "metadata_file": str(result_path / "d1_metadata.csv") } } }, }, "instructions": { "inst1": { "type": "DatasetExport", "datasets": ["new_d1"], "export_formats": ["AIRR"] } } } specs_path = path / "specs.yaml" with open(specs_path, "w") as file: yaml.dump(specs, file) run_immuneML(Namespace(**{"specification_path": specs_path, "result_path": result_path / 'result/', 'tool': "GalaxyYamlTool"})) self.assertTrue(os.path.exists(result_path / "result/inst1/dataset/AIRR")) shutil.rmtree(path)
def test_run(self): path = PathBuilder.build(EnvironmentSettings.tmp_test_path / "api_galaxy_trainmlmodel_tool/") result_path = path / "result/" specs = { "definitions": { "datasets": { "d2": { "format": "RandomRepertoireDataset", "params": { "repertoire_count": 50, "sequence_length_probabilities": { 10: 1 }, 'sequence_count_probabilities': { 10: 1 }, 'labels': { "CD": { True: 0.5, False: 0.5 } } } } }, "encodings": { "e1": { "Word2Vec": { "k": 3, "model_type": "sequence", "vector_size": 8, } }, "e2": { "Word2Vec": { "k": 3, "model_type": "sequence", "vector_size": 10, } }, }, "ml_methods": { "simpleLR": { "LogisticRegression": { "penalty": "l1" }, "model_selection_cv": False, "model_selection_n_folds": -1, } }, }, "instructions": { "inst2": { "type": "TrainMLModel", "settings": [{ "encoding": "e1", "ml_method": "simpleLR" }, { "encoding": "e2", "ml_method": "simpleLR" }], "assessment": { "split_strategy": "random", "split_count": 1, "training_percentage": 0.7 }, "selection": { "split_strategy": "random", "split_count": 2, "training_percentage": 0.7 }, "labels": ["CD"], "dataset": "d2", "strategy": "GridSearch", "metrics": ["accuracy", "auc"], "reports": [], "number_of_processes": 10, "optimization_metric": "accuracy", 'refit_optimal_model': False, "store_encoded_data": False } } } specs_path = path / "specs.yaml" with open(specs_path, "w") as file: yaml.dump(specs, file) run_immuneML( Namespace( **{ "specification_path": specs_path, "result_path": result_path, 'tool': "GalaxyTrainMLModel" })) self.assertTrue( os.path.exists(result_path / "exported_models/ml_model_CD.zip")) self.assertTrue(os.path.exists(result_path / "index.html")) shutil.rmtree(path)
def test_run(self): path = PathBuilder.build(EnvironmentSettings.tmp_test_path / "api_galaxy_simulation_tool/") result_path = path / "result" specs = { "definitions": { "datasets": { "d1": { "format": "RandomRepertoireDataset", "params": { "repertoire_count": 50, "sequence_length_probabilities": {10: 1}, 'sequence_count_probabilities': {10: 1}, 'labels': { "CD": { True: 0.5, False: 0.5 } } } } }, "motifs": { "motif1": { "seed": "E/E", "instantiation": { "GappedKmer": { "max_gap": 1 }, } }, "motif2": { "seed": "TTT", "instantiation": "GappedKmer" } }, "signals": { "signal1": { "motifs": ["motif1", "motif2"], "implanting": "HealthySequence", "sequence_position_weights": None } }, "simulations": { "sim1": { "var1": { "signals": ["signal1"], "dataset_implanting_rate": 0.5, "repertoire_implanting_rate": 0.5 } } }, }, "instructions": { "inst1": { "type": "Simulation", "dataset": "d1", "simulation": "sim1", "export_formats": ["AIRR"] }, } } specs_path = path / "specs.yaml" with open(specs_path, "w") as file: yaml.dump(specs, file) run_immuneML(Namespace(**{"specification_path": specs_path, "result_path": result_path / 'result/', 'tool': "GalaxySimulationTool"})) shutil.rmtree(path)