schrodinger.application.jaguar.input module

Functions and classes for reading and creating Jaguar input files.

It allows setting and querying of keyword values in Jaguar input &gen sections and also provides an interface to some of the mmjag library.

The JaguarInput class also provides for the running of jobs.

exception schrodinger.application.jaguar.input.ConstraintError

Bases: Exception

Exception to be raised when Constraint is invalid, e.g. no atoms specified.

__init__(*args, **kwargs)
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception schrodinger.application.jaguar.input.InputVerificationError

Bases: Exception

Exception for non-matching JaguarInput instances. Generated by isEquivalentInput.

__init__(*args, **kwargs)
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

schrodinger.application.jaguar.input.launch_file(input: str, wait: bool = False, save: bool = False, disp: Optional[str] = None, **kwargs) schrodinger.job.jobcontrol.Job

Launch a Jaguar job from the Jaguar input file ‘input’. Returns a jobcontrol.Job object.

Parameters
  • input – Name of input file

  • wait – Do not return until the job is complete.

  • save – Set to True to save the scratch directory.

  • disp – Set to a valid jobcontrol disposition.

Returns

Job instance

schrodinger.application.jaguar.input.apply_jaguar_atom_naming(struc: schrodinger.structure._structure.Structure)

Apply jaguar unique atom naming to all atoms in the specified structure

Parameters

struc – The structure to apply atom naming to

schrodinger.application.jaguar.input.read(filename: str, index: int = 1, **kwargs)

Create and return a JaguarInput object from a Jaguar .in file or a maestro .mae file. Additional keyword args are passed on to the JaguarInput constructor.

Parameters
  • filename – Can be a Jaguar input .in file, Maestro structure .mae file, or the basename of a file of one of these types.

  • index – The index of the structure to use for an .mae input file.

kwargs (additional keyword arguments)

All keyword arguments are passed on to the JaguarInput constructor.

schrodinger.application.jaguar.input.get_name_file(name: str) Tuple[str, str]

Get the input filename and jobname, given either the input filename or the jobname.

Return a tuple of (jobname, filename).

schrodinger.application.jaguar.input.split_structure_files(files: List[str])

Given a list of structure (.in or .mae) files, split all .mae files into individual structures and write them back to disk with new names.

Return the list of structure files, each of which contains a single structure. Any split mae files are named with either the entry ID (if available) or the source file basename with an index suffix.

class schrodinger.application.jaguar.input.JaguarInput(input: Optional[str] = None, name: Optional[str] = None, handle: Optional[int] = None, structure: Optional[schrodinger.structure._structure.Structure] = None, genkeys: Optional[dict] = None, reload: Optional[bool] = None, run_kwargs: Optional[dict] = None, text: Optional[str] = None, qsite_ok: bool = False, rename_directives: bool = False)

Bases: object

A class for specifying Jaguar input.

This is a thin wrapper to the mmjag library and carries very little internal information.

__init__(input: Optional[str] = None, name: Optional[str] = None, handle: Optional[int] = None, structure: Optional[schrodinger.structure._structure.Structure] = None, genkeys: Optional[dict] = None, reload: Optional[bool] = None, run_kwargs: Optional[dict] = None, text: Optional[str] = None, qsite_ok: bool = False, rename_directives: bool = False)

There are three main ways to create a JaguarInput instance: from a Jaguar input file ‘input’, an mmjag handle ‘handle’, or a Structure instance ‘structure’.

The ‘input’ parameter will provide for initialization and job name from an existing Jaguar input file. (If no new name is provided, calling the save() method will overwrite the original file.)

Note that the structure and name parameters will modify the object status after loading from a file or initialization from a handle has completed. This can be utilized to get the settings from a Jaguar input file but replace the geometry for a new calculation.

