Package schrodinger :: Package application :: Package desmond :: Module mdkey
[hide private]
[frames] | no frames]

Module mdkey

Functions for initializing, reading, and writing Desmond parameters.

This is also where global variables that are shared among different tabs are defined.

Copyright Schrodinger, LLC. All rights reserved.

Classes [hide private]
  _Bool
  GuiMap
  CfgAtom
This class represents the "atomic" parameters in a config file.
  List
  Key
  _Evalor
  FepSchedule
  AtomGroup
Functions [hide private]
 
_is_equal(a, b, epsilon=1E-6)
Compares two floating numbers and returns True if the absolute difference is within epsilon (defaults to 1E-6), False if not.
 
_boolean(s)
Returns 1 if the string 's' is one of the following: 'true', 'yes', 'on', '1', 't', 'y'.
 
_debug_print(s, nl=True)
 
_update_key_with_file(key, fname, raise_exception)
 
_parent_dir(dir_name, up=1)
Returns the parent directory name.
 
gen_key(file=None, raise_exception=False)
Returns a Key object that is constructed based on 'DEFAULT_CONFIG' (see above) and the default config file that is saved in the directory as given by 'DEFAULT_CONFIG_FILE' (see above).
 
diff(x, reference)
 
__op_eq(key, arg)
 
__op_lt(key, arg)
 
__op_le(key, arg)
 
__op_gt(key, arg)
 
__op_ge(key, arg)
 
__op_and(key, arg)
 
__op_or(key, arg)
 
__op_not(key, arg)
 
__op_at(key, arg)
 
__op_minus(key, arg)
 
__op_cat(key, arg)
 
__op_sizeof(key, arg)
 
is_powerof2(x)
Returns True if 'x' is a power of 2, or False otherwise.
 
_xchk_power2(key, val, prefix, ev)
 
_xchk_file_exists(key, val, prefix, ev)
 
_xchk_dir_exists(key, val, prefix, ev)
 
_eval(key, arg)
 
reg_xcheck(name, func)
 
_match(check_func, key, valid, ev, prefix)
 
_check_atom(key, valid, ev, prefix)
 
_check_list(key, valid, ev, prefix)
 
check_key(key, valid=Key(__CONFIG_VALIDATION), ev=None, prefix="")
 
check_key2(key, valid)
 
extract_cfg(cpt_fname, min_size=1048576)
Extracts the extended ark content from a checkpoint file.
 
has_plugin(key, plugin_name)
 
add_plugin(key, plugin_name, position=None)
 
remove_plugin(key, plugin_name)
 
has_mmffio(ct)
Returns 1 if 'ct' has an mmffio block, or 0 if it does not.
 
has_fepio(struc)
Returns True if any of the Structures in 'struc' have a fepio_fep block, or False if they do not.
 
get_model_system_type(struc)
Returns 1 if the CTs in 'struc' have a fepio_fep block.
 
prep_struc(struc)
This function does the following mutations to each element of 'struc':
 
clean_struc(struc)
For each 'Structure' ojbect in 'struct', this function removes the '_ffh' attribute of the member object and frees the memory as held by '_ffh'.
 
get_box(struc)
Given a list of CTs, return None if something is wrong, or a tuple of (size_x, size_y, size_z, (9-element list for box matrix)).
 
dotprod(v, u)
Returns the dot product of two 3-D vectors.
 
crossprod(v, u)
Returns the cross product of two 3-D vectors.
 
norm(v)
Returns the norm of the 3-D vector 'v'.
 
get_boxsize(box)
Given a simulation box in the form of a 3x3 matrix, this function returns the size of the box.
 
get_boxvolume(box)
 
get_homebox(box, cpu_top)
 
is_triclinic_box(box)
 
get_clone_xyz(r_clone, homebox_volume, homebox_size)
 
set_farterm(key)
Optimizes the parameters of the far term of the Coulombic potential.
 
optimize_key(key, n_k=None, should_retry=True, num_atom=None, grid=1.2)
Optimizes the simulation parameters in 'key', where 'key' must represent a complete config file.
 
_calc_vdw_lambda(n_win)
Given the number of windows, returns a list of lambda values for VDW potentials.
 
