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]

    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)#

write xyz file

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

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

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

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

  • mo (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

  • 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_xtb(geom, theory, outfile=None, return_warnings=False, **kwargs)#

write input files for xtb

classmethod write_crest(geom, theory, outfile=None, return_warnings=False, **kwargs)#

write crest input files

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