Parameters
  • input – A jaguar input file; a default name will be derived from the input value.

  • name – A jaguar job name that will override the name derived from ‘input’.

  • handle – An mmjag handle, pointing to an existing mmjag instance in memory.

  • structure – A structure that will populate a new mmjag instance. If specified with ‘input’ or ‘handle’ it will replace any structure provided by them.

  • genkeys – A dictionary of keyword/value pairs to set in the input &gen section. If keywords are specified in this mapping and the file, the genkeys value will be used.

  • reload – Specifies whether to reload the job from an output file in the run() method. Default value is False, but can be modified by setting JaguarInput.reload to a different value.

  • run_kwargs – The run_kwargs dictionary provides default keyword settings for the run function that is called from the launch and run methods. Default is to set no defaults, but this can be modified by setting JaguarInput.run_kwargs to a different value.

  • text – The complete text of a Jaguar input file.

  • qsite_ok – Allows this class to be initialized from a QSite input file

  • rename_directives – When copying directives from an existing input file with relative paths, rename them to match the new input file name.

reload = False
run_kwargs = {}
launch(*args, **kwargs)

Save the file and launch a job. Returns a jobcontrol.Job object.

Uses the class run_kwargs value as base for keyword arguments to the run function.

run(**kwargs)

Save the file and launch a job with the wait option. Returns a JaguarOutput object. Raises an exception if the job failed.

Set the class (or instance) attribute reload to True to load existing output files of the same name.

save(follow_links: int = 0, validate: Optional[bool] = None)

Write an input file to name.in.

Parameters
  • follow_links

    Flag specifying whether to follow links in the structure to a Jaguar restart file, if present, to append additional sections. Options are:

    • mm.MMJAG_APPEND_OFF: don’t follow links to append additional sections (default)

    • mm.MMJAG_APPEND_OVERWRITE: append sections from link, overwriting any that overlap

    • mm.MMJAG_APPEND_NO_OVERWRITE: append sections from link, not overwriting any that overlap

    • mm.MMJAG_APPEND_X_OVERWRITE: exclusively append sections from link, deleting any already present

    • mm.MMJAG_APPEND_X_NO_OVERWRITE: append sections from link only if no such sections already present

  • validate – If True, sections dependent upon geometry, molecular state, basis set are removed if invalid. If not entered (None), default is to validate if “following links”.

saveAs(file: str, follow_links: int = 0, validate: Optional[bool] = None)

Write an input file to name.in and set the object’s name attribute.

Parameters
  • file – Filename to use for save file

  • follow_links

    Flag telling whether to follow links in the structure to a Jaguar restart file, if present, to append additional sections. Options are:

    • mm.MMJAG_APPEND_OFF: don’t follow links to append additional sections (default)

    • mm.MMJAG_APPEND_OVERWRITE: append sections from link, overwriting any that overlap

    • mm.MMJAG_APPEND_NO_OVERWRITE: append sections from link, not overwriting any that overlap

    • mm.MMJAG_APPEND_X_OVERWRITE: exclusively append sections from link, deleting any already present

    • mm.MMJAG_APPEND_X_NO_OVERWRITE: append sections from link only if no such sections already present

  • validate – If True, sections dependent upon geometry, molecular state, basis set are removed if invalid. If not entered (None), default is to validate if “following links”.

getInputText() str

Return the text of the input file. Note that the input file will not be saved to self._file.

Returns

The text of the input file

getZmatText(zmat: int = 0) str

Return the input file text corresponding to the specified Z matrix.

Parameters

zmat – The z matrix to return the text for. Must be one of mm.MMJAG_ZMAT1, mm.MMJAG_ZMAT2, or mm.MMJAG_ZMAT3.

Returns

The text for the specified Z matrix

property name: str

Set the jobname; also updates the filename based on the jobname.

property filename: str

Return the filename of the JaguarInput object.

On Windows, with paths over the Windows max path length, we must prepend an extended path tag.

getAtomCount(zmat: int = 0) int

Return the number of atoms for the specified zmat.

getValue(key)

Return the &gen section value for keyword ‘key’.

The return type is as defined by mmjag_key_type().

getDefault(key)

Return the default value for &gen section keyword ‘key’.

setValue(key, value)

Set the &gen section keyword ‘key’ to the value provided.

If value is None, the keyword will be unset.

setValues(dict_)

Set multiple &gen section keywords from the provided dictionary

Note that one easy way to specify the dict_ argument is via the "dict(basis='6-31g**', igeopt=1)" syntax for constructing a dictionary.

deleteKey(key)

Remove a key from the &gen section.

deleteKeys(keys)

Remove a list of keys from the &gen section.

getNonDefault()

Return a dictionary of all non-default keys except ‘multip’ and ‘molchg’, which must be retrieved explicitly since they are connected to the geometry.

