schrodinger.infra.propedit module

Support functions for Structure property manipulation functions in the propeditor script.

Structures can be created by reading files in any supported format.

Manipulations which can be performed on a Structures properties are:

  • Add: Add a new property with a given value
  • Delete: Delete a named property
  • Rename: Rename a property, preserving the value
  • Merge: Combine two properties into a new property, delimiter is specified
  • Clear: Clear out the property value
  • Slice: Create a new property which is made up of a specified range of
    characters from an existing property
  • Split: Create two new properties by dividing an existing property using
    a delimiter
  • Export: Write the properties to a CSV format file
  • Import: Read properties from a CSV format file
  • Formula: Apply a formula to create a new property.

The formula must be in terms of existing properties, constants, operators ‘**’, ‘=’, ‘+’, ‘-‘, ‘*’, ‘/’, ‘(‘, ‘)’ or functions from the following list:

  • acos
  • asin
  • atan
  • cos
  • cosh
  • degrees
  • exp
  • fabs
  • floor
  • log
  • log10
  • radians
  • sin
  • sinh
  • sqrt
  • tan
  • tanh

Copyright Schrodinger, LLC. All rights reserved

schrodinger.infra.propedit.fxnname()

Return a function’s name

schrodinger.infra.propedit.checkCompatibleTypes(prop1, prop2)

Check that the prop1 can be converted into a prop of type prop2

schrodinger.infra.propedit.get_op_positions(formula, allowed_operators=['**', '=', '+', '-', '*', '/', '(', ')'])

Get a list of tuples of start and end positions for all operators. These tuples may be overlapping (e.g., * also matches **, so ** is included twice) and will not be sorted. Generally, these positions will be processed by merge_op_positions.

schrodinger.infra.propedit.checkCT(ct, ranges)

Checks individual structure (ct) for compliance with user input range parameters. ‘ranges’ contains a list of lists - ranges[i][0] is the property name ranges[i][1] is the minimum value ranges[i][2] is the maximum value Boolean properties are checked against ranges[i][1] which can be True or False

Returns True if ‘ct’ complies with all range parameters, False otherwise

False is returned if the property name is not known or if there is some other type of exception when retrieving it.

schrodinger.infra.propedit.merge_op_positions(op_positions)

Merge individual operator positions into a list of all positions of the formula string and whether they contain an operator The result is a list of Boolean values for each character in the formula string indicating if that character is a known operator.

schrodinger.infra.propedit.generate_groups(formula)

Build ‘groups’ of the formula pieces, marking each as an operator or not

schrodinger.infra.propedit.check_formula(formula, existing_properties=[])

Does some basic checking of the formula

The checks include: 1) Must have 1 and only 1 = 2) To the left of the = must be a valid real or int property 3) Must have only allowed operators, allowed functions, property names, or numbers (ints or float) 4) (optional) Must have only existing properties

schrodinger.infra.propedit.generate_eval_string(groups, group_types, ct_str='ct')

Generate a string to use in eval for calculation from the groups

schrodinger.infra.propedit.generate_eval_string_all(formula_part, ct_str='ct')

Generate a string to use in eval for calculation from the formula

schrodinger.infra.propedit.calcProperty(ct, formula, tocheck_formula=True)

Calculate and set a new property based on calculation from a function of existing properties. The formula must be of the form: new_property = <old_property|operator|function|constant>

schrodinger.infra.propedit.listProps(prop_dict)

Print the values for a set of properties. The properties are sorted alphabetically.

schrodinger.infra.propedit.listElements(structure)

Sorts the elements in a list and displays them with a count as the first line

schrodinger.infra.propedit.sliceProp(ct, propn, newn, startval, endval)

Takes a property, slices its value according to input endpoints and creates a new property with the sliced portion as the value. Boolean properties cannot be sliced.

schrodinger.infra.propedit.merge(ct, prop1, prop2, delim, newname)

Merges the value of two properties according a specified delimiter and creates a new property with the merged value and the name ‘newname’.

schrodinger.infra.propedit.addProperty(ct, prop, val, add, num=-1)

Adds a property to the input structure with the given value. If a property of that name already exists then it will overwritten.

schrodinger.infra.propedit.copyProperty(ct, prop1, prop2)

Copies the value of one property to another property. If the source property does not exist then the destination (prop2) is set to a default value - 0, ‘’ or False depending on the type.

schrodinger.infra.propedit.renameProperty(ct, prop1, prop2)

Renames a property. Algorithm: Create a new property with the new name, copy values of the old property to the new property and delete the old property. Uses copy and delete methods.

schrodinger.infra.propedit.delete(ct, prop)

Deletes a property from a structure

schrodinger.infra.propedit.clear(ct, prop)

Clears the value of a property For integer and float property types sets property value to zero. For string property types sets property value to “” For boolean property type sets property value to False

schrodinger.infra.propedit.split(ct, propn, prop1, prop2, delim)

Splits the value of a property according to a given delimiter. Creates two new properties. Property values of these new properties are the pieces of the old property that remain after the split.

schrodinger.infra.propedit.conv_bool(value, allow_onezero=True)

Convert a boolean string to True/False.

The following are considered True: True, T (case insensitive), 1 (if allow_onezero is True) The following are considered False: False, F (case insensitive), 0 (if allow_onezero is True) If the value doesn’t match either of these, a ValueError is raised.

schrodinger.infra.propedit.get_type(value, onezero_boolean=True)

Get the type of a string value

The types are assigned based on drop-down, conversion 1) boolean (b), else 2) int (i), else 3) float (r), else 4) string (s)

schrodinger.infra.propedit.readData(filename, ct_key_prop, csv_key_prop, tab_delim=False, data={}, prop_group='user', onezero_boolean=True, use_first_value=False, missing_key='MISSINGENTRY')

Read the data of a .csv file into a dict using the csv package.

This assumes the first line is a list of properties.

Returns a tuple of (data, ok_status). (If no problems were encountered, ok_status is True, otherwise it is False.)

This also assigns property types as follows:

  1. If the property name matches [ribs]_, the type is determined from the prefix.
  2. The property values are then checked to see if it is convertible to
    1. boolean (with handling for True|T|1 or False|F|0), else
    2. int, else
    3. float (assigned real), else
    4. string

The types are based on the ‘least stringent’ of the data, e.g., data with values of 1.0,3.4,1 ==> float, with values of 1.0,4,3a ==> string. If all values are 1|0 and <onezero_boolean> is True, the property is assumed to be a boolean

This also builds a dictionary of valid values for missing instances when doing the import. The values are:

  • boolean: False
  • int : 0
  • real : 0.0
  • string : ‘’
schrodinger.infra.propedit.exportFile(ct, fileobj, num, props=[], tab_delim=False)

Exports a .mae file into a .csv file

schrodinger.infra.propedit.printvals(props, input_fn, rules)

Given a list of properties and an input file prints out the values of every property for every ct in the input file If a set of rules has been entered, first checks if the CT abides by the rules and only prints out property values if it does. See checkCT for a description of how the ‘rules’ are specified.