Protool/utilities.py
def placeOxygen(CA, C, N):
    """
        Place an oxygen according to the planar atoms CA, C, and N using
        a trans-peptide geometry.  Allows for a more accurate method of
        adding oxygen atoms.

        Parameters
            CA:        The coordinates of the CA atom (list)
            C:         The coordinates of the C atom (list)
            N:         The coordinates of the peptide bonded N atom from the
                       next residue (list)
        Returns
            location:  The location of the residue (list)
    """

    # Step 1: Find the vector normal to the C-CA-N plane in order to get
    #         the equation for any point in the plane

    vec1 = subtract(CA,C)
    vec2 = subtract(N,C)
    planeeq = cross(vec1, vec2)
    sum = planeeq[0]*C[0] + planeeq[1]*C[1] + planeeq[2]*C[2]

    # Step 2: Get two more equations using the known C-O distance (1.24 A)
    #         and CA-C-O and N-C-O bond angles (120.5 and 123.5 degrees,
    #         respectively) using the identity
    #
    #         A . B = |A||B| cos(angle)
    
    num1 = math.sqrt(pow(vec1[0],2) + pow(vec1[1],2) + pow(vec1[2],2)) 
    num2 = math.sqrt(pow(vec2[0],2) + pow(vec2[1],2) + pow(vec2[2],2))
    
    # For vector 1
    
    val1 = 0
    angle = 120.5*math.pi/180.0
    val1 = num1*1.24*math.cos(angle)
    for j in range(3):
        val1 += C[j]*vec1[j]
        
    # For vector 2

    val2 = 0
    angle = 123.5*math.pi/180.0
    val2 = num2*1.24*math.cos(angle)
    for j in range(3):
        val2 += C[j]*vec2[j]
        
    # Step 3: We now use Gaussian Elimination to solve the following matrix
    #
    #         [ planeq[0] planeeq[1] planeeq[2] ]  =  [sum]
    #         [  vec1[0]    vec1[1]  vec1[2]    ]  =  [val1]
    #         [  vec2[0]    vec2[1]  vec2[2]    ]  =  [val2]
    

    fac1 = -1 * planeeq[0]/vec1[0]
    new1 = [0, fac1*vec1[1]+planeeq[1], fac1*vec1[2]+planeeq[2]]
    val1 = fac1*val1+sum
    
    fac2 = -1 * planeeq[0]/vec2[0]
    new2 = [0, fac2*vec2[1]+planeeq[1], fac2*vec2[2]+planeeq[2]]
    val2 = fac2*val2+sum
    
    fac3 = -1 * new1[1]/new2[1]
    newest = [0,0,fac3*new2[2]+new1[2]]
    val2 = fac3*val2+val1

    # Step 4: Backfill in to find the results
    
    z = val2/newest[2]
    y = (val1 - z*new1[2])/new1[1]
    x = (sum - z*planeeq[2] - y*planeeq[1])/planeeq[0]

    location = [x,y,z]
    return location

        Place an oxygen according to the planar atoms CA, C, and N using
        a trans-peptide geometry.  Allows for a more accurate method of
        adding oxygen atoms.

        Parameters
            CA:        The coordinates of the CA atom (list)
            C:         The coordinates of the C atom (list)
            N:         The coordinates of the peptide bonded N atom from the
                       next residue (list)
        Returns
            location:  The location of the residue (list)
    
Place an oxygen according to the planar atoms CA, C, and N using
a trans-peptide geometry.  Allows for a more accurate method of
adding oxygen atoms.

Parameters
CA:        The coordinates of the CA atom (list)
C:         The coordinates of the C atom (list)
N:         The coordinates of the peptide bonded N atom from the
next residue (list)
Returns
location:  The location of the residue (list)
Place an oxygen according to the planar atoms CA C and N using a trans - peptide geometry . Allows for a more accurate method of adding oxygen atoms . Parameters CA : The coordinates of the CA atom ( list ) C : The coordinates of the C atom ( list ) N : The coordinates of the peptide bonded N atom from the next residue ( list ) Returns location : The location of the residue ( list )
def placeOxygen(CA, C, N):
    vec1 = subtract(CA,C)
    vec2 = subtract(N,C)
    planeeq = cross(vec1, vec2)
    sum = planeeq[0]*C[0] + planeeq[1]*C[1] + planeeq[2]*C[2]
             A . B = |A||B| cos(angle)
    num1 = math.sqrt(pow(vec1[0],2) + pow(vec1[1],2) + pow(vec1[2],2)) 
    num2 = math.sqrt(pow(vec2[0],2) + pow(vec2[1],2) + pow(vec2[2],2))
     For vector 1
    val1 = 0
    angle = 120.5*math.pi/180.0
    val1 = num1*1.24*math.cos(angle)
    for j in range(3):
        val1 += C[j]*vec1[j]
     For vector 2
    val2 = 0
    angle = 123.5*math.pi/180.0
    val2 = num2*1.24*math.cos(angle)
    for j in range(3):
        val2 += C[j]*vec2[j]
     Step 3: We now use Gaussian Elimination to solve the following matrix
             [ planeq[0] planeeq[1] planeeq[2] ]  =  [sum]
             [  vec1[0]    vec1[1]  vec1[2]    ]  =  [val1]
             [  vec2[0]    vec2[1]  vec2[2]    ]  =  [val2]
    fac1 = -1 * planeeq[0]/vec1[0]
    new1 = [0, fac1*vec1[1]+planeeq[1], fac1*vec1[2]+planeeq[2]]
    val1 = fac1*val1+sum
    fac2 = -1 * planeeq[0]/vec2[0]
    new2 = [0, fac2*vec2[1]+planeeq[1], fac2*vec2[2]+planeeq[2]]
    val2 = fac2*val2+sum
    fac3 = -1 * new1[1]/new2[1]
    newest = [0,0,fac3*new2[2]+new1[2]]
    val2 = fac3*val2+val1
     Step 4: Backfill in to find the results
    z = val2/newest[2]
    y = (val1 - z*new1[2])/new1[1]
    x = (sum - z*planeeq[2] - y*planeeq[1])/planeeq[0]
    location = [x,y,z]
    return location
