The prop Command

The prop or property command is used to create, modify, query and delete property definitions.

The command has the following subcommands:

prop alias

prop alias
prop alias propertyname aliasname ?propertyname aliasname?...

This command defines an alias name for a property name. After defining an alias, any time the alias name is used as a property name, it is silently and automatically translated to the original property name. It is possible to map an alias name to another alias. Name resolution recursively proceeds until the name can no longer be resolved. Aliases have precedence over basic property names. If an alias name is the same as an existing property name, that existing property becomes effectively invisible and is replaced by the property the alias links to.

The name the alias maps to must be resolvable at the time of definition.

In case the command is used without arguments, it returns a dictionary of current alias definitions. The keys are the recognized alias names and the values the property or second-level alias name the keys are translated to.

Example:

prop alias E_NATOMS E_ATOM_COUNT

After execution, the number of atoms in an ensemble can both be queried via property E_NATOMS (original name) and E_ATOM_COUNT (new alias name).

The default start-up files of the toolkit include a set of alias definitions which map older, less systematic property names as aliases to current official property names.

prop check

prop check propertyname ?objecthandle?...

Verify the syntactic correctness of property data on a list of major objects, such as ensembles, reactions or datasets. The return value is a boolean list of check results, 1 if the data is formatted correctly, 0 if not. If the property is not set for the object, the returned status value is -1.

In case there is no check function (attribute checkfunction , see prop set ) defined, or it cannot be found, an error results. More details on the operation of the check function can be found in the prop set subcommand documentation.

Example:

prop check E_CAS $eh

This command checks, if property E_CAS is set for the ensemble, whether it is formatted correctly by calling the Tcl check function defined for E_CAS . For this property, the check function runs the CAS check digit algorithm on the data value. It catches encoding errors where the check digit does not match the value as re-computed from the other digits.

prop compare

prop compare propertyname value1 value2 ?cmpflags? ?param1? ?param2?
prop compare propertyname(field) value1 value2 ?cmpflags? ?param1? ?param2?
prop compare datatypename value1 value2 ?cmpflags? ?param1? ?param2?

Compare two property values. In the first two forms, the name of the property, or of a property field, is used primarily to get the data type for the decoding of the comparison values and the selection of the applicable comparison function. Alternatively, a data type name can also be supplied directly.

The value parameters are expected to be suitable string representations for the underlying data type. If the property name form of the command is used, they may be specified as enumerated values and other formats which can only be decoded with the aid of information attached to a specific property. The comparison values are converted using the string or Tcl object input function associated with the data type. If the property name form is used, they are also subject to any other tests associated with the property, such as constraints or regular expression pattern matches.

The cmpflags argument is a list of words which are used to select specific comparison function modes. The default is an empty list. In that case, no c modification flags are passed to the comparison function. In case a mode bit is selected which is not supported by a specific comparison function, it is silently ignored. Some of the flags may be combined to yield specific useful comparison results, but it is the responsibility of the implementation of a data-type specific comparison function to determine which flags can be combined, and which have precedence in case of conflicts. The following words are currently recognized:

The return value is the integer value returned by the comparison function. For most modes, this is either 0 (values are equal), 1 (left value is larger) or -1 (right value is larger). Some modes do however return other values. For example, similarity bit vector or bit set comparisons return a value between 0 and 100.

The default values for the optional extra parameters are both zero.

Example:

prop compare E_SCREEN [ens get $eh1 E_SCREEN] [ens get $eh2 E_SCREEN] tanimoto

This command performs a Tanimoto comparisons on the screening vectors of the two ensembles and returns a score in the range 0..100.

prop configure

prop configure propertyname

Execute the property configuration function (attribute configfunction ). If there is no function defined, or the execution of the configuration function fails, the command does nothing. By convention, a property configuration function opens a Tk window with various GUI elements for the convenient adjustment of computation parameters. Because this is usually a graphical operation, and the overhead of extending the property slave interpreter to a fully GUI-enabled version, this command is always executed in the global interpreter.

Note that this function usually does not directly result in the change of property attributes and parameters. The standard approach is to set up and display a Tk window, which remains open until it is closed by the user, while this command returns immediately. Changes from adjustments in the property panel take effect asynchronously only after an apply button has been pressed by the user.

prop create

prop create propertyname ?attribute value?...

Create a new property definition, and optionally set attributes.

The name of the new property must conform to the general property naming conventions in the toolkit. Indexed fields, instance identifiers, registration ID and other name parts aside from the base name are ignored.

In case a property definition for the same property name is available, and either already loaded or can be found by in the property autoloader path, the command internally succeeds, but still returns a Tcl error. This is intended to prevent the accidental overwriting of system property definitions, which can lead to problems which are difficult to detect and may lead to crashes, for example when the data type of an internally used property is changed in an incompatible fashion. Acceptance of the command when overwriting is desired can be forced by surrounding it in a catch statement.

A property created without additional attributes has no associated functions, is of data type string and generally has empty default values for all attributes. The only exception is the URN namespace, which is set to the local namespace, and the creation date, which is set to the current time. In addition, the property object class is automatically set from the prefix of the specified name.

