Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions coloraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,38 @@


def coloraf(selection="all"):

"""
AUTHOR
Christian Balbin

DESCRIPTION
Colors Alphafold structures by pLDDT
Colors structures by pLDDT, automatically detecting if values are in [0,1] or [0,100] range
Handles multiple objects independently

USAGE
coloraf sele

PARAMETERS

sele (string)
The name of the selection/object to color by pLDDT. Default: all
"""

cmd.color("blue", f"({selection}) and b > 90")
cmd.color("cyan", f"({selection}) and b < 90 and b > 70")
cmd.color("yellow", f"({selection}) and b < 70 and b > 50")
cmd.color("orange", f"({selection}) and b < 50")
for obj in set(cmd.get_object_list(selection)):

stored.b = []
cmd.iterate(obj, "stored.b.append(b)")
max_bfactor = max(stored.b)
print(f"Object {obj}: Maximum B-factor = {max_bfactor:.3f}")

if max_bfactor <= 1.0:
cmd.color("blue", f"({obj}) and (b > 0.90 or b = 0.90)")
cmd.color("cyan", f"({obj}) and ((b < 0.90 and b > 0.70) or b = 0.70)")
cmd.color("yellow", f"({obj}) and ((b < 0.70 and b > 0.50) or b = 0.50)")
cmd.color("orange", f"({obj}) and b < 0.50")
else:
cmd.color("blue", f"({obj}) and (b > 90 or b = 90)")
cmd.color("cyan", f"({obj}) and ((b < 90 and b > 70) or b = 70)")
cmd.color("yellow", f"({obj}) and ((b < 70 and b > 50) or b = 50)")
cmd.color("orange", f"({obj}) and b < 50")


cmd.extend("coloraf", coloraf)
Expand Down