schrodinger.application.matsci.fragments module¶
Classes and functions to help with workflows that fragment multiple reactions such as the bond dissociation and adsorption energy workflows.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.matsci.fragments.
LoggerUser
(*args, logger=None, **kwargs)¶ Bases:
object
Mixin for classes that need to use a logger
-
__init__
(*args, logger=None, **kwargs)¶ Create the LoggerUser
Parameters: logger (log.logger) – The logger to use
-
log
(msg)¶ Log a message
Parameters: msg (str) – The message to log
-
-
class
schrodinger.application.matsci.fragments.
BreakingBond
(struct, bond, preserve_order=False)¶ Bases:
object
Defines and tracks the information for a bond that breaks
-
__init__
(struct, bond, preserve_order=False)¶ Create a BreakingBond object
Parameters: - struct (
schrodinger.structure.Structure
) – The structure containing the breaking bond - bond (
schrodinger.structure._StructureBond
) – The bond that will be broken - preserve_order (bool) – Preserve the found order of fragments. If False, fragments will be sorted based on SMILES string.
- struct (
-
getFragments
(struct, bond)¶ Define the two fragments that will be created when the bond breaks
Parameters: - struct (
schrodinger.structure.Structure
) – The structure containing the breaking bond - bond (
schrodinger.structure._StructureBond
) – The bond that will be broken
Return type: list
Returns: Each item of the list is a
Fragment
object defining one of the fragments that is created by breaking the bond - or each item is None if the bond is actually part of a macrocycle.- struct (
-
-
class
schrodinger.application.matsci.fragments.
Fragment
(struct, indexes, targets)¶ Bases:
object
A fragment of a structure that will be created after dissociation
-
__init__
(struct, indexes, targets)¶ Create a Fragment object
Parameters: - struct (
schrodinger.structure.Structure
) – The structure containing the fragment - indexes (list) – The list of atom indexes in struct to include in the fragment
- targets (list) – The atom index(es) in struct that are part of this fragment and that are directly involved in the dissociation
- struct (
-
isClosedShell
()¶ Detect if this is a closed shell (even number of electrons) fragment when neutral
Return type: bool Returns: Whether the fragment has an even number of electrons
-
getSMILESForFrag
()¶ Get the smiles string and list of targets for this fragment. Note that this SMILES string will have an addition At atom at the point of dissociation. This is done to increase the robustness of the unique SMILES method. Without it, I have found that a benzene ring radical can have different unique SMILES strings depending on what atom the SMILES is on. Since we never generate a structure from these SMILES strings, the extra atom isn’t an issue.
Return type: (str, list) or (None, []) Returns: (SMILES, list_of_targets). The SMILES string is the SMILES string for this fragment with an At atom at the dissociation point(s). Each item in list_of_targets is the atom index of a target atom (atom at the point of dissociation) using the atom index numbering in frag. (None, []) is returned if the SMILES string fails to generate.
-
-
class
schrodinger.application.matsci.fragments.
UniqueTracker
(struct, keydict, key, options, basename='fragment', targets=None, parent_indexes=None, charge=None, mult=None, tddft=False, vertical=False, write_input_ok=True, **kwargs)¶ Bases:
schrodinger.application.matsci.fragments.LoggerUser
Tracks the information for, and creates the Jaguar job for, a unique fragment. Since the same fragment may be generated by multiple dissociations, we use this class to track each unique fragment.
-
__init__
(struct, keydict, key, options, basename='fragment', targets=None, parent_indexes=None, charge=None, mult=None, tddft=False, vertical=False, write_input_ok=True, **kwargs)¶ Create a UniqueTracker object
Parameters: - struct (
schrodinger.structure.Structure
) – The structure containing the leaving ligand - keydict (dict) – The dictionary containing the base set of keywords
- key (str) – a unique identifier for this unique fragment
- options (argparse.Namespace) – The command line options
- basename (str) – The base name to use for files for this fragment. Will be used as the fragment_type and combined with key to form the file base names.
- targets (list) – The atom indexes in struct that are at the dissociation point
- parent_indexes (list) – The atom indexes with the parent atom numbering for the atoms in struct. Note this will only be valid for one specific reaction, so must be overwritten in any NonUniqueTracker objects that track this instance.
- charge (int) – The charge of the fragment - will be used with the molchg keyword
- mult (int) – The multiplicity of the fragment - will be used with the multip keyword
- tddft (bool) – True if the calculation should use TDDFT
- vertical (bool) – True if this is tracking an object that should not have its geometry optimized. If vertical is True, writing the Jaguar input file is delayed and must be triggered manually later by a call to setVerticalStructure.
- write_input_ok (bool) – If True, write the input files for this fragment. If False, do not.
- struct (
-
addBondEnergy
(index1, index2, energy)¶ Add a computed bond dissociation energy
Parameters: - index1 (int or
schrodigner.structure._StructureAtom
) – The index of the first atom in the bond (or the atom object) - index2 (int or
schrodigner.structure._StructureAtom
) – The index of the second atom in the bond (or the atom object) - energy (float) – The bond dissociation energy for that bond
- index1 (int or
-
getWeakestBonds
()¶ Get the bond with the lowest energy
Return type: list, float Returns: Each item of the list is a (int, int) tuple that gives the atom indexes involved the bond with the lowest energy. The energy is the energy of that bond. The list will be empty and the energy will be None if there are no BDE’s defined for this Reactant
-
updateVerticalStructure
(parent_structure)¶ Grab the structure for these atoms from the parent structure and write out the Jaguar input file
Parameters: parent_structure ( schrodinger.structure.Structure
) – The parent structure to extract the fragment structure from
-
writeInput
(struct)¶ Write an input file using the given structure
Parameters: structure ( schrodinger.structure.Structure
) – The structure to write to the input file
-
addToQueue
(jobq, backend)¶ Check if output file exists and if not create a job for this fragment and add it to the queue and add its output files to the backend
Parameters: - jobq (
schrodinger.job.queue.JobDJ
) – The queue to add the job to - backend (
schrodinger.job.jobcontrol.Backend
) – The job control backend, if any
- jobq (
-
getStructureWithProps
()¶ Get the structure resulting from the Jaguar run including any existing properties
Return type: schrodinger.structure.Structure
or NoneReturns: The output structure, or None if an error occurs
-
getStructureWithoutProps
()¶ Get the structure resulting from the Jaguar run but remove any existing properties
Return type: schrodinger.structure.Structure
or NoneReturns: The output structure, or None if an error occurs
-
superimposeOnParent
(parent, struct)¶ Superimpose this fragment on its parent structure to get the orientation the same. Modifies struct directly
Parameters: - parent (
schrodinger.structure.Structure
) – The parent structure to superimpose on - must have the same atom ordering as was used for the parent_indexes argument in the class constructor. - struct (
schrodinger.structure.Structure
) – The structure for this fragment
- parent (
-
getEnergy
()¶ Get the best energy from the Jaguar job.
Return type: float or None Returns: The best energy from the Jaguar job. In order of preference - Free energy corrected by ZPE, solution phase energy, LMP2 energy, SCF energy. None is returned if an error occurs in obtaining the energy.
-
write
(writer)¶ Write the structure with properties to the output file
Parameters: writer (L{schrodinger.structure.StructureWriter) – The writer to use to write the output file
-
log
(msg)¶ Log a message
Parameters: msg (str) – The message to log
-
-
class
schrodinger.application.matsci.fragments.
NonUniqueTracker
(unique_master, parent_indexes)¶ Bases:
schrodinger.application.matsci.fragments.UniqueTracker
This is a placeholder for a second (or third, etc.) time a fragment is used in the reaction. Mimics the UniqueTracker job without creating any new Jaguar jobs or writing to the output file.
-
__init__
(unique_master, parent_indexes)¶ Create a NonUniqueTracker object
Parameters: - unique_master (
UniqueTracker
) – The UniqueTracker object this NonUniqueTracker should mimic - parent_indexes (list) – The atom indexes with the parent atom numbering for the atoms in this fragment. Note this is only be valid for the specific reaction this tracker is for, so must it overwrites the parent_indexes of the UniqueTracker this object is mimicking
- unique_master (
-
updateVerticalStructure
(*args)¶ Overwrite the parent method because this class doesn’t deal with structures but we want to be able to call this method safely.
-
addToQueue
(*args, **kwargs)¶ The whole point of this class is that it doesn’t run a Jaguar job but takes the results from a different job
-
write
(writer)¶ Don’t write anything out - we’re vaporware of the best kind
-
addBondEnergy
(index1, index2, energy)¶ Add a computed bond dissociation energy
Parameters: - index1 (int or
schrodigner.structure._StructureAtom
) – The index of the first atom in the bond (or the atom object) - index2 (int or
schrodigner.structure._StructureAtom
) – The index of the second atom in the bond (or the atom object) - energy (float) – The bond dissociation energy for that bond
- index1 (int or
-
getEnergy
()¶ Get the best energy from the Jaguar job.
Return type: float or None Returns: The best energy from the Jaguar job. In order of preference - Free energy corrected by ZPE, solution phase energy, LMP2 energy, SCF energy. None is returned if an error occurs in obtaining the energy.
-
getStructureWithProps
()¶ Get the structure resulting from the Jaguar run including any existing properties
Return type: schrodinger.structure.Structure
or NoneReturns: The output structure, or None if an error occurs
-
getStructureWithoutProps
()¶ Get the structure resulting from the Jaguar run but remove any existing properties
Return type: schrodinger.structure.Structure
or NoneReturns: The output structure, or None if an error occurs
-
getWeakestBonds
()¶ Get the bond with the lowest energy
Return type: list, float Returns: Each item of the list is a (int, int) tuple that gives the atom indexes involved the bond with the lowest energy. The energy is the energy of that bond. The list will be empty and the energy will be None if there are no BDE’s defined for this Reactant
-
log
(msg)¶ Log a message
Parameters: msg (str) – The message to log
-
superimposeOnParent
(parent, struct)¶ Superimpose this fragment on its parent structure to get the orientation the same. Modifies struct directly
Parameters: - parent (
schrodinger.structure.Structure
) – The parent structure to superimpose on - must have the same atom ordering as was used for the parent_indexes argument in the class constructor. - struct (
schrodinger.structure.Structure
) – The structure for this fragment
- parent (
-
writeInput
(struct)¶ Write an input file using the given structure
Parameters: structure ( schrodinger.structure.Structure
) – The structure to write to the input file
-
-
class
schrodinger.application.matsci.fragments.
Reaction
(reactant_index, reactant_targets, product_trackers, **kwargs)¶ Bases:
schrodinger.application.matsci.fragments.LoggerUser
Holds the information for a single dissociation reaction
-
__init__
(reactant_index, reactant_targets, product_trackers, **kwargs)¶ Create a Reaction object
Parameters: - reactant_index (str) – the key into the reactants dictionary for the reactant in this reaction
- reactant_targets (list) – The atom indexes in the reactant structure that dissociate in this reaction
- product_trackers (list) – Each item of this list is a UniqueTracker or NonUniqueTracker object for one of the product fragments
- logger (logging.logger) – The logger to use
-
updateProductGeometries
(reactants)¶ Update the geometry of all product fragments to have the geometry of that fragment in the reactant
Parameters: reactants (dict) – keys are reactant_index strings, values are UniqueTracker objects for that reactant
-
log
(msg)¶ Log a message
Parameters: msg (str) – The message to log
-
-
schrodinger.application.matsci.fragments.
create_fragment_tracker
(unique_fragments, unique_trackers, fragment, keywords, options, charge=0, vertical=False, state='s0', index=0, logger=None, tracker_class=<class 'schrodinger.application.matsci.fragments.UniqueTracker'>)¶ Create a UniqueTracker or NonUniqueTracker for the given fragment with the given charge state.
Parameters: - unique_fragments (dict) – Dictionary of unique fragments. Keys are smiles strings, values are the index number for this fragment. This function adds fragments to this dictionary.
- unique_trackers (dict) – Dictionary of unique fragment trackers. Keys are smiles strings possibly modified by a charge state, values are UniqueTracker objects. There may be more than one unique tracker for each unique fragment because each charge state requires its own tracker. This function adds trackers to this dictionary.
- fragment (
Fragment
) – The Fragment object to create a tracker for - keywords (dict) – The base set of Jaguar keywords to use in Jaguar jobs
- options (argparse.Namespace) – The command line options
- charge (int) – The charge on the fragment - used for the molchg keyword
- vertical (bool) – True if this is tracking an object that should not have its geometry optimized
- state (str) – The reactant state for this fragment, one of the strings in the STATES constant. Important because product fragments from a triplet reactant must be considered unique from the same product fragments from a singlet (etc) if vertical=True.
- index (int) – The index of this fragment. Used when keeping fragments unique when vertical=True.
- logger (log.logger) – The logger to use
- tracker_class (class) – The tracker class to create for unique fragments
Return type: tracker_class or NonUniqueTracker
Returns: A tracker for the given fragment. If no trackers previously existed for this fragment and charge state, the tracker is a an object of the class specified by tracker_class. If one previously existed, then a NonUniqueTracker is returned.
-
schrodinger.application.matsci.fragments.
create_reactions
(unique_fragments, unique_trackers, reactants, rstruct, rind, state, product_groups, options, keywords=None, vertical=False, logger=None, tracker_class=<class 'schrodinger.application.matsci.fragments.UniqueTracker'>, reactant_title_base='reactant')¶ Create Reaction objects for each reaction
Parameters: - unique_fragments (dict) – Dictionary of unique fragments. Keys are smiles strings, values are the index number for this fragment. This function adds fragments to this dictionary.
- unique_trackers (dict) – Dictionary of unique fragment trackers. Keys are smiles strings possibly modified by a charge state, values are UniqueTracker objects. There may be more than one unique tracker for each unique fragment because each charge state requires its own tracker. This function adds trackers to this dictionary.
- reactants (dict) – Dictionary of reactant trackers. Keys are strings with an index number possibly appended with an electronic state, values are UniqueTracker objects. This function adds reactants to this dictionary.
- rstruct (
schrodinger.structure.Structure
) – The reactant structure - rind (int) – Unique index for this reactant structure - used to form the keys in the reactants dictionary
- state (str) – The electronic state of the reactant - should be a module constant from the STATES list
- product_groups (list) – items are BreakingBond and/or LeavingLigand objects - one Reaction is created for each item
- options (argparse.Namespace) – The command line options
- keywords (dict) – The base set of Jaguar keywords to use in Jaguar jobs
- vertical (bool) – True if this is tracking an object that should not have its geometry optimized
- logger (log.logger) – The logger to use
- tracker_class (class) – The tracker class to create for unique fragments
- reactant_title_base (str) – The base name for reactant trackers
Return type: list
Returns: A list of Reaction objects, one or two for each product_groups item. Two Reaction objects are created for each product_groups item if state is in the CHARGED set.
-
schrodinger.application.matsci.fragments.
run_jobs
(trackers, options, logfn)¶ Create all jaguar jobs and run them
Parameters: - trackers (list) – each item is a UniqueTracker object that should create a job to be run - can be product fragments or reactants. Returns True if at least one job did not fail (or there were no jobs to run), otherwise False.
- options (
argparse.Namespace
) – The command line options - logfn (callable) – A logging function
Return type: bool or None
Returns: None if no jobs were run, True if at least one job did not fail, otherwise False
-
schrodinger.application.matsci.fragments.
set_pt_subgroup_info
(struct, name, collapsed=True)¶ Set the properties on the structure to have it incorporate in the proper subgroup
Parameters: - struct (
schrodinger.structure.Structure
) – The structure to set the properties one - name (str) – The name of the subgroup
- collapsed (bool) – Whether the subgroup should be collapsed
- struct (
-
schrodinger.application.matsci.fragments.
write_single_structures
(trackers, writer)¶ Write all single structures to the output file
Parameters: - trackers (list) – Each item in this list is a UniqueTracker object and will be written to the output file
- writer (
schrodinger.structure.StructureWriter
) – The structure writer to use to write structures with