isNonDefault(key: str) bool

Has the specified key been set to a non-default value?

Parameters

key – The key to check

Returns

True if the specified key is set to a non-default value. False otherwise.

setDirective(name: str, value)

Set a file specification directive.

getDirective(name: str)

Get a file specification directive.

getDirectives()

Get all file specification directives, except for MAEFILE, which is weeded out by the mmjag function itself.

writeMaefile(filename: Optional[str] = None, structs: Optional[List[schrodinger.structure._structure.Structure]] = None)

Write an associated .mae file and set the MAEFILE directive. If no name is provided, use jobname.mae. If no structs are provided, use self.getStructure().

If an absolute filename is not provided but the input file is known, write the mae file relative to the input file.

If no filename is given and no jobname is set, a random filename will be generated in the current directory.

Parameters
  • filename – Name to give the mae file

  • structs – A list of structures

getMaefilename(dont_create: bool = False) Optional[str]

Get the filename of the Maestro file containing the input structure. If no such file exists, it will be created unless c{dont_create} is True.

Parameters

dont_create – If False, a Maestro file will be created if one does not yet exist. If True, None will be returned if no file exists.

Returns

The requested filename as an absolute path. If no file exists and dont_create is True, None will be returned.

Raises

RuntimeError – If no structure is present.

property restart: str

Get the restart name associated with the input file.

getStructure(zmat: int = 0) schrodinger.structure._structure.Structure

Return a Structure representation of the specified zmat section.

Note that if the JaguarInput instance was created from a Jaguar input file that has no associated Maestro file (MAEFILE), the Lewis structure is determined automatically based on atom distances.

Parameters

zmat – The zmat to return (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3).

getStructures() List[schrodinger.structure._structure.Structure]

Return a list of all available structure representations for zmat sections

The first call to getStructure is required because getStructure is guaranteed to return a structure, which might have been set in a different way

setStructure(struct: schrodinger.structure._structure.Structure, zmat: int = 0, set_molchg_multip: bool = True)

Set one of the zmat sections from the provided Structure (or MMCT handle).

If set_molchg_multip is True, calling this method will update the values of molchg and multip. molchg will be consistent with the sum of formal charges in the provided CT, while multip will be set according to the CT-level i_m_Spin_multiplicity property.

Note one may call self.clearAllConstraints() to remove any unwanted constraints or scan-coordinates after updating the Structure. By default, such info will be preserved if the new Structure has the same atoms and connectivity as the original Structure; only XYZs (and charges/multiplicity) will be updated.

Parameters
  • struct – The structure to use for setting.

  • zmat – The zmat to set (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3).

  • set_molchg_multip – Whether to update molecular charge and multiplicity (default is yes)

hasStructure(zmat: int = 0) bool

Does this handle have a structure for the specified zmat section?

Parameters

zmat – The zmat to check (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3)

Returns

True if the specified structure is present. False otherwise.

resetStructure(struct: schrodinger.structure._structure.Structure, molchg: int, multip: int, zmat: int = 0)

Redefine the connectivity and formal charges for the input CT, and store the new structure in the current mmjag object, in the &zmat section indicated by the zmat argument.

This function is used when the molecular geometry has changed such that it may not be consistent with its original CT description in terms of bond orders and formal charges, and we want to force the creation of a new Lewis structure.

Parameters
  • struct – The structure to use for setting.

  • molchg – The value to use for the net molecular charge.

  • multip – The value to use for the net molecular spin.

  • zmat – The zmat to set (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3).

deleteStructure(zmat: int = 0)

Delete the specified structure

Parameters

zmat – The z matrix to delete. Must be one of mm.MMJAG_ZMAT1, mm.MMJAG_ZMAT2, or mm.MMJAG_ZMAT3.

preflight() str

Run a preflight check and return any warnings.

Returns

A string containing any warnings raised by the preflight check. If there were no warnings, an empty string is returned.

makeInternalCoords(zmat: int = 0)

Convert the specified Z-matrix to internal coordinates

Parameters

zmat – The Z-matrix to modify. Must be one of mm.MMJAG_ZMAT1, mm.MMJAG_ZMAT2, or mm.MMJAG_ZMAT3.

