def restart( start: str, results: str, skip_stages: Optional[List[str]] = None, end: Optional[str] = None, config: Optional[str] = None, cores: Optional[int] = None, memory: Optional[int] = None, ) -> None: """Restart a QUBEKit parametrisation job from the given stage. Must be started from within an old workflow folder. """ # try and load the results file results = WorkFlowResult.parse_file(results) if config is None: # if we have no new config load from results workflow = prep_config(results=results, cores=cores, memory=memory) else: # load the new config file workflow = prep_config(config_file=config, cores=cores, memory=memory) # now run the workflow workflow.restart_workflow(start=start, result=results, skip_stages=skip_stages, end=end)
def run( input_file: Optional[str] = None, smiles: Optional[str] = None, name: Optional[str] = None, multiplicity: int = 1, end: Optional[str] = None, skip_stages: Optional[List[str]] = None, config: Optional[str] = None, protocol: Optional[str] = None, cores: Optional[int] = None, memory: Optional[int] = None, ): """Run the QUBEKit parametrisation workflow on an input molecule.""" # make sure we have an input or smiles not both if input_file is not None and smiles is not None: raise RuntimeError( "Please supply either the name of the input file or a smiles string not both." ) # load the molecule if input_file is not None: molecule = Ligand.from_file(file_name=input_file, multiplicity=multiplicity) else: if name is None: raise RuntimeError( "Please also pass a name for the molecule when starting from smiles." ) molecule = Ligand.from_smiles(smiles_string=smiles, name=name, multiplicity=multiplicity) # load workflow workflow = prep_config(config_file=config, memory=memory, cores=cores, protocol=protocol) # move into the working folder and run with folder_setup( f"QUBEKit_{molecule.name}_{datetime.now().strftime('%Y_%m_%d')}"): # write the starting molecule molecule.to_file(file_name=f"{molecule.name}.pdb") workflow.new_workflow(molecule=molecule, skip_stages=skip_stages, end=end)
def run( bulk_file: str, skip_stages: Optional[List[str]] = None, end: Optional[str] = None, restart: Optional[str] = None, config: Optional[str] = None, protocol: Optional[str] = None, cores: Optional[int] = None, memory: Optional[int] = None, ) -> None: """Run the QUBEKit parametrisation workflow on a collection of molecules in serial. Loop over the molecules in order of the CSV file. """ import glob import os from qubekit.utils.helpers import mol_data_from_csv home = os.getcwd() # load all inputs bulk_data = mol_data_from_csv(bulk_file) # start main molecule loop for name, mol_data in bulk_data.items(): print(f"Analysing: {name}") try: if restart is not None or mol_data["restart"] is not None: # we are trying to restart a run, find the folder # should only be one fname = name.split(".")[0] folder = glob.glob(f"QUBEKit_{fname}_*")[0] with folder_setup(folder): results = WorkFlowResult.parse_file("workflow_result.json") if config is None: # if we have no new config load from results workflow = prep_config( results=results, cores=cores, memory=memory, protocol=None ) else: # load the new config file workflow = prep_config( config_file=config, cores=cores, memory=memory ) workflow.restart_workflow( start=restart or mol_data["restart"], skip_stages=skip_stages, end=end or mol_data["end"], result=results, ) else: if mol_data["smiles"] is not None: molecule = Ligand.from_smiles( smiles_string=mol_data["smiles"], name=name ) else: molecule = Ligand.from_file(file_name=name) # load the CLI config or the csv config, else default workflow = prep_config( config_file=config or mol_data["config_file"], memory=memory, cores=cores, protocol=protocol, ) # move into the working folder and run with folder_setup( f"QUBEKit_{molecule.name}_{datetime.now().strftime('%Y_%m_%d')}" ): # write the starting molecule molecule.to_file(file_name=f"{molecule.name}.pdb") workflow.new_workflow( molecule=molecule, skip_stages=skip_stages, end=end or mol_data["end"], ) except WorkFlowExecutionError: os.chdir(home) print( f"An error was encountered while running {name} see folder for more info." ) continue