The processing of the attribute/value pairs is equivalent to a prop set command. The possible attributes are described under that subcommand.

Example:

prop create A_MYPROPERTY datatype int author “A. Nonymouse”

This statement creates an atom property (determined by the standard A_ prefix) of data type integer and a curious author attribution.

prop defined

prop defined propertyname

Attempt to resolve the specified property name. If the property name is not yet part of the internal property database, an attempt is made to resolve it via the auto-loading mechanism. This is different from the similar prop exists command. The boolean return value is zero if the property name could not be resolved, one otherwise.

prop available is a deprecated alias of this command.

prop delete

prop delete propertyname ?force?

This command deletes a property definition from memory. It does not remove the files the property is defined by, if it exists. Property names which are not defined when the command is run are silently ignored. By default built-in properties cannot be deleted. In order to force this, the optional fourth boolean parameter must be set. Deleting built-in properties is risky and can lead to crashes if the property is required as part of internal computations.

The property is not actually removed from the internal database until all instances of data of that property attached to chemical objects have been deleted. In such a case, the property name is not usable any longer in script commands, but implicitly information such as data type and formatting instructions are still used until all data associated with the original definition has been purged. The name of a half-deleted property still shows up in commands like ens props , but commands such as ens get fail, even for existing property data because the translation of the property name in the request to the internal data structure is no longer possible. However, operations such as file I/O which do not rely on properties looked up by string name may still succeed. The deletion of chemical objects with data from deleted properties always succeeds, decrements the reference counts and frees memory.

It is possible to re-define a property with the same name as a deleted one, even if there is still pending data. However, this is highly discouraged and potentially confusing.

If the supplied property name is an alias, the property the alias is pointing to is deleted, not the alias definition (see prop unalias for this function). In addition, all alias definitions which point to the deleted property are also recursively deleted.

prop dup

prop dup propertyname newpropertyname

Create a new property definition using an existing definition as a template. In typical cases, the property duplicate is further customized by prop set commands. The new property name should not be the name of an existing property, though this is not illegal. In that case, it hides the definition of the original name similar to an alias definition.

The return value of this function is the name of the duplicated property.

prop exists

prop exists propertyname

This command checks whether a property is currently loaded in the in-memory database. No attempt is made to look up the definition via the auto-loading mechanism if it is not yet present. The boolean return value is zero if the definition is currently unknown, one otherwise. For a related command with implied auto-loading, see the prop defined command.

prop get

prop get propertyname attribute

Get the value of a property attribute. The property attributes are explained in the paragraph dealing with the prop set subcommand. The return value is the current setting of the requested attribute.

The parameters attribute is a special case in multi-threaded scripts. Its value is thread-local. Every thread may have a different parameter set for each property. In order to obtain the base parameter set, the attribute globalparameters may be read.

prop getparameter

prop getparameter propertyname parametername ?usedefault?

Get the value of a computation function parameter, or of a computation function default parameter.If the last command argument is not specified, or set to a boolean false , the queried parameter collection is the current parameter set (property attribute parameters ). Otherwise, it is the default parameter collection (property attribute defaultparams ). If the requested parameter is not found in the parameter set, an error results. Otherwise, the result of the command is the retrieved parameter value.

In a multi-threaded environment, a returned parameter value (but not a default parameter value) is thread-dependent. Every script thread has an independent property computation parameter set which is copied from the global value in the base interpreter the first time a property is referenced in a thread.

This command may be abbreviated to prop getparam .

prop isdefault

prop isdefault propertyname value

Check whether a property data value is the same as the property default value. The return value is the boolean test result.

prop ismagic

prop ismagic propertyname value

Check whether a property data value is the same as the property magic value. The return value is the boolean test result.

prop list

prop list ?pattern? ?computable_only?

List all currently loaded property definitions, including built-in definitions. If desired, a string pattern filter can be supplied to select only specific properties. The optional fourth parameter can be used to restrict the list to properties which are associated with a computation function.

Example:

prop list E_* 1

lists all currently defined and loaded ensemble property definitions which are computable. Computability is only checked at the property definition level. It is no guarantee that the property computation succeeds for any specific ensemble or other chemistry object.

prop query

prop query keyword ?objectclass? ?mode? ?casesensitivity?

Search the internal property database by matching the keyword against a standard set of property attributes, such as name, description, keywords, category, comment and UUIDs. Only the current memory database is checked, no auto-loading or repository checks are performed.

By default all property definitions are matched. The object class argument (such as atom ) can be used to limit the search to properties for a specific object class. Providing an empty argument is the same as omitting the argument.

The optional mode argument changes the string comparison mode. The default is equal , other possibilities are substring , left (match beginning of string), right (match end of string), like (as the SQL operator), glob or regexp .

The final argument can be case (case-sensitive matching) or nocase (case-insensitive comparison, this is the default).

The return value is a list of the version UUIDs of the matched properties.

prop read

prop read filename ?doinstances?