makeCartesianCoords(zmat: int = 0)

Convert the specified Z-matrix to Cartesian coordinates

Parameters

zmat – The Z-matrix to modify. Must be one of mm.MMJAG_ZMAT1, mm.MMJAG_ZMAT2, or mm.MMJAG_ZMAT3.

getUnknownKeywords() dict

Return a dictionary of all unknown keywords and their values

Returns

A dictionary of all unknown keywords and their values

sectionDefined(sect: str) bool

Determine if the specified section is defined

Parameters

sect – The section to check for

Returns

True if the specified section is defined. False otherwise.

createSection(sect: str)

Create the specified section

Parameters

sect – The section to create

deleteSection(sect: str)

Delete the specified section

Parameters

sect – The section to delete

Raises

ValueError – If the specified section does not exist

clearAllConstraints()

Delete all constraints and their associated coord entries. (Note that mm.mmjag_constraint_delete_all() does not delete the associated coord entries.)

scanCount() int

This function returns the total number of scan coordinates.

Returns

scan count

getScanCoordinate(i: int) Tuple[int, List[int], float, float, int]

This function returns i-th scan coordinate.

Returns

tuple that contains coordinate type, list of atoms, initial and final coordinate values, number of steps and step.

setScanCoordinate(coord_type: int, atoms: List[int], initial_value: float, final_value: float, num_steps: int, step: float)

This function defines scan coordinate. If atoms list size is less than 4, we add zeros to the list.

Parameters
  • coord_type – coordinate type

  • atoms – list of atom indices

  • initial_value – coordinate initial value

  • final_value – coordinate final value

  • num_steps – number of steps

  • step – step value

constrainAtomXYZ(index: int)

Constrain the XYZ coordinates of an atom.

Parameters

index – The index of the atom to constrain

constrainInternal(atom1: int, atom2: int, atom3: int = 0, atom4: int = 0)

Constrain an internal coordinate (bond, angle or torsion)

Parameters
  • atom1 – The index of the first atom in the internal coordinate definition

  • atom2 – The index of the second atom in the internal coordinate definition

  • atom3 – The index of the third atom in the internal coordinate definition (0 if this coordinate is a bond)

  • atom4 – The index of the fourth atom in the internal coordinate definition (0 if this coordinate is a bond or angle)

constraintCount() int

This function returns the total number of constraints.

Returns

constraint count

constraints() Iterator[Optional[Tuple[int, List[int], Optional[float]]]]

Generator function that yields constraints instead of returning a list.

getConstraint(i)

This function returns i-th constraint.

Returns

tuple that contains coordinate type, list of atoms and target value (may be None if constraint is not dynamic). If constraint type is MMJAG_SCAN_CONSTRAINT return None, so that we scan coordinates don’t appear as constraints.

Raises

if constraint index is out of range, a MmException is raised if the atom list is empty, a ConstraintError is raised

setConstraint(coordinate_type: int, atoms: List[int], value: Optional[float] = None)

This function defines static, dynamic, and natural torsion constraints. If atoms list size is less than 4, we add zeros to the list. If the coordinate_type is a natural torsion, a ConstraintError is raised if the number of atoms supplied is not 2. Otherwise, if value is not None, we set this constraint as ‘dynamic’.

Parameters
  • coordinate_type – coordinate type

  • atoms – list of atom indices

  • value – target value (for dynamic constraints only)

setMonomialConstraint(coordinate_type: int, atoms: List[int], fc: float, width: float, center: Optional[float] = None)

Defines a monomial (e.g. harmonic) constraint. If atoms list size is less than 4, we add zeros to the list.

Parameters
  • coordinate_type – coordinate type

  • atoms – list of atom indices

  • fc – force constant for potential

  • width – half-width for flat bottom of potential

  • center – center for internal coordinate constraints. If None, Jaguar will not use the center

setActiveCoord(coordinate_type: int, atoms: List[int])

This function defines an active coordinate. If atoms list size is less than 4, we add zeros to the list.

Parameters
  • coordinate_type – coordinate type

  • atoms – list of atom indices

anyConstraintsActive() bool

Check if any coordinate constraints are active

Returns

Are any coordinate constraints active

allConstraintsActive() bool

Check if all coordinate constraints are active

Returns

