Source code for schrodinger.ui.sequencealignment.utils
[docs]def colorGradientBlueWhiteRed(value):
"""
Return an RGB color triple using blue - white - red gradient
for a given value. The value is clamped to a [-1..1] range.
:type value: float
:param value: numerical value
:rtype: (int int int)
:return: RGB color triple
"""
if value < 0.0:
if value < -1.0:
value = -1.0
r = int(255 * (value + 1.0))
g = int(255 * (value + 1.0))
b = 255
elif value > 0.0:
if value > 1.0:
value = 1.0
r = 255
g = int(255 * (1.0 - value))
b = int(255 * (1.0 - value))
else:
r = g = b = 255
return (r, g, b)
[docs]def colorGradientGreenRed(value):
"""
Return an RGB color triple using green - red gradient
for a given value. The value is clamped to a [-1..1] range.
:type value: float
:param value: numerical value
:rtype: (int int int)
:return: RGB color triple
"""
if value < 0.0:
if value < -1.0:
value = -1.0
r = int(255 * (value + 1.0))
b = int(255 * (value + 1.0))
g = 255
elif value > 0.0:
if value > 1.0:
value = 1.0
r = 255
b = int(255 * (1.0 - value))
g = int(255 * (1.0 - value))
else:
r = g = b = 255
return (r, g, b)
[docs]def matrixValue(matrix, first, second):
"""
Return a similarity matrix vaule for a specified pair of residues.
"""
if (first, second) in matrix:
return matrix[(first, second)]
if (second, first) in matrix:
return matrix[(second, first)]
return 0.0
[docs]def print_error(message):
print("ERROR: ", message, "\n")