Introduction: Python - Rotation Angle of an Alpha Helix
Python program that calculates the rotation angle of an alpha helix protein.
Also attached is a PDF that diagrams the formula being broken down into Python code. Code is below and attached.
print ("This program will calculate the rotation angle of an alpha helix.")
import math
# Formula for calculating the rotation angle of an alpha helix:
# RotationAngleAlphaHelix = arccos((1-(4 * (((cos((DihedralAngleOne + DihedralAngleTwo)/2)))**2)))/3)
###########################################
# 1 function: solve for the rotation angle
# math.cos(x in radians) - returns cosine of "x in radians"
# math.acos(x in radians) - returns arccosine of "x in radians"
# Function to solve for rotation angle
# Enter the Dihedral Angle #1 and Dihedral Angle #2
# RotationAngleAlphaHelix = arccos((1-(4 * (((cos((DihedralAngleOne + DihedralAngleTwo)/2)))**2)))/3)
def SolveForRotationAngleAlphaHelix():
print ("Solving for the rotation angle of an alpha helix.")
# math.cos(x in radians) - returns cosine of "x in radians"
# Enter the Dihedral Angle #1 and Dihedral Angle #2
DihedralAngleOne = float(input("Enter the 1st dihedral angle: ") )
DihedralAngleTwo = float(input("Enter the 2nd dihedral angle: ") )
AngleOnePlusAngleTwoOver2 = ((DihedralAngleOne + DihedralAngleTwo)/2)
# Now convert degrees to radians so that we can use the math.cos() function
# Use math.radians() to convert degrees to radians
TopInRadians = math.radians(AngleOnePlusAngleTwoOver2)
print(AngleOnePlusAngleTwoOver2, "degrees in radians is: ", TopInRadians)
# Now find cosine
CosineOfTop = math.cos(TopInRadians)
print("The cosine of ", AngleOnePlusAngleTwoOver2, "is: ", CosineOfTop)
# Square the cosine
CosineOfTopSquared = (CosineOfTop**2)
# Finish the top part of the formula
FourTimesCosineSquared = (4*CosineOfTopSquared)
OneMinusFourTimesCosineSquared = (1 - FourTimesCosineSquared)
# Divide by 3
DividedBy3 = (OneMinusFourTimesCosineSquared/3)
# Finally, compute acrcos and get result in radians
AcosInRadians = math.acos(DividedBy3)
# Convert radians to degrees
RotationAngle = math.degrees(AcosInRadians)
print("The rotation angle is: ", RotationAngle)
ContinueCalculations = "y"
# Check to see if the user wants to continue to calculate the rotation angle of an alpha helix
while (ContinueCalculations=="y"):
SolveForRotationAngleAlphaHelix()
ContinueCalculations = input("Would like to do another calculation for the rotation angle of an alpha helix? (y/n): ")
print("==================================")
print ("Thank you to www.fxsolver.com & Wikipedia for assistance with this formula.")
print ("Also thank you to the book: \"Introduction to Peptides and Proteins\", page 40 for additional information. ")
Supplies
Used the Geany text editor and IDLE.







