def read_mol_smiles(mol_dict: Settings) -> Optional[Molecule]: """Read a SMILES string.""" try: mol = _from_smiles(mol_dict.mol) mol.properties.smiles = Chem.CanonSmiles(mol_dict.mol) if mol_dict.get('indices'): for i in mol_dict.indices: mol[i].properties.anchor = True canonicalize_mol(mol) if mol_dict.get('indices'): mol_dict.indices = tuple(i for i, at in enumerate(mol, 1) if at.properties.pop('anchor', False)) if mol_dict.guess_bonds and not mol_dict.is_qd: mol.guess_bonds() return mol except Exception as ex: print_exception('read_mol_smiles', mol_dict.name, ex)
def _set_charge_amsjob(s: Settings, charge: int) -> None: if s.get('uff') is not None: return s.input.ams.system.charge = charge
def _set_charge_cp2kjob(s: Settings, charge: int) -> None: if s.get('dft') is None: return s.input.force_eval.dft.charge = charge
def prep_input( arg: Settings ) -> Tuple[SettingsDataFrame, SettingsDataFrame, SettingsDataFrame]: """Interpret and extract the input settings. Returns a list of ligands and a list of cores. Parameters ---------- |plams.Settings|_ A settings object containing all (optional) arguments. Returns ------- |tuple|_ [|CAT.SettingsDataFrame|_, |CAT.SettingsDataFrame|_, |CAT.SettingsDataFrame|_] A tuple containing the ligand, core and qd dataframes. """ # Interpret arguments validate_input(arg, validate_only=False) # Read the input ligands and cores lig_list = read_mol(arg.get('input_ligands')) core_list = read_mol(arg.get('input_cores')) qd_list = read_mol(arg.get('input_qd')) is_qd = True if qd_list is not None else False # Raises an error if lig_list or core_list is empty if is_qd: if not qd_list: raise MoleculeError( 'No valid input quantum dots were found, aborting run') else: if not lig_list: raise MoleculeError( 'No valid input ligands were found, aborting run') elif not core_list: raise MoleculeError( 'No valid input cores were found, aborting run') # Store the molecules in dataframes columns = pd.MultiIndex.from_tuples([MOL], names=['index', 'sub index']) if is_qd: ligand_df = core_df = None qd_df = SettingsDataFrame(index=pd.RangeIndex(len(qd_list)), columns=columns, settings=arg) qd_df[MOL] = qd_list else: qd_df = None ligand_df = SettingsDataFrame(index=pd.RangeIndex(len(lig_list)), columns=columns, settings=arg) core_df = SettingsDataFrame(index=pd.RangeIndex(len(core_list)), columns=columns.copy(), settings=arg) ligand_df[MOL] = lig_list core_df[MOL] = core_list return ligand_df, core_df, qd_df