fep_schedule(n_win, fep_type="alchemical")
Returns a FEP schedule, which is calculated for the given FEP type ('fep_type').
 
_default_group_selector(grp)
 
condense_atom_group(grp, group_selector)
 
compare_atom_group(grp1, grp2, group_selector=_default_group_selector)
Compares two given atom groups 'grp1' and 'grp2', and returns True if they are the same or False if they are not.
 
get_asl(raw_grp)
Returns an ASL string for a given group of atoms ('raw_grp').
 
get_atom_grp(struc)
 
del_all_atom_grp(struc)
 
inject_atom_grp(struc, atom_grp)
 
get_restr(struc)
 
restr_grp_selector(grp)
 
compare_restr_grp(grp1, grp2)
Compares two given restraint groups 'grp1' and 'grp2', and returns True if they are the same or False if they are not.
 
resize_restr_block(ffh, size)
Resizes the "ffio_restraints" block, i.e., changes the number of entries of the block.
 
set_restr(ffh, i, k, i_atom, x, y, z)
 
set_restr_block(ct, restr)
 
inject_restr(struc, restr_grp)
 
get_restr2(struc)
This differs from 'get_restr' in that this one get the complete restraint information whereas 'get_restr' does not get the atom coordinates and assumes that the force constants are the same for x, y, and z directions.
 
merge_restr2(ct, restr, k, atom_list)
 