Read a file with one or more property definitions. All property definitions found in the file are added to the internal in-memory database. By default, or when the doinstances parameter is set to 0, a definition from the file which refers to the same property as one already loaded implicitly deletes the old definition (see prop delete for a discussion of the consequences of this operation) from memory before the new definition is added. If the optional argument is set to a true boolean value, an additional definition with an instance number one higher than the highest currently defined instance is created instead.

The return value of the command is a list where the first element is the total number of property definitions read from the file, and the second element the name of the first read property.

prop reload

prop reload propertyname

A convenience command for property computation module development. It first attempts to delete the current property definition. If this fails because its reference count is not zero, and attempt is made to reach zero by deleting all objects which may contain property data of the object class the property is associated with (e.g. ensembles if the property is an atom, ring or ensemble property). If the deletion now succeeds, the property is auto-loaded again, presumably with an updated processing script or module. Specifying an unknown property, a property where the reference count cannot be decremented to zero, or for which the definition cannot be found in the property loader path is an error.

The command returns the property name.

prop set

prop set propertyname ?attribute value?...

This command is used to modify the attribute sets of existing property definitions. If the property name cannot be resolved, an error results. The following attributes are currently supported:

The prop set command supports a special attribute value syntax for manipulating bitset-type attributes. If the first character of the argument is a minus character (-), the named bits in the set identified by the remainder of the argument are unset. If it is a plus (+), they are additionally set. With an equal sign (=), or no special lead character, the flag set replaces the old value. A leading caret character (^) toggles the selected bits.

Example:

prop set E_SCREEN flags +locked:fixedlength
prop set E_SCREEN flags -locked

prop setparameter

prop setparameter propertyname ?parameter value?...
prop setparameter propertyname dictionary

Set zero or more computation parameters. In multi-threaded scripts, this effects only the thread-local parameter set. Only the base interpreter, and its slaves, manipulate the global parameter set, in addition to its own thread-local set.

In the second command variant, the dictionary argument must be a properly formed Tcl dictionary with suitable keyword/value pairs. If that is the case, the dictionary is implicitly expanded and processing proceeds as in the first command variant.

An attempt to set a parameter whose name is not listed in the current parameter set fails with an error. This is a safety mechanism to prevent typos in parameter names. Nevertheless, setting such an unknown parameter does succeed internally. In order to force the addition of a new parameter, the statement can be written with a catch command:

catch {prop setparam $pname my_new_parameter “New World!”}

This command can be abbreviated as prop setparam .

There is no command to unset a single parameter. This can be done by retrieving and manipulating the complete parameter list via a command like

set d [dict create {*}[prop get $propname parameters]]
dict unset d $obsolete_param
prop set $propname parameters $d

prop sqldecode

prop sqldecode propertyname value

Attempt to decode a property value from a string formatted in SQL -style encoding. If it succeeds, its standard Tcl representation is returned. Otherwise, an error results.

prop sqlencode

prop sqlencode propertyname value

Encode a property value in SQL formatting. The value parameter must be a valid representation of the property value in its Tcl format. If the decoding succeeds, and the data type handler supports SQL formatting, the returned value is suitable for constructing SQL statements.

prop sqlformat is an alias for this command.

prop string

prop string propertyname

Get the XML-style property definition record as a string. This is equivalent to writing out the property definition and reading the output file as text data.

prop subcommands

prop subcommands

This command returns a list of all the subcommands of the prop command.

prop unalias

prop unalias ?alias_name?...

Remove one or more alias definitions introduced by a prop alias command. If a specified alias name does not exist, it is silently ignored. If an existing property was hidden by an alias definition, it becomes visible again. However, existing property data in the name of the old alias on chemical objects continues to refer to the property definitions it was alias-mapped to when it was created.

prop write

prop write propertyname ?filename?

Write the current definition of the property to a file. The file can be loaded into future script interpreters explicitly (see prop read command) or implicitly via the property definition auto-load mechanism. If no file name is given, the name of the file is automatically constructed from the property name in lower case and the suffix . xpd for the new-style XML property definitions .

In addition to normal file names, the magic names stdout and stderr may be used, as well as already opened Tcl socket and file handles, plus pipes indicated by a file name which starts with “|”. Writing to Tcl channels is not supported on the MS Windows platform.If the file name argument is a directory, the file name is still automatically generated, and the file written in that directory. If a file name with an explicit .prp suffix is specified, the output is written in the legacy keyword/value ASCII -based file format. Old property definition files continue to be supported for both input and output. They are backward-compatible with earlier toolkit versions, though they cannot store all content of the newer XML format.

If the output is written to a regular file named in the command, the suffix .xpd is automatically added if necessary, and the output contain a single property definition record. By writing to a Tcl channel, it is possible to write multiple properties into a single file, and these can be read in a single operation by the prop read command. For explicit file input, neither one of the two standard suffixes nor the standard file name derived from the property name are mandatory, but the naming convention must be adhered to in order to enable auto-loading of property definitions.

It is possible to write out built-in property definitions. For reference purposes, current toolkit distributions contain a BUILTIN directory which contains dumps of the property definitions of the built-in property set.

The command returns the name of the file written to.