True if all coordinate constraints are active otherwise returns False. Will return False if there are no constraints set.

getConstraintIndicesByType(reference_type: int) List[int]

Returns a list of constraint indices (1 based indexing) that are of the given constraint type

Parameters

reference_type – Check for constraints with this type (mm.MMJag_constraint_type)

Returns

A list of indices with the given type, 1 indexed

setNotes(text: str)

Set comments/notes in input file

Raises
  • ValueError – Note contains “&”

  • RuntimeError – Any other mmexception from mmjag_note_set

getNotes() str

Get comments/notes from input file. Removes any whitespace/newline at end of comment string.

setAtomicBasis(atom_num: int, basis: str)

Set a per-atom basis set

Parameters
  • atom_num – The atom number to set the basis set for

  • basis – The basis set

Raises
  • ValueError – Invalid atomic number

  • MmException – General failure from mmjag_atomic_char_set

getAtomicBasis(atom_num: int) Optional[str]

Get the per-atom basis set for the specified atom

Parameters

atom_num – The atom index to get the basis set for

Returns

The basis set, or None if no basis set has been set for this atom

Raises
  • ValueError – Invalid atomic number

  • MmException – General failure from mmjag_atomic_char_get

getAllAtomicBases() Dict[int, str]

Get all per-atom basis sets

Returns

A dictionary of {atom index: basis set}. Atoms which do not have a per-atom basis set are not included in this dictionary.

clearAtomicBases()

Clear all per-atom basis sets

setAtomicCharge(atom_index: int, charge: int)

Set atomic charge of atom_index to charge

Raises
  • ValueError – Invalid atomic number

  • MmException – General failure from mmjag_atomic_int_set

getAtomicCharge(atom_index: int) int

Get atomic charge of atom_index

Raises
  • ValueError – Invalid atomic number

  • MmException – General failure from mmjag_atomic_int_get

setAtomicMultiplicity(atom_index: int, multip: int)

Set atomic multiplicity of atom_index to multip

Raises
  • ValueError – Invalid atomic number

  • MmException – General failure from mmjag_atomic_int_set

getAtomicMultiplicity(atom_index: int) int

Get atomic multiplicity of atom_index

Raises
  • ValueError – Invalid atomic number

  • MmException – General failure from mmjag_atomic_int_get

getChargeConstraints() List[Tuple[float, Dict[int, float]]]

Parse CDFT input file section to get charge constraints. Assume &cdft section takes the form:

&cdft net-charge weight1 first-atom1 last-atom1 weight2 first-atom2 last-atom2 net-charge weight3 first-atom3 last-atom3 weight4 first-atom4 last-atom4 &

Return constraints
list of CDFT constraints in the form

[ (charge1, weights1), (charge2, weights2), …]

where:

charge: The target charge value for the specified atoms weights: A dictionary of {atom index: weight}

Return empty list if keyword icdft!=1 (i.e. not CDFT done)

:raise InvalidCDFTError if &cdft section invalid or not found

when icdft keyword is 1

appendChargeConstraints(charge: float, weights: Dict[int, float])

Set charge constraints for CDFT. Append to existing constraints if previously set.

Parameters
  • charge – The target charge value for the specified atoms

  • weights – A dictionary of {atom index: weight}

setChargeConstraints(constraints: List[Tuple[int, Dict[int, float]]])

Set charge constraints for CDFT. Overwrite existing constraints if previously set.

Parameters

constraints (list) – List of CDFT constraints. Each item of the list should be a (charge, weights) tuple, where weights is a dictionary with atom index as key and weight as value.

clearChargeConstraints()

Clear all CDFT charge constraints

isEquivalentInput(other, thresh: float = 0.1) bool

Checks whether two JaguarInput instances are describing essentially the same job.

The comparison checks: 1) that the non-default Jaguar keywords are the same 2) that the number of atoms are the same 3) that the structures can be superposed on each other to within a given threshold 4) that all atoms identities (elements and isotopes) are the same.

NB: this means that renumberings of the same structure will be parsed as non-matching. If any of the tests fail, an InputVerificationError is raised (with a message indicating the failed test), otherwise True is returned.

exception schrodinger.application.jaguar.input.InvalidCDFTError

Bases: Exception

__init__(*args, **kwargs)
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.