# Foldit Lua Function band.Add

*1,452*pages on

this wiki

## band.Add Edit

- Function
`boolean band.Add(integer segmentOrigin, integer segmentXAxis, integer segmentYAxis, number rho, number theta, number phi, [integer atomIndexOrigin], [integer atomIndexXAxis], [integer atomIndexYAxis])`- Description
- Add a band to empty space.
- V1 Function Name
`New to V2`- More Information
**Details**

## Remarks Edit

segmentOrigin, segmentXAxis, and segmentYAxis must be a valid segment number and must be different from each other.

rho is a distance and must be a value greater than 0 and less than 10000.

theta is an angle in radians and must in the range 0 to pi.

phi is an angle in radians and must be in the range 0 to 2pi.

atomIndexOrigin, atomIndexXAxis, and atomIndexYAxis are atom numbers for the segment. They range from 1 to structure.GetAtomCount() for the segment. An atom number of 0 is equivalent to the default, which bands to the heavy atom of the backbone (normally atom number 2).

For theta and phi, you can convert from degrees to radians using the [math.rad()] function. For example, math.rad(45) converts from 45 degrees into the equivalent in radians.

To create a band to empty space, you'll need spherical coordinates from a given segment.

- The X axis is defined as the line passing through segmentOrigin and segmentXAxis.
- The Y axis defined by segmentOrigin, segmentXAxis, and segmentYAxis. These three arguments define a plane that passes through these three segments. The Y axis is perpendicular to the X axis in this plane, passing through segmentOrigin. The positive values on the Y axis will occur on the same side of the X axis as segmentYAxis. The segment you specify is not necessarily perpendicular to the X axis.
- The Z axis is perpendicular to the X and Y axes, passing through segmentOrigin. The positive direction on the Z axis is determined the right-hand rule from X and Y axes.

The first three arguments are the segment numbers of segments in the protein. The segments segmentOrigin, segmentXAxis, and segmentYAxis must be different from one other.

Once the three axes are defined, theta, and phi define the angles from these axes in radians. Rho defines the length in the same units used to measure the distance between segments. You can use the math.rad() Lua function to convert degrees to radians.

The atom numbers are optional, but allow you to use individual atom numbers of the segment. The function structure.GetAtomCount() returns the number of atoms in a segment. The axes are from the physical locations of these atoms. An atom number omitted or zero maps to the backbone heavy atom.

A single amino acid in water normally starts with an ammonium ion (NH3+) and ends with a carbolic acid ion (COO-). When two amino acids bond, 2 H from one end and one O from the other are removed as water, leaving the two amino acids bonded (H3N-C-C(=O)-N-C-C(=O)O). This bonding can be repeated on either end to form a long chain. Foldit numbers the backbone heavy atoms (C,N,O) starting with the N, then the heavy atoms of the sidechain (which is attached to the first carbon) (C,N,O,S), and finally the hydrogens, starting with the hydrogens attached to the N and proceeding in the same order as before..In a bonded amino acid, the backbone has 4 atoms and the 5th is the first atom of the sidechain (except for glycine). In the last segment of the protein there is not a peptide bond. Instead, there is an extra oxygen.. So the last segment has a 5 atom long backbone and number 6 is the sidechain.

## Example Edit

The example below would create a band to empty space from segment 12, with rho of 20, a theta of 30, and a phi of 45. The angles would be relative to the coordinate system established from the segments numbered 12, 49, and 42 in the protein.

local segmentOrigin = 12 local segmentXAxis = 49 local segmentYAxis = 42 local rho = 20 local theta = math.rad(30) local phi = math.rad(45) band.Add(segmentOrigin, segmentXAxis, segmentYAxis, rho, theta, phi)

In practice, most often, segmentXAxis and segmentYAxis will be specified as the segments immediately adjacent to segmentOrigin. So here is possibly the most common usage, creating a band that is 20 units long perpendicular to the backbone at segment 2, and the plane defined by segments 2, 1, and 3.

band.Add(2,1,3,20,0,0)

To get a perfectly uniformly random direction, use the following snippet (simply using random() won't be perfectly even everywhere):

theta = math.acos(2*math.random()-1) phi = 2 * math.pi * math.random() rho = R * math.random()^(1/3) + 0.001 -- for a random point in sphere of radius R