schrodinger.application.matsci.enumeration module

A class and function that help enumerate possibilities - could be enumerating over items of a list or enumerating the element at various atom positions in a structure, for instance.

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.enumeration.Alchemist(master, targets, new_items, child=None)

Bases: object

Class that mutates the element of an atom in a structure

performTransmutation(data, index, item)

Perform a transmutation on a copy of data at index. It is very important that this happen on a copy of data, not data itself.

Parameters:
  • data – The object to transmute a copy of
  • index – An index that tells what part of data to transmute
  • item – The object to mutate data[index] to
Return type:

type(data)

Returns:

A COPY of data, transmuted at index

allTransmutationsCompleted(mydata, myused)

Perform whatever action is required when all transmutations have been performed on the mydata object

Parameters:
  • mydata – The object that is fully transmuted
  • myused (list) – List of indexes that have been transmuted in mydata
runTransmutations(data, used=None)

Begin transmutations.

This Alchemist will determine what targets to transmute based on its set of original targets minus those targets that have been used by previous Alchemists. Each time this Alchemist transmutes an item, it calls its child Alchemist to do its mutations (which calls its child Alchemist each time it transmutes an item, and so on). Thus is the iterative process of transmutating all possible combinations achieved.

If this Alchemist does not have any children, than it is the last in the Alchemist line and it should call allTransmutationsCompleted when it is done with a transmutation.

Parameters:
  • data (object) – The object to be transmuted
  • used (list of int) – The indexes in data of the transmutations performed by parent Alchemists. The last item in this list is used to ensure that this Alchemist does not mutate any target already covered by parent Alchemists.
class schrodinger.application.matsci.enumeration.StructureAlchemist(master, targets, new_items, path, child=None)

Bases: schrodinger.application.matsci.enumeration.Alchemist

An abstract base Alchemist class for Alchemists that transmute Structures - subclasses will probably need to re-implement the performTransmutation and allTransmutationsCompleted methods.

runTransmutations(data, used=None)

Begin transmuating atoms.

This Alchemist will determine what target atoms to transmute based on its set of original targets minus those targets that have been used by previous Alchemists. Each time this Alchemist transmute an atom, it calls its child Alchemist to do its mutations (which calls its child Alchemist each time it transmutes an atom). Thus is the iterative process of transmutating all possible combinations achieved.

If this Alchemist does not have any children, than it is the last in the Alchemist line and it should add a new project entry each time it transmutes an atom.

Parameters:
  • struct (schrodinger.structure.Structure) – The structure object with the transmuted atoms
  • used (list of int) – The atom indexes of the transmuted atoms by parent Alchemists. The last atom in this list is used to ensure that this Alchemist does not mutate any target already covered by parent Alchemists.
class schrodinger.application.matsci.enumeration.ElementAlchemist(master, targets, new_items, path, child=None)

Bases: schrodinger.application.matsci.enumeration.StructureAlchemist

An alchemist class that transmutes elements in a Structure

Note:

The new_items argument to the constructor for this class should have the following format:

type new_items: list of tuple param new_items: Each item of the list is an (element, color) tuple, where element is the atomic symbol of the element to mutate to, and color is the new color for that atom in a form accepted by the _StructAtom.color property

performTransmutation(struct, index, item)

Perform a transmutation on a copy of struct at index. It is very important that this happen on a copy of struct, not struct itself.

Parameters:
  • struct (schrodinger.structure.Structure) – The structure to transmute a copy of
  • index (int) – An index that tells what atom to transmute
  • item (tuple) – An (element, color) tuple, where element is the atomic symbol of the element to mutate to, and color is the new color for that atom in a form accepted by the _StructAtom.color property
Return type:

schrodinger.structure.Structure

Returns:

A COPY of struct with atom index transmuted

fixHydrogens(struct, used)

Correct the number of hydrogens bonded to each transmuted atom

Parameters:
  • struct (schrodinger.structure.Structure) – The structure object with the transmuted atoms
  • used (list of int) – The atom indexes of the transmuted atoms
allTransmutationsCompleted(struct, used)

All transmutations have been performed on struct, write it out to a file if we are keeping this result

Parameters:
  • struct (schrodinger.structure.Structure) – The structure object with the transmuted atoms
  • used (list of int) – The atom indexes of the transmuted atoms
class schrodinger.application.matsci.enumeration.VacancyAlchemist(master, targets, new_items, path, child=None)

Bases: schrodinger.application.matsci.enumeration.StructureAlchemist

An alchemist class that deletes atoms in a Structure and the hydrogens they are bound to

Note:

The new_items argument to the constructor for this class should have the following format:

type new_items: list param new_items: Should be [None]

DELETE_PROPERTY = 'b_matsci_impending_vacancy'
performTransmutation(struct, index, item)

Mark atom index for deletion, and also mark all the hydrogen atoms it is attached to. This will happen on a copy of the input structure.

Normally this method in parent classes actually changes the structure, but in this case, deleting atoms would mess up all the atom numbering for Alchemists down the line, so we only mark those atoms for later deletion.

Parameters:
  • struct (schrodinger.structure.Structure) – The structure to transmute a copy of
  • index (int) – An index that tells what atom to delete
  • item (None) – None - unused
Return type:

schrodinger.structure.Structure

Returns:

A COPY of struct with atom index and attached hydrogens marked for deletion.

deleteAtoms(struct)

Delete all atoms marked for deletion

Parameters:struct (schrodinger.structure.Structure) – The structure object with the transmuted atoms
allTransmutationsCompleted(struct, used)

All transmutations have been performed on struct, write it out to a file if we are keeping this result

Parameters:
  • struct (schrodinger.structure.Structure) – The structure object with the transmuted atoms
  • used (list of int) – The atom indexes of the transmuted atoms
schrodinger.application.matsci.enumeration.perform_transmutations(minimum_transmutations, maximum_transmutations, transmutation_sites, alchemist_creator, data, **kwargs)

Enumerate all possible transmutations on an object

Parameters:
  • minimum_transmutations (int) – The minimum number of transmutations to perform on each object
  • maximum_transmutations (int) – The maximum number of transmutations to perform on each object
  • transmutation_sites (list) – The indexes of the object that are available for transmutation
  • alchemist_creator (callable) – A method that creates an Alchemist object. The method should take the following positional arguments: 1) A list of sites to transmute, 2) A child alchmist (or None if no child). In addition, any additional keyword arguments passed to the perform_transmutations function are passed on to the alchemist_creator function as keyword arguments.
  • data – The object to perform transmutations on
Note:

Any additional keyword arguments are passed to the alchemist_creator function

schrodinger.application.matsci.enumeration.main(*args)