FileWriter class¶
- class AaronTools.fileIO.FileWriter¶
class for handling file writing
- classmethod write_file(geom, style=None, append=False, outfile=None, *args, **kwargs)¶
Writes file from geometry in the specified style
- Parameters:
geom (Geometry) – the Geometry to use
style (str) –
the file type style to generate Currently supported options: “xyz” (default), “com”, “inp”, “inq”, “in”, “sqmin”, “cube”, “xtb”, “crest”, “mol”
if outfile has one of these extensions, default is that style
append (bool) – for *.xyz, append geometry to the same file
outfile (str|None|False) – output destination - default is [geometry name] + [extension] or [geometry name] + [step] + [extension]
kwargs (str) –
allowed kwargs: * oniom * models * theory
if outfile is False, no output file will be written, but the contents will be returned
theory (Theory) – for com, inp, and in files, an object with a get_header and get_footer method
- classmethod write_xyz(geom, append, outfile=None, comment=None, **kwargs)¶
write xyz file (file with coordinate system of input geometry)
- Parameters:
geom (Geometry) – molecule(s) to be written to the output
append (bool) – whether the output should be appended to a file (True) or overwrite (False)
outfile (str) – filename to append/write output to
Default/None: output file is the name of the geometry object provided (e.g. benzene.xyz if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing/appending.- Parameters:
comment (str) – comment to be added to the output Default/None: comment is the same as the geom object’s comment
- Returns:
xyz file contents if outfile=False, otherwise no return value
- Return type:
str
- classmethod write_multi_xyz(geom, append, outfile=None, **kwargs)¶
write multiple oniom xyz files from geometry with multiple poses such as a pdb derived geometry
- Parameters:
geom (Geometry) – molecule(s) to be written to the outputs
append (bool) – whether the output should be appended to a file (True) or overwrite (False)
outfile (str) – filename to append/write output to
Default/None: output file is the name of the geometry object provided (e.g. benzene.xyz if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing/appending.- kwargs[“models”] can be string “all”, string of model number e.g. “2”, string of model range e.g. “1-5”,
or list of model numbers including ranges e.g. [“1”, “3-5”, “10”]
kwargs[“oniom”] can be string “all” or string “frag” which requires a specification of the fragment in another kwarg kwargs[“layer”] can be defined if kwargs[“oniom”] == “frag”, can be “H”, “M”, or “L”
- classmethod write_oniom_xyz(geom, append, outfile=None, **kwargs)¶
write xyz files with additional columns for atomtype, charge, and link atom info
- Parameters:
geom (Geometry) – molecule(s) to be written to the outputs
append (bool) – whether the output should be appended to a file (True) or overwrite (False)
outfile (str) – filename to append/write output to
Default/None: output file is the name of the geometry object provided (e.g. benzene.xyz if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing/appending.kwargs[“oniom”] can be string “all” or string “frag” which requires a specification of the fragment in another kwarg kwargs[“layer”] can be defined if kwargs[“oniom”] == “frag”, can be “H”, “M”, or “L”
- classmethod write_mol(geom, outfile=None, **kwargs)¶
write V2000 mol file
- Parameters:
geom (Geometry) – molecule(s) to be written
outfile (str) – file to be written to
Default/None: output file is the name of the geometry object provided (e.g. benzene.mol if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing.
- classmethod write_com(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write Gaussian input file for given Theory and Geometry
- Parameters:
geom (Geometry) – structure
theory (Theory) – input file parameters
outfile (None|False|str) –
output file option
None - geom.name + “.com” is used as output destination
False - return contents of the input file as a str
str - output destination
return_warnings (bool) – True to return a list of warnings (e.g. basis set might be misspelled
kwargs – passed to Theory methods (make_header, make_molecule, etc.)
- classmethod write_inp(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write ORCA input file for the given Theory() and Geometry()
- Parameters:
geom (Geometry) – structure
theory (Theory) – input file parameters
outfile (None|False|str) –
None - geom.name + “.inp” is used as output destination
False - return contents of the input file as a str
str - output destination
return_warnings (bool) – True to return a list of warnings (e.g. basis set might be misspelled
kwargs – passed to Theory methods (make_header, make_molecule, etc.)
- classmethod write_inq(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write QChem input file for the given Theory() and Geometry()
- Parameters:
geom (Geometry) – structure
theory (Theory) – input file parameters
outfile (None|False|str) –
None - geom.name + “.inq” is used as output destination
False - return contents of the input file as a str
str - output destination
return_warnings (bool) – True to return a list of warnings (e.g. basis set might be misspelled
kwargs – passed to Theory methods (make_header, make_molecule, etc.)
- classmethod write_in(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write Psi4 input file for the given Theory() and Geometry()
- Parameters:
geom (Geometry) – structure
theory (Theory) – input file parameters
outfile (None|False|str) –
None - geom.name + “.in” is used as output destination
False - return contents of the input file as a str
str - output destination
return_warnings (bool) – True to return a list of warnings (e.g. basis set might be misspelled
kwargs – passed to Theory methods (make_header, make_molecule, etc.)
- classmethod write_sqm(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write SQM input file for the given Theory() and Geometry()
- Parameters:
geom (Geometry) – structure
theory (Theory) – input file parameters
outfile (None|False|str) –
None - geom.name + “.sqmin” is used as output destination
False - return contents of the input file as a str
str - output destination
return_warnings (bool) – True to return a list of warnings (e.g. basis set might be misspelled
kwargs – passed to Theory methods (make_header, make_molecule, etc.)
- classmethod write_cube(geom, orbitals=None, outfile=None, kind='homo', padding=4.0, spacing=0.2, alpha=True, xyz=False, n_jobs=1, delta=0.1, **kwargs)¶
write a cube file for a molecular orbital
- Parameters:
geom (Geometry) – structure
orbitals (Orbitals) – orbital data
outfile (str) – output destination
kind (str|int) – index of molecular orbital or “homo” for ground state highest occupied molecular orbital or “lumo” for first ground state unoccupied MO can also be an array of MO coefficients
alpha (bool) –
xyz (bool) –
ao (str|int) – index of atomic orbital to print
padding (float) – padding around geom’s coordinates
spacing (float) – targeted spacing between points
n_jobs (int) – number of parallel threads to use this is on top of NumPy’s multithreading, so if NumPy uses 8 threads and n_jobs=2, you can expect to see 16 threads in use
delta (float) – see Orbitals.fukui_donor_value or fukui_acceptor_value
- classmethod write_pdb(geom, append, outfile=None, qt=False)¶
write input files for pdb
- Parameters:
geom (Geometry) – molecule to be written/appended
append (bool) – appends instead of overwrites if True
outfile (str) – file to be written to
Default/None: output file is the name of the geometry object provided (e.g. benzene.mol if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing.- Parameters:
qt (bool) – determines charge spacing to be used for writing; True is 2, False is 10
- classmethod write_xtb(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write input files for xtb
- Parameters:
Default/None: output file is the name of the geometry object provided (e.g. benzene.mol if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing.- Parameters:
return_warnings (bool) – whether or not warnings should be returned
- classmethod write_crest(geom, theory, outfile=None, return_warnings=False, **kwargs)¶
write crest input files
- Parameters:
Default/None: output file is the name of the geometry object provided (e.g. benzene.mol if geom.name = ‘benzene’)False: method simply returns the contents of the output file instead of writing.- Parameters:
return_warnings (bool) – whether or not warnings should be returned
- static write_dict_files(contents, dirname, name)¶
write data to different files
- Parameters:
contents (dict) – keys are either a file name (includes a “.”) or a file extension (no “.”)
dirname (str) –
where to write files e.g. calling with contents as
{“run.sh”: “cat {{ name }}.txt”, “txt”: “hi”}
and name as “test” will write run.sh and test.txt to dirname
name (str) – name of file to be written