set_restr2(struc, restr)
Variables [hide private]
  DEFAULT_CONFIG = "...
  __CONFIG_VALIDATION = "...
  APPDATA_DIR = mm.mmfile_schrodinger_appdata_dir()
  DEFAULT_CONFIG_FILE = os.path.join(APPDATA_DIR, "desmond20", "...
  DEFAULT_CONFIG_FILE_OLD = os.path.join(APPDATA_DIR, "desmond10...
  NEW_CONFIG_DIR = os.path.join(APPDATA_DIR, "desmond20")
  OLD_CONFIG_DIR = os.path.join(APPDATA_DIR, "desmond10")
  MACRO_NAMESPACE_NAME = "desmond_macro"
  __CHECK_CFG_DEBUG = False
hash(x)
  __debug_str_buf = ""
  __OP = {"==": __op_eq, "<": __op_lt, "<=": __op_le, ">": __op_...
  __TYPE = {"str": str, "float": float, "int": int, "bool": bool...
  __CONVERTIBLE_TO = {int: [float,],}
  __xcheck = {"power2": _xchk_power2, "file_exists": _xchk_file_...
  CFG_PATTERN = re.compile("\{[ -~\s]{300,}\}")
  PREDEFINED_ATOM_GROUP = ["frozen",]
  ATOMGROUP_PREFIX_NAME = "i_ffio_grp_"
  ATOMGROUP_PREFIX_LEN = len(ATOMGROUP_PREFIX_NAME)
  a = Key("{a = 1}")
Function Details [hide private]

_boolean(s)

 

Returns 1 if the string 's' is one of the following: 'true', 'yes', 'on', '1', 't', 'y'.

Returns 0 if it is one of the following: 'false', 'no', 'off', '0', 'f', 'n'.

Case difference will be ignored.

Raises a ValueError exception if 's' is none of the above strings.

_parent_dir(dir_name, up=1)

 

Returns the parent directory name.

Parameters:
  • up - This should be a non-negative integer value indicating the parent along the path. Default value is 1, indicating the immediate parent. Value 2, for example, indicates the parent of the immediate parent directory.

gen_key(file=None, raise_exception=False)

 

Returns a Key object that is constructed based on 'DEFAULT_CONFIG' (see above) and the default config file that is saved in the directory as given by 'DEFAULT_CONFIG_FILE' (see above).

If the default config file is found, the values there will be used to update those as in 'DEFAULT_CONFIG'.

extract_cfg(cpt_fname, min_size=1048576)

 

Extracts the extended ark content from a checkpoint file. This function returns a string that is bracketed by '{}'.

The ark as represented by the string contains the following values:

  • argv : the argument vector
  • boot_timestamp : the boot time for the program
  • chemical_time : chemical time in pico seconds
  • config : the ark file
  • threader_size : the number of threads
  • version : the desmond version
  • world_size : the number of processors

has_fepio(struc)

 

Returns True if any of the Structures in 'struc' have a fepio_fep block, or False if they do not.

Parameters:

get_model_system_type(struc)

 

Returns 1 if the CTs in 'struc' have a fepio_fep block. Returns 2 if the CTs in 'struc' have a non-empty ligand atom group and do not have an fepio_fep block. Returns 0 otherwise.

Parameters:

prep_struc(struc)

 

This function does the following mutations to each element of 'struc':

  1. It adds a pointer to the the ffio block. This pointer is saved into the 'Structure' object as the '_ffh' attribute.
  2. Second, it removes the ffio block from the CT. This treatment is necessary for use of a few functions below (specifically, calc_average_vdw_coeff, inject_restr, set_restr_block).
Parameters:

clean_struc(struc)

 

For each 'Structure' ojbect in 'struct', this function removes the '_ffh' attribute of the member object and frees the memory as held by '_ffh'. This "cleaning up" may be necessary for the 'Structure' objects to be garbage-collected.

Parameters:

get_box(struc)

 

Given a list of CTs, return None if something is wrong, or a tuple of (size_x, size_y, size_z, (9-element list for box matrix)).

This function will check the consistency of the simulation-box data through all CTs.

Parameters:

fep_schedule(n_win, fep_type="alchemical")

 

Returns a FEP schedule, which is calculated for the given FEP type ('fep_type').

Parameters:
  • fep_type - Can take the following values: "alchemical", "ligand_binding".

compare_atom_group(grp1, grp2, group_selector=_default_group_selector)

 

Compares two given atom groups 'grp1' and 'grp2', and returns True if they are the same or False if they are not.

Both 'grp1' and 'grp2' should be lists of AtomGroup objects.

Note that empty groups are ignored in the comparison.

get_asl(raw_grp)

 

Returns an ASL string for a given group of atoms ('raw_grp').

Parameters:
  • raw_grp - Must be an iterable of 2-element tuples. The first element of the tuple is the entry ID, the second is the atom ID within the entry.

compare_restr_grp(grp1, grp2)

 

Compares two given restraint groups 'grp1' and 'grp2', and returns True if they are the same or False if they are not.

Both 'grp1' and 'grp2' should be lists of 'AtomGroup' objects. Note that each 'AtomGroup' object's 'name' attribute should be the restraint force constant of the 'float' type.

Note that any group with a force constant of 0.0 will be ignored as it does not have any effects on the actual simulation. This means if the atom sets of two groups are different but their force constants are 0.0, then this is not considered as a real difference. Also note that empty groups are ignored in the comparison.

resize_restr_block(ffh, size)

 

Resizes the "ffio_restraints" block, i.e., changes the number of entries of the block.

What will happen?

  • If the new size is the same as the existing size, nothing changes.
  • If the new size is smaller, the entries at the end of the block will be deleted.
  • If the new size is larger, new entries will be appended. These new entries will have undetermined values.
Parameters:
  • ffh - The handle of the ffio block.
  • size - The wanted size of the restraint block.

Variables Details [hide private]

DEFAULT_CONFIG

Value:
"""{
Desmond = {
   config_version = 2
}
global_cell = {
   reference_time       =  0.0
   topology             =  periodic
   n_replica            =  1
...

__CONFIG_VALIDATION

Value:
"""{
Desmond = {
   config_version = {
      type  = int
      range = [2 2]
   }
}
global_cell = {
...

DEFAULT_CONFIG_FILE

Value:
os.path.join(APPDATA_DIR, "desmond20", "desmond_default.cfg")

DEFAULT_CONFIG_FILE_OLD

Value:
os.path.join(APPDATA_DIR, "desmond10", "desmond_default.cfg")

__OP

Value:
{"==": __op_eq, "<": __op_lt, "<=": __op_le, ">": __op_gt, ">=": __op_\
gt, "&&": __op_and, "||": __op_or, "!": __op_not, "@": __op_at, "-": _\
_op_minus, "cat": __op_cat, "sizeof": __op_sizeof,}

__TYPE

Value:
{"str": str, "float": float, "int": int, "bool": bool, "enum": str, "l\
ist": List,}

__xcheck

Value:
{"power2": _xchk_power2, "file_exists": _xchk_file_exists, "dir_exists\
": _xchk_dir_exists,}