import numpy as np
from math import sin,cos,acos,pi,atan
import scipy as Sci
import scipy.linalg
from scipy.optimize import leastsq,fmin,fmin_bfgs
[docs]def DC_Wave(nres,tr):
""" Dipolar Coupling Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = tr[0]
rho = tr[1]
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
DCtensor = np.array([sin(delta*deg),
0.,
cos(delta*deg)])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
DC = []
for k in range(1,nres+1):
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
DC.append(abs((1./2.)*(10.735)*(3*np.dot(B, np.dot(C.conj().T,DCtensor))**2.-1.)))
return DC
[docs]def DC_ContinuousWave(nres,tr):
""" Dipolar Coupling Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = tr[0]
rho = tr[1]
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
DCtensor = np.array([sin(delta*deg),
0.,
cos(delta*deg)])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
DC = []
kar = []
for j in range(100,(nres+1)*100,1):
k=float(j)*0.01
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
kar.append(k)
DC.append(abs((1./2.)*(10.735)*(3*np.dot(B, np.dot(C.conj().T,DCtensor))**2.-1.)))
return kar,DC
[docs]def DC_WaveRho(nres,tr):
""" Dipolar Coupling Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = 90
rho = tr[1]
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
DCtensor = np.array([sin(delta*deg),
0.,
cos(delta*deg)])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
DC = []
for k in range(1,nres+1):
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
DC.append(abs((1./2.)*(10.735)*(3*np.dot(B, np.dot(C.conj().T,DCtensor))**2.-1.)))
return DC
[docs]def DC_WaveTau(nres,tr):
""" Dipolar Coupling Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = tr[0]
rho = 260
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
DCtensor = np.array([sin(delta*deg),
0.,
cos(delta*deg)])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
DC = []
for k in range(1,nres+1):
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
DC.append(abs((1./2.)*(10.735)*(3*np.dot(B, np.dot(C.conj().T,DCtensor))**2.-1.)))
return DC
def DCWaveFit(taurho,*args):
k0 = args
val = Fits.DC_Wave(len(k0),taurho)
return np.sqrt(sum([(val[i]-k0[i])*(val[i]-k0[i]) for i in range(2,len(k0))])/len(k0))
[docs]def CS_Wave(nres,tr):
""" Chemical Shift Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = tr[0]
rho = tr[1]
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
CSAtensor = np.array([[31, 0, 0],
[0, 54, 0],
[0, 0, 202]])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
CS = []
for k in range(1,nres+1):
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
CdB = np.dot( C , B )
CS.append(np.dot( CdB.conj().T, np.dot( CSAtensor , CdB ) ))
return CS
[docs]def CS_WaveTau(nres,tr):
""" Chemical Shift Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = tr[0]
rho = 260
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
CSAtensor = np.array([[31, 0, 0],
[0, 54, 0],
[0, 0, 202]])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
CS = []
for k in range(1,nres+1):
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
CdB = np.dot( C , B )
CS.append(np.dot( CdB.conj().T, np.dot( CSAtensor , CdB ) ))
return CS
[docs]def CS_WaveRho(nres,tr):
""" Chemical Shift Wave Equation
k = residue number
tau = tilt of peptide
rho = polarity of peptide
"""
tau = 90
rho = tr[1]
deg = pi/180. # Convert degrees into radians
delta = 17. # Assume delta = 17. degrees
omega = 100 # Assume 100 degrees per residue ( 3.6 residues per turn )
shift = -1. # Start with residue 1
CSAtensor = np.array([[31, 0, 0],
[0, 54, 0],
[0, 0, 202]])
C = np.array([[ 0.690, 0.719, -0.090],
[ 0.693, -0.691, -0.206],
[-0.211, 0.079, -0.975]])
CS = []
for k in range(1,nres+1):
B = np.array([sin(tau*deg)*cos(rho*deg-(k+shift)*omega*deg),
sin(tau*deg)*sin(rho*deg-(k+shift)*omega*deg),
cos(tau*deg)])
CdB = np.dot( C , B )
CS.append(np.dot( CdB.conj().T, np.dot( CSAtensor , CdB ) ))
return CS
def CSWaveFit(taurho,*args):
k0 = args
val = Fits.CS_Wave(len(k0),taurho)
return np.sqrt(sum([(val[i]-k0[i])*(val[i]-k0[i]) for i in range(2,len(k0))])/len(k0))