You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the following function for ConformerEnsemble_from_CREST:
ce.prune_rmsd(method = "obrms-batch")
It gives me the following error:
PermissionError: [Errno 13] Permission denied: '~\AppData\Local\Temp\tmpnp4iv4_n.xyz'
I modified the conformer.py write_xyz function by adding 2 lines (import os and os.unlink(file)):
`` def write_xyz(
self,
file: str | PathLike,
ids: Iterable[int] | None = None,
unit: str = "kcal/mol",
relative: bool = True,
separate: bool = False,
n_decimals: int = 3,
) -> None:
"""Write conformers to xyz file.
Args:
file: Filename or path object. Needs filename if `separate=True`
ids: Conformer indices (1-indexed)
unit: Output unit for energies in xyz comment field: 'hartree', 'kcal/mol',
'kJ/mol'
relative: Whether to give energies relative to lowest energy conformer
separate: Whether to write conformers to separate xyz files
n_decimals: Number of decimals for energies
Raises:
TypeError: When separate=True and file is not str
"""
if ids is None:
ids_ = np.arange(len(self.conformers))
else:
ids_ = np.array(ids) - 1
ids = ids_
# Retrieve symbols, coordinates and energies
symbols = convert_elements(self.elements, output="symbols")
conformer_coordinates = self.get_coordinates()[ids]
energies = self.get_relative_energies(unit=unit, relative=relative)[ids].round(
n_decimals
)
# Write conformers
if separate:
if not isinstance(file, str):
raise TypeError("file must be str when separate=True")
for i, coordinates, energy in zip(ids, conformer_coordinates, energies):
conf_filename = file.split(".")[0] + f"_{i + 1}.xyz"
write_xyz(conf_filename, symbols, coordinates, comments=[energy])
else:
import os
os.unlink(file)
write_xyz(file, symbols, conformer_coordinates, comments=energies)
Now the function runs without an error message.
The text was updated successfully, but these errors were encountered:
Hello and thanks for reporting the issue, it is a problem with NamedTemporaryFile on Windows. There seems to be a way to fix this generally in Python 3.12, but I don't want to break backwards incompatibility that far.
Your fix works coincidentally for the very specific case, but a more general fix built on that could be to change:
Hey:)
I am trying to use the following function for ConformerEnsemble_from_CREST:
ce.prune_rmsd(method = "obrms-batch")
It gives me the following error:
PermissionError: [Errno 13] Permission denied: '~\AppData\Local\Temp\tmpnp4iv4_n.xyz'
I modified the conformer.py write_xyz function by adding 2 lines (import os and os.unlink(file)):
`` def write_xyz(
self,
file: str | PathLike,
ids: Iterable[int] | None = None,
unit: str = "kcal/mol",
relative: bool = True,
separate: bool = False,
n_decimals: int = 3,
) -> None:
"""Write conformers to xyz file.
Now the function runs without an error message.
The text was updated successfully, but these errors were encountered: