TOP commands and variables

TOP variables come in four varieties -- strings, reals, integers, logicals -- as either single values or lists. The equivalents in Python are the standard 'str', 'float', 'int' and 'bool' types, respectively, while lists can be represented as 'list' or 'tuple' objects. In essence, this means that strings must be quoted, logical on and off become bool True and False respectively, and lists must be comma-separated and enclosed in parentheses. Also, the '=' operator is not mandatory in TOP, but it is in Python. See the Python documentation for more information. For example, consider the following assignments in TOP:

SET STRVAR = foo                   # Set a string variable (quotes not required)
SET REALVAR 3.4                    # Set a real variable (= not required either)
SET INTVAR = 4                     # Set an integer variable
SET LOGVAR = on                    # Set a logical variable
SET INTLIST = 1 1 3 5              # Set a list of integers
SET STRLIST = 'one' 'two' 'three'  # Set a list of strings
The equivalent Python code would be:
STRVAR = 'foo'                     # Set a string variable
REALVAR = 3.4                      # Set a real variable
INTVAR = 4                         # Set an integer variable
LOGVAR = True                      # Set a logical variable
INTLIST = (1, 1, 3, 5)             # Set a list of integers
STRLIST = ('one', 'two', 'three')  # Set a list of strings

Variables in TOP are case-insensitive; that is, the names GAP_PENALTIES_1D and gap_penalties_1d refer to the same variable. (Upper case is usually used, but this is just by convention.) Python variables are case-sensitive, so these two names refer to different variables. For consistency with other codes, all Python commands and variables used by MODELLER are lower-case.

All variables in TOP are global; that is, once they are set, their value is kept for the rest of the program (or until changed again). This is irrespective of whether the variable is set while calling a TOP command, or whether an explicit SET command is used. For example, this TOP script:

ALIGN GAP_PENALTIES_1D = 900 50
will behave identically to this code:
SET GAP_PENALTIES_1D = 900 50
ALIGN

In Python, on the other hand, each command takes a number of arguments. For example, the align() command takes a gap_penalties_1d argument. The value of this argument affects only this call to align(), i.e. it is a local variable. Thus, the exact equivalent to both of the TOP scripts above would be:

aln.align(gap_penalties_1d=(900, 50))
where 'aln' is an alignment object (see section C.2.2). This only sets the 1D gap penalties for this invocation of align(), and so is less likely to cause problems later in your script. If you want to call a routine several times with the same set of arguments, it is recommended that you save the arguments in local Python variables, use subroutines or classes, or use 'for' loops.

Automatic builds 2015-05-19