### Attribute Calculator

Attribute Calculator generates new numerical attributes from existing ones. The calculated attribute values, or even simply the values of an existing attribute, can be written to a file.

There are several ways to start Attribute Calculator, a tool in the Structure Analysis category.

One must specify a name for the attribute to be created and whether it will be an attribute of atoms, residues, or molecules (molecule models). The name must be an alphanumeric string without spaces; it can include underscores, but should not begin with a underscore, digit, or capital letter. Atom attributes with names containing area, volume, or charge (after word separation by camel case and/or underscores) will be totaled automatically to give the corresponding residue attributes.

The Formula is an arithmetic expression. Supported operators are + (addition), (subtraction), * (multiplication), and / (division). Parentheses can be used for grouping.

Terms in the expression can be:
• numbers - simple integers and floating-point numbers only, i.e., no scientific notation
• function calls - currently, only the functions sum and average are supported. Averages are calculated considering only the atoms (or residues) with values for the attribute. For example, the average kdHydrophobicity of a model containing amino acid and water residues is calculated considering only the amino acid residues.
• attributes - attributes are of the form scope.attribute. The scope can be atom, residue, or molecule, and attribute is the name of a numerical attribute of the appropriate scope (for example, see the lists of attributes automatically defined for atoms, residues, and molecule models). When defining a larger scope and referring to values from a smaller scope, the attribute is actually a list of values. Typically, the value list must be reduced to scalar using a function.

For example, to define a residue (or molecule model) attribute equal to the average B-factor of its constituent atoms:

``` average(atom.bfactor) ```

Several options further affect the calculation and attribute assignment:
• Restrict attribute assignment to current selection, if any - whether, if a selection exists, to assign values of the new attribute to the selected items (atoms, residues, or molecule models) only
• Restrict formula domain to current selection, if any - whether, if a selection exists, only the attribute values of selected items should be used in the calculation
• Open Render/Select by Attribute - whether to open the Render/Select by Attribute tool after assigning attribute values. Even when this option is off, the attribute(s) will be available within the Render/Select by Attribute tool if it is opened later in the session.
• Show calculation results in Reply Log - whether to report results in the Reply Log
• Save calculation results to file - whether to write the results to a text file, in the format used as input to Define Attribute

OK performs the calculation/assignment and dismisses the dialog. Apply performs the calculation/assignment without dismissing the dialog. Close dismisses the dialog, and Help opens this manual page in a browser window.

The formula is not reevaluated automatically; if any constituent attribute values change, OK or Apply must be used again to recalculate the result with the new values.

UCSF Computer Graphics Laboratory / March 2014