sidechain module

Date: 20180201

Module author: Andrew Trzynka

Authors:

Michael S. Chapman <chapmanms@missouri.edu>

Oregon Health & Science University & University of Missouri

Version:

1, Nov 26, 2024

Changed in version 0.3.7: 02/01/18 Initial development

Changed in version 1.0.0: 11/17/20 Python 2.7 –> 3.6 (untested)

Usage:

import sidechain

Todo

Needs to be incorporated into refinement capabilities.

class sidechain.Side_chains

Bases: object

Code to traverse a selection of residues and rank the rotamers by best match to library rotamer Chi angles and best fit to density.

The rotamer “match” value indicates how well each library rotamer matches the experimental residue chi angles. The “Local cc” value is the fit to electron density map for only the local region of the experimental residue.

The residue selection is provided by the user through command line (CMD2) execution of RSRref.

For each residue, a list of library rotamers is created containing the residue name, the library rotamer type, the % probability of natural occurance of the library rotamer, the experimental residue chi angles, the library rotamer chi angles, a ‘match’ value of experimental to library chi angles, the ‘local cc’ value for fit to electron density for residue if the residue took on the library rotamer chi angles, and a symmetric flip test (“Flip_Sym” or “Flip_P-Sym”) to check if symmetric or pseudo symmetric flipping improves the match value, and if so, indicate as such.

For each residue in the selection, the chi angles are compared to the library rotamer chi angles. The match (score) value is based on the combination of two values and is determined as follows:

# Starting with the root chi angle for each residue and working outward, compare the

value against the library rotamer chi angle. If the resulting chi angle difference for each chi angle is less than a window type band (in this case: +/- 60 degrees) then increment an integer match value to count the number of chi angles that match within the window. Stop incrementing the integer match value at first instance of a chi angle difference not fitting within the window. This will result in an integer match value of the library rotamer to the experimental residue ranging from 0 to 4 with the higher values indicating a better match than lower values.

# For each time the chi angle (as determined previously) within the window band,

calculate and accumulate the floating point chi angle difference. When the chi angle is no longer is within the window, include the floating point match value for only the next order chi angle. This accumulated floating point value is then averaged by the number of chi angles and scaled to a range of (0 < average accumulated chi angle < 1.0) and subtract from 1 to achieve a value such that a small value indicates poor match and a large value indicates good match.

# Finally add the interger match value to the floating point value to produce the

final chi score value (ranging from 0 to 4.999) for each rotamer in the rotamer library for the selected the experimental residue data.

# Check if symmetric and psudo-symmetric side chain flipping and improves match value and

include a flag in the residue rotamer list for each rotamer if flipping improves match value.

# Evaluate library rotamer fits to local electron density for each residue in the selection

and include the Local cc (fit to electron density) for each rotamer in residue rotamer list.

@note: None. @param source: defines which of the supported tables (above) is used. @type source: string (exact match required)

rota_match(structure, map_calc, selection=None, flip='FlipSym', rotamer_probablity=0.0, f2d=True, Standardize=False, verbosity=1)

Compare chi angles in structure to a rotamer library.

Instantiate a rotamer_chi library class to obtain Richardson Rotamer library chi angles. Instantiate a rotamer class and get some chi angles. Check each chi angle against the library and determine chi angle difference. Resolve the chi angle difference to the range (-180 deg < chi angle difference < +180 deg). Provide a final “chi-score” value for each rotamer in richardson rotamer library based on the combination of two values:

# Starting with the root chi angle for each rotamer, if the chi angle difference for each

chi angle is less than a window band then increment an integer window match to count the number of chi angles that match the window range. Stop incrementing integer window fit at first instrance of chi angle not fitting window. This will provide a match value of the library rotamer to the experimental rotamer ranging from 0 to 4 with higher numbers indicating better match.

# If provided in argument list, apply symmetric chi angle flipping or psudosymmetric chi

angle flipping (add or subrtract 180 degrees) to the experimental residue chi angles to check if flipping results in closer agreement with library rotamer chi angles. If flipping improves match to library rotamers then flip symmetric or psudosymmetric chi angles and flag the rotamer with the ‘*’ indicator in the matched residue dictionary.

Error

Might be bug if side chain flipping and f2d are both active: Is the f2d applied the the flipped or the unflipped configuration? Need to check this somehow.

# If provided in argument list, use ‘rotamer_probability’ (float value) to only select

library rotamers with % probability values greater than or equal to this value.

# For each successful “chi diff” of a chi angle to the window band, also increment a

floating point chi-score value based on the actual chi angle difference (in degrees). The floating point chi-match value is determined by first scaling the chi angle difference to a range of (0 < chi angle difference < 1.0) and then subtracting from 1 to achieve a value that relates small values to poor chi-fit and large values to good “chi-fit”. Additionally, also include the floating point match for the next order chi angle following the last successful integer window fit.

# Determine the average of the floating point match values for which floating point match

values were calculated.

# Finally add the interger window match value to the floating point match value to produce

thefinal rotamer match value (0 to 4.999) for each rotamer in the rotamer library to the experimental rotamer data.

# For each matched rotamer, adjust the residue experimental chi angles to the matched

rotamer chi angles and determine the local fit to density: “Local cc”. Include the “Local cc” value in the residue rotamer list and reset the residue experimental chi angles to their initial values.

# For each residue, sort the residue rotamer list rotamers by “Local cc” unless disabled by

command line argument. In event that “fit to density” is disabled, sort residue rotamer list rotamers by “chi-match” value, with rotamer of greatest “chi-match” value first in list.

rota_print(MatchedRotamerList, header=0, verbosity=1)

Output matching rotamers (in MatchedRotamerList) in human readable format.

Note: I’m using a funky <sys.stdout.softspace=0> command to inhibit printing a space before a comma. (There must be a better way to do this space inhibiting…) If verbosity = 0: Print progress indicator dots. If verbosity = 1 (default): For eash residue print only best match library rotamer, “X-score”, Fit to density (cc) and optional flipflag. If verbosity >= 2: For each residue print all library rotamers “X-score”, Fit to density (cc) and optional flipflag for the specific residue label.