MolecularDiffusion.runmodes.generate.tasks_generate¶
Attributes¶
Classes¶
Entry point for all ShEPhERD pharmacophore generation modes. |
Module Contents¶
- class MolecularDiffusion.runmodes.generate.tasks_generate.GenerativeFactory(task: MolecularDiffusion.modules.tasks.task.Task, task_type: str = 'unconditional', sampling_mode: str = 'ddpm', num_generate: int = 100, mol_size: List[int] = [0, 0], target_values: List[float] = [], property_names: List[str] = [], negative_target_values: List[float] = [], batch_size: int = 1, seed: int = 86, n_frames: int = 0, output_path: str = 'generated_mol', condition_configs={}, max_mol_size: int = 0)¶
- conditional_generation()¶
- hybrid_guidance()¶
- preprocess_ref_structure(device)¶
Load and preprocess a reference molecular structure from an XYZ file.
This function reads an XYZ file, encodes atomic features, normalizes coordinates and features, and returns a tensor combining positions and processed features. When the model uses extra node features (ndim_extra > 0), they are either computed from the reference structure or zero-padded.
- Returns:
- Tensor of shape (1, n_atoms, 3 + n_features + ndim_extra + 1)
containing [normalized_coords | normalized_onehot | normalized_extra | normalized_charges].
- Return type:
- Raises:
FileNotFoundError – If the reference structure file is not found.
ValueError – If the processed reference structure is empty.
- property_guidance()¶
- property_prediction(xh: torch.Tensor, t: int)¶
- run()¶
- structural_guidance()¶
- unconditional_generation()¶
- batch_size = 1¶
- condition_configs¶
- max_mol_size = 0¶
- mol_size = [0, 0]¶
- n_frames = 0¶
- negative_target_values = []¶
- num_generate = 100¶
- output_path = 'generated_mol'¶
- property_names = []¶
- sampling_mode = 'ddpm'¶
- seed = 86¶
- target_values = []¶
- task¶
- task_type = 'unconditional'¶
- class MolecularDiffusion.runmodes.generate.tasks_generate.PharmacophoreConditionGenerator(task, task_type: str = 'pharmacophore_condition', num_generate: int = 10, batch_size: int = 1, N_x1: list = [20], N_x4: int = 5, N_x1_sampling: str = 'uniform', distributions_path: str = None, distributions_key: str = 'gdb', num_steps: int = 400, prior_noise_scale: float = 1.0, denoising_noise_scale: float = 1.0, output_path: str = 'generated_pharmacophore', seed: int = 42, verbose: bool = True, reference_mol: str = None, mol_idx: int = 0, scaffold_smarts: str = None, inpaint_x1_pos: bool = True, inpaint_x1_x: bool = True, inpaint_x1_bonds: bool = True, stop_inpainting_at_time_x1_pos: float = 0.0, stop_inpainting_at_time_x1_x: float = 0.0, stop_inpainting_at_time_x1_bonds: float = 0.0, stop_inpainting_at_time_x4: float = 0.0, save_modalities: bool = False, compute_x1: bool = True, compute_x2: bool = True, compute_x3: bool = True, compute_x4: bool = True, start_time: float = 0.5, condition_configs: dict = {})¶
Entry point for all ShEPhERD pharmacophore generation modes.
- task_type selects the generation mode:
unconditional : joint x1/x2/x3/x4 from pure noise
pharmacophore_condition: condition on pharmacophores extracted from reference_mol
shape_conditioned : condition on surface + electrostatics from reference_mol
pharmacophore_inpaint : scaffold inpainting — keep scaffold_smarts atoms, regenerate rest
from_intermediate_time : soft scaffold hopping starting from a noisy intermediate
- For all conditional modes, provide:
reference_mol : path to .pkl (list of (molblock, charges) tuples) or .sdf file mol_idx : which molecule to use from the file (default 0)
- For pharmacophore_inpaint:
- scaffold_smarts: SMARTS pattern selecting atoms to keep (e.g. ‘c1ccccc1’)
If null, keeps all ring atoms and regenerates chains.
- run()¶
- N_x1 = [20]¶
- N_x1_sampling = 'uniform'¶
- N_x4 = 5¶
- batch_size = 1¶
- compute_x1 = True¶
- compute_x2 = True¶
- compute_x3 = True¶
- compute_x4 = True¶
- condition_configs¶
- denoising_noise_scale = 1.0¶
- inpaint_x1_bonds = True¶
- inpaint_x1_pos = True¶
- inpaint_x1_x = True¶
- mol_idx = 0¶
- num_generate = 10¶
- num_steps = 400¶
- output_path = 'generated_pharmacophore'¶
- prior_noise_scale = 1.0¶
- reference_mol = None¶
- save_modalities = False¶
- scaffold_smarts = None¶
- seed = 42¶
- start_time = 0.5¶
- stop_inpainting_at_time_x1_bonds = 0.0¶
- stop_inpainting_at_time_x1_pos = 0.0¶
- stop_inpainting_at_time_x1_x = 0.0¶
- stop_inpainting_at_time_x4 = 0.0¶
- task¶
- task_type = 'pharmacophore_condition'¶
- verbose = True¶
- MolecularDiffusion.runmodes.generate.tasks_generate.logger¶