def placeOxygen ( CA , C , N ) : vec1 = subtract ( CA , C ) vec2 = subtract ( N , C ) planeeq = cross ( vec1 , vec2 ) sum = planeeq [ 0 ] * C [ 0 ] + planeeq [ 1 ] * C [ 1 ] + planeeq [ 2 ] * C [ 2 ] num1 = math . sqrt ( pow ( vec1 [ 0 ] , 2 ) + pow ( vec1 [ 1 ] , 2 ) + pow ( vec1 [ 2 ] , 2 ) ) num2 = math . sqrt ( pow ( vec2 [ 0 ] , 2 ) + pow ( vec2 [ 1 ] , 2 ) + pow ( vec2 [ 2 ] , 2 ) ) val1 = 0 angle = 120.5 * math . pi / 180.0 val1 = num1 * 1.24 * math . cos ( angle ) for j in range ( 3 ) : val1 += C [ j ] * vec1 [ j ] val2 = 0 angle = 123.5 * math . pi / 180.0 val2 = num2 * 1.24 * math . cos ( angle ) for j in range ( 3 ) : val2 += C [ j ] * vec2 [ j ] fac1 = - 1 * planeeq [ 0 ] / vec1 [ 0 ] new1 = [ 0 , fac1 * vec1 [ 1 ] + planeeq [ 1 ] , fac1 * vec1 [ 2 ] + planeeq [ 2 ] ] val1 = fac1 * val1 + sum fac2 = - 1 * planeeq [ 0 ] / vec2 [ 0 ] new2 = [ 0 , fac2 * vec2 [ 1 ] + planeeq [ 1 ] , fac2 * vec2 [ 2 ] + planeeq [ 2 ] ] val2 = fac2 * val2 + sum fac3 = - 1 * new1 [ 1 ] / new2 [ 1 ] newest = [ 0 , 0 , fac3 * new2 [ 2 ] + new1 [ 2 ] ] val2 = fac3 * val2 + val1 z = val2 / newest [ 2 ] y = ( val1 - z * new1 [ 2 ] ) / new1 [ 1 ] x = ( sum - z * planeeq [ 2 ] - y * planeeq [ 1 ] ) / planeeq [ 0 ] location = [ x , y , z ] return location
Place an oxygen according to the planar atoms CA, C, and N using
a trans-peptide geometry.
Place an oxygen according to the planar atoms CA C and N using a trans - peptide geometry .
"""
        Place an oxygen according to the planar atoms CA, C, and N using
        a trans-peptide geometry.  Allows for a more accurate method of
        adding oxygen atoms.

        Parameters
            CA:        The coordinates of the CA atom (list)
            C:         The coordinates of the C atom (list)
            N:         The coordinates of the peptide bonded N atom from the
                       next residue (list)
        Returns
            location:  The location of the residue (list)
    """ # Step 1: Find the vector normal to the C-CA-N plane in order to get #         the equation for any point in the plane # Step 2: Get two more equations using the known C-O distance (1.24 A) #         and CA-C-O and N-C-O bond angles (120.5 and 123.5 degrees, #         respectively) using the identity # #         A . B = |A||B| cos(angle) # For vector 1 # For vector 2 # Step 3: We now use Gaussian Elimination to solve the following matrix # #         [ planeq[0] planeeq[1] planeeq[2] ]  =  [sum] #         [  vec1[0]    vec1[1]  vec1[2]    ]  =  [val1] #         [  vec2[0]    vec2[1]  vec2[2]    ]  =  [val2] # Step 4: Backfill in to find the results
CA
C
N