cctk.XYZFile¶
- class cctk.XYZFile(ensemble, titles)[source]¶
Bases:
File
Class representing plain
.xyz
files.- titles¶
the title or titles from the file
- Type:
list of str
- molecule¶
Molecule instance representing the first molecule in the file. deprecated, but present for backwards compatibility.
- Type:
Methods
__init__
(ensemble, titles)append_to_file
(filename, text)Appends output text to a file.
get_molecule
([num])Returns a given molecule.
mol_from_lines
(lines[, charge, multiplicity])read_ensemble
(filename, **kwargs)Post refactoring, just an alias for
XYZFile.read_file()
.read_file
(filename[, charge, multiplicity, ...])Factory method to create new XYZFile instances.
read_trajectory
(filename, **kwargs)Post refactoring, just an alias for
XYZFile.read_file()
.write_ensemble_to_file
(filename, ensemble[, ...])Write a
cctk.Ensemble
to a single.xyz
file.write_file
(filename[, idx])Write an
.xyz
file, using object attributes.write_molecule_to_file
(filename, molecule[, ...])Write an
.xyz
file, using object attributes.- static append_to_file(filename, text)¶
Appends output text to a file.
- Parameters:
filename (str) – path to file, including name (e.g.
path/to/input.gjf
)text (str) – desired contents of file
- Returns:
True
if write succeeded,False
otherwise
- get_molecule(num=None)[source]¶
Returns a given molecule.
If
num
is specified, returnsself.ensemble.molecule_list()[num]
- classmethod read_ensemble(filename, **kwargs)[source]¶
Post refactoring, just an alias for
XYZFile.read_file()
.
- classmethod read_file(filename, charge=0, multiplicity=1, conformational=False)[source]¶
Factory method to create new XYZFile instances.
- Parameters:
filename (str) – path to
.xyz
filecharge (int) – charge of resultant molecule
multiplicity (int) – multiplicity of resultant molecule
conformational (bool) – whether or not it’s a conformational ensemble
- classmethod read_trajectory(filename, **kwargs)[source]¶
Post refactoring, just an alias for
XYZFile.read_file()
.
- classmethod write_ensemble_to_file(filename, ensemble, titles=None)[source]¶
Write a
cctk.Ensemble
to a single.xyz
file. Can be viewed in MOLDEN.- Parameters:
filename (str) – path to
.xyz
fileensemble (Ensemble) – the collection of structures to write
titles (None, str, or list of str) – if None, the titles of the Molecules will be used; if one str, then the same name will be used for all molecules; if iterable, then the titles are assumed to parallel the indexing of the list
- write_file(filename, idx=-1)[source]¶
Write an
.xyz
file, using object attributes.- Parameters:
idx (int) – the index of the molecule to write
- classmethod write_molecule_to_file(filename, molecule, title='title', append=False)[source]¶
Write an
.xyz
file, using object attributes.- Parameters:
filename (str) – path to the new file
molecule (Molecule) – molecule to write
title (str) – title of file
append (Bool) – whether or not to append to file