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__
¶ Initialize self. See help(type(self)) for accurate signature.
-
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__
¶ Initialize self. See help(type(self)) for accurate signature.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
schrodinger.application.jaguar.input.
launch_file
(input, wait=False, save=False, disp=None, **kwargs)¶ Launch a Jaguar job from the Jaguar input file ‘input’. Returns a jobcontrol.Job object.
Arguments
- wait (bool)
- Do not return until the job is complete.
- save (bool)
- Set to True to save the scratch directory.
- disp (str)
- Set to a valid jobcontrol disposition.
-
schrodinger.application.jaguar.input.
apply_jaguar_atom_naming
(struc)¶ Apply jaguar unique atom naming to all atoms in the specified structure
Parameters: struc ( schrodinger.structure.Structure
) – The structure to apply atom naming to
-
schrodinger.application.jaguar.input.
read
(filename, index=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 (str)
- Can be a Jaguar input .in file, Maestro structure .mae file, or the basename of a file of one of these types.
- index (int)
- 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)¶ 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)¶ 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=None, name=None, handle=None, structure=None, genkeys=None, reload=None, run_kwargs=None, text=None, qsite_ok=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=None, name=None, handle=None, structure=None, genkeys=None, reload=None, run_kwargs=None, text=None, qsite_ok=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 (str) – A jaguar input file; a default name will be derived from the input value.
- name (str) – A jaguar job name that will override the name derived from ‘input’.
- handle (int) – An mmjag handle, pointing to an existing mmjag instance in memory.
- structure (
schrodinger.structure.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 (dict) – 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 (bool) – 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 (dict) – 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 (str) – The complete text of a Jaguar input file.
- qsite_ok (bool) – Allows this class to be initialized from a QSite input file
-
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=0, validate=None)¶ Write an input file to name.in.
Parameters: - follow_links (int) –
- 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 (bool) – 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”.
- follow_links (int) –
-
saveAs
(file_, follow_links=0, validate=None)¶ Write an input file to name.in and set the object’s name attribute.
Parameters: - follow_links (int) –
- 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 (bool) – 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”.
- follow_links (int) –
-
saveAsBatch
(file_)¶ Write a batch file to file_.bat. Note that the object’s name attribute will not be set.
Parameters: file (str) – The filename to save to. The “.bat” extension will be added if necessary.
-
getInputText
()¶ 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 Return type: str
-
getZmatText
(zmat=0)¶ 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 Return type: str
-
name
¶ Return the name of the job.
-
getAtomCount
(zmat=0)¶ 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 ‘dict_’.
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)¶ Has the specified key been set to a non-default value?
Parameters: key (str) – The key to check Returns: True if the specified key is set to a non-default value. False otherwise. Return type: bool
-
setDirective
(name, value)¶ Set a file specification directive.
-
getDirective
(name)¶ 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=None, structs=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: structs – A list of structures
-
getMaefilename
(dont_create=False)¶ 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 (bool) – 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.Return type: str or NoneType Raises: RuntimeError – If no structure is present.
-
restart
¶ Get the restart jobname based on the current name.
-
getStructure
(zmat=0)¶ 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 (mmjag enum)
- The zmat to return (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3).
-
getStructures
()¶ 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, zmat=0, set_molchg_multip=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.
Parameters
- struct (schrodinger.structure.Structure)
- The structure to use for setting.
- zmat (mmjag enum)
- 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=0)¶ Does this handle have a structure for the specified zmat section?
Parameters: zmat (int) – The zmat to check (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3) Returns: True if the specified structure is present. False otherwise. Return type: bool
-
resetStructure
(struct, molchg, multip, zmat=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 (schrodinger.structure.Structure)
- The structure to use for setting.
- molchg (integer)
- The value to use for the net molecular charge.
- multip (integer)
- The value to use for the net molecular spin.
- zmat (mmjag enum)
- The zmat to set (MMJAG_ZMAT1, MMJAG_ZMAT2, or MMJAG_ZMAT3).
-
deleteStructure
(zmat=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
()¶ 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. Return type: str
-
makeInternalCoords
(zmat=0)¶ Convert the specified Z-matrix to internal coordinates
Parameters: zmat (int) – The Z-matrix to modify. Must be one of mm.MMJAG_ZMAT1, mm.MMJAG_ZMAT2, or mm.MMJAG_ZMAT3.
-
makeCartesianCoords
(zmat=0)¶ Convert the specified Z-matrix to Cartesian coordinates
Parameters: zmat (int) – The Z-matrix to modify. Must be one of mm.MMJAG_ZMAT1, mm.MMJAG_ZMAT2, or mm.MMJAG_ZMAT3.
-
getUnknownKeywords
()¶ Return a dictionary of all unknown keywords and their values
Returns: A dictionary of all unknown keywords and their values Return type: dict
-
sectionDefined
(sect)¶ Determine if the specified section is defined
Parameters: sect (str) – The section to check for Returns: True if the specified section is defined. False otherwise. Return type: bool
-
createSection
(sect)¶ Create the specified section
Parameters: sect (str) – The section to create
-
deleteSection
(sect)¶ Delete the specified section
Parameters: sect (str) – 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
()¶ This function returns the total number of scan coordinates.
Returns: scan count Return type: int
-
getScanCoordinate
(i)¶ 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. Return type: tuple
-
setScanCoordinate
(coord_type, atoms, initial_value, final_value, num_steps, step)¶ This function defines scan coordinate. If atoms list size is less than 4, we add zeros to the list.
Parameters: - coord_type (int) – coordinate type
- atoms (list) – list of atom indices
- initial_value (float) – coordinate initial value
- final_value (float) – coordinate final value
- num_steps (int) – number of steps
- step (float) – step value
-
constrainAtomXYZ
(index)¶ Constrain the XYZ coordinates of an atom.
Parameters: index (int) – The index of the atom to constrain
-
constrainInternal
(atom1, atom2, atom3=0, atom4=0)¶ Constrain an internal coordinate (bond, angle or torsion)
Parameters: - atom1 (int) – The index of the first atom in the internal coordinate definition
- atom2 (int) – The index of the second atom in the internal coordinate definition
- atom3 (int) – The index of the third atom in the internal coordinate definition (0 if this coordinate is a bond)
- atom4 (int) – The index of the fourth atom in the internal coordinate definition (0 if this coordinate is a bond or angle)
-
constraintCount
()¶ This function returns the total number of constraints.
Returns: constraint count Return type: int
-
constraints
()¶ 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. Return type: tuple or None 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, atoms, value=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 (int) – coordinate type
- atoms (list) – list of atom indices
- value (float) – target value (for dynamic constraints only)
-
setMonomialConstraint
(coordinate_type, atoms, fc, width, center=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 (int) – coordinate type
- atoms (list) – list of atom indices
- fc (float) – force constant for potential
- width (float) – half-width for flat bottom of potential
- center (float or None) – center for internal coordinate constraints. If None, Jaguar will not use the center
-
setActiveCoord
(coordinate_type, atoms)¶ This function defines an active coordinate. If atoms list size is less than 4, we add zeros to the list.
Parameters: - coordinate_type (int) – coordinate type
- atoms (list) – list of atom indices
-
anyConstraintsActive
()¶ Check if any coordinate constraints are active
Returns: Are any coordinate constraints active Return type: bool
-
allConstraintsActive
()¶ 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. Return type: bool
-
getConstraintIndicesByType
(reference_type)¶ Returns a list of constraint indices (1 based indexing) that are of the given constraint type
Parameters: reference_type (mm.MMjag_constraint_type) – Check for constraints with this type Returns: A list of indices with the given type, 1 indexed Return type: list(int)
-
setAtomicBasis
(atom_num, basis)¶ Set a per-atom basis set
Parameters: - atom_num (int) – The atom number to set the basis set for
- basis (str) – The basis set
-
getAtomicBasis
(atom_num)¶ Get the per-atom basis set for the specified atom
Parameters: atom_num (int) – 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 Return type: str or NoneType
-
getAllAtomicBases
()¶ 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. Return type: dict
-
clearAtomicBases
()¶ Clear all per-atom basis sets
-
getChargeConstraints
()¶ 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 &
Rtype constraints: list
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, weights)¶ Set charge constraints for CDFT. Append to existing constraints if previously set.
Parameters: - charge (float) – The target charge value for the specified atoms
- weights (dict) – A dictionary of {atom index: weight}
-
setChargeConstraints
(constraints)¶ Set charge constraints for CDFT. Overwrite existing constraints if previously set.
Parameters: contraints – 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=0.1)¶ 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.
-
-
class
schrodinger.application.jaguar.input.
GenOptions
(kwdict=None)¶ Bases:
object
A class to convert keyword value pairs defined in a single string into a data structure, and allow them to be converted back into a string.
Here are some example strings:
'igeopt=1 mp2=3' 'igeopt=1 maxitg=1 iacc=1'
-
eq_re
= re.compile('\\s*=\\s*')¶
-
OK
= 0¶
-
PARTIAL
= 1¶
-
ERROR
= 2¶
-
__init__
(kwdict=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
static
fromString
(string)¶ Create a GenOptions instance from the provided string.
-
static
testString
(string, gen_options=None)¶ Test the state of the provided string. If gen_options is provided, set its values based on the keyword value pairs in the string.
Parameters
- string (str)
- Input string to read for settings.
- gen_options (GenOptions)
- A gen_options instance to modify according to the values in ‘string’.
-
toString
()¶
-
commandLineOptions
()¶
-
isEquivalent
(other)¶
-