[docs]defrun(self):try:print_log(f"Running immuneML version {Constants.VERSION}\n",include_datetime=True)self.set_cache()print_log(f"immuneML: parsing the specification...\n",include_datetime=True)symbol_table,self._specification_path=ImmuneMLParser.parse_yaml_file(self._specification_path,self._result_path)print_log(f"immuneML: starting the analysis...\n",include_datetime=True)instructions=symbol_table.get_by_type(SymbolType.INSTRUCTION)output=symbol_table.get("output")model=SemanticModel([instruction.itemforinstructionininstructions],self._result_path,output)result=model.run()self.clear_cache()print_log(f"ImmuneML: finished analysis.\n",include_datetime=True)returnresultexcept(ModuleNotFoundError,ImportError)ase:sys_exit(f"{e}\n\nAn error occurred when trying to import a package. Please check if all necessary "f"packages are installed correctly. See the log above for more details.")exceptExceptionase:traceback.print_exc()raisee
[docs]defrun_immuneML(namespace:argparse.Namespace):ifos.path.isdir(namespace.result_path)andlen(os.listdir(namespace.result_path))!=0:result_path=f"{namespace.result_path}_{datetime.now()}"print(f"Directory {namespace.result_path} already exists. The output of this analysis will be "f"stored in {result_path}.")else:result_path=namespace.result_pathPathBuilder.build(result_path)ifnamespace.toolisNone:app=ImmuneMLApp(namespace.specification_path,result_path,namespace.logging)else:app_cls=ReflectionHandler.get_class_by_name(namespace.tool,"api/")app=app_cls(**vars(namespace))app.run()
[docs]defmain():parser=argparse.ArgumentParser(description="immuneML command line tool")parser.add_argument("specification_path",help="Path to specification YAML file. Always used to define the ""analysis.")parser.add_argument("result_path",help="Output directory path.")parser.add_argument("--tool",help="Name of the tool which calls immuneML. This name will be used to invoke ""appropriate API call, which will then do additional work in tool-dependent ""way before running standard immuneML.")parser.add_argument('--logging',help='Logging level to use',choices=['DEBUG','INFO','WARNING','ERROR','CRITICAL'],default='INFO')parser.add_argument("--version",action="version",version=Constants.VERSION)namespace=parser.parse_args()namespace.specification_path=Path(namespace.specification_path)namespace.result_path=Path(namespace.result_path)run_immuneML(namespace)