Evaluate the Loop Polynomial CoeÆients
William J. Wedemeyer, Harold A. Sheraga
This seond supplement provides a omputer program poly oeffs.
whih omputes the seventeen loop polynomial oeÆients R
0 R
16 ,
or-responding to equation (7) in the text. This program alls routines in
poly funs. and poly funs.h, whih are also given in this supplement.
The programsarewritteninANSI-ompliantC, andshouldompilewithout
diÆulty. A typial omputation of the loop oeÆients takes less than a
poly oes. 3
poly funs.h 18
/* ************************** **** **** **** **** *** **** ***
poly_oeffs.
This program omputes the oeffiients of the
tripeptide loop losure polynomial
The ECEPP peptide bond geometry is assumed, whih
fixes the angles gamma1, alpha2, gamma2 and gamma3.
The bond angles at the CA atoms are assumed to be
exatly 109.5 degrees, whih fixes the angles delta1,
delta2 and delta3. The four angles alpha1, beta1,
alpha3 and omega0 are given on the ommand line.
Lastly, the angles beta2 and beta3 are determined
from beta1. Sine they pertain to the same triangle,
the sum of beta1, beta2 and the supplement of beta3
must add up to PI radians. Moreover, the supplement
of beta3 must equal beta1 beause the triangle is
isoeles.
Copyright, 1998, William J. Wedemeyer
************************** *** **** **** **** **** *** **** *** */
#inlude <stdio.h>
#inlude <stdlib.h>
#inlude <math.h>
#inlude "poly_funs.h"
/* ****************** */
/* Maros and Defines */
#define MAX_DEGREE 16
#define MAX_DEGREE_PLUS_ONE 17
/* **************** */
/* The Main Program */
/* **************** */
main(int arg, har *argv[℄)
{
int i, j, k;
int deg_index;
double temp1, temp2, temp3;
double zeta1, zeta3;
double w1, z1, z3, z3_2;
double omega0, omega1, omega3;
double alpha1, alpha2, alpha3;
double beta1, beta2, beta3;
double gamma1, gamma2, gamma3;
double delta1, delta2, delta3;
double alpha1_deg, beta1_deg;
double alpha3_deg, omega0_deg;
double 0, 1, 2, 3, 4;
double d0, d1, d2, d3, d4;
double l0, l1, l2, l3, l4;
double m0, m1, m2, m3, m4;
double P10, P11, P12;
double P20, P21, P22;
double Q00, Q20, Q40;
double Q11, Q31;
double Q02, Q22, Q42;
double Q13, Q33;
double Q04, Q24, Q44;
double B0, B1, B2;
double K0, K1, K2, K3;
double A0, A1, A2, A3, A4;
double a0[MAX_DEGREE_PLUS_ONE℄;
double a1[MAX_DEGREE_PLUS_ONE℄;
double a2[MAX_DEGREE_PLUS_ONE℄;
double a3[MAX_DEGREE_PLUS_ONE℄;
double a4[MAX_DEGREE_PLUS_ONE℄;
double b0[MAX_DEGREE_PLUS_ONE℄;
double b1[MAX_DEGREE_PLUS_ONE℄;
double b2[MAX_DEGREE_PLUS_ONE℄;
double b0b0[MAX_DEGREE_PLUS_ONE ℄;
double b1b1[MAX_DEGREE_PLUS_ONE ℄;
double b2b2[MAX_DEGREE_PLUS_ONE ℄;
double b0b1[MAX_DEGREE_PLUS_ONE ℄;
double b1b2[MAX_DEGREE_PLUS_ONE ℄;
double b2b0[MAX_DEGREE_PLUS_ONE ℄;
double loop_poly[MAX_DEGREE_PLU S_ON E℄;
double temp1_poly[MAX_DEGREE_PL US_O NE℄;
double temp2_poly[MAX_DEGREE_PL US_O NE℄;
printf("\n");
/* ********************** */
/* Command-line arguments */
/* ********************** */
if (arg < 5)
{
printf("Proper format:\n\n");
printf("%s <alpha1> <beta1> <alpha3> <omega0>\n\n",
argv[0℄);
exit(1);
}
alpha1_deg = atof(argv[1℄);
beta1_deg = atof(argv[2℄);
alpha3_deg = atof(argv[3℄);
omega0_deg = atof(argv[4℄);
printf("Input parameters:\n");
printf("alpha1 = %-5.1lf deg beta1 = %-5.1lf deg\n",
alpha1_deg, beta1_deg);
printf("alpha3 = %-5.1lf deg omega0 = %-5.1lf deg\n\n",
alpha3_deg, omega0_deg);
/* ************************ **** *** */
/* Assign the geometri parameters */
/* ************************ **** *** */
alpha1 = alpha1_deg * (PI/180.0);
beta1 = beta1_deg * (PI/180.0);
alpha3 = alpha3_deg * (PI/180.0);
delta1 = (70.5/180.0)*PI;
alpha2 = (14.9/180.0)*PI;
beta2 = PI - 2.0*beta1;
gamma2 = (20.9/180.0)*PI;
delta2 = (109.5/180.0)*PI;
beta3 = PI - beta1;
gamma3 = (14.9/180.0)*PI;
delta3 = (70.5/180.0)*PI;
printf("Parameters derived from fixed virtual bond lengths:\n");
printf("Beta2 = %-5.1lf deg Beta3 = %-5.1lf deg\n\n",
180.0 - 2.0*(beta1_deg), 180.0 - beta1_deg);
printf("Parameters derived from ECEPP bond geometry:\n");
printf("Gamma1 = Gamma2 = 20.9 deg\n");
printf("Alpha2 = Gamma3 = 14.9 deg\n");
printf("Delta1 = Delta3 = 70.5 deg Delta2 = 109.5 deg\n\n");
/* ************************ **** **** */
/* P equation: Get the oeffiients */
/* ************************ **** **** */
n0 = os(alpha3) * os(beta3) * os(gamma3) - os(delta3);
n1 = sin(alpha3) * sin(beta3) * os(gamma3);
n2 = os(alpha3) * sin(beta3) * sin(gamma3);
n3 = -sin(alpha3) * os(beta3) * sin(gamma3);
n4 = sin(alpha3) * sin(gamma3);
P21 = 2.0 * n4 * sin(omega0);
P22 = n0 - n1 * os(omega0) - n2 + n3 * os(omega0);
/* ************************ **** **** */
/* D equation: Get the oeffiients */
/* ************************ **** **** */
0 = os(alpha1) * os(beta1) * os(gamma1) - os(delta1);
1 = sin(alpha1) * sin(beta1) * os(gamma1);
2 = os(alpha1) * sin(beta1) * sin(gamma1);
3 = -sin(alpha1) * os(beta1) * sin(gamma1);
4 = sin(alpha1) * sin(gamma1);
d0 = 0 + 1 + 2 + 3;
d1 = 0 - 1 + 2 - 3;
d2 = 0 + 1 - 2 - 3;
d3 = 0 - 1 - 2 + 3;
d4 = 4.0 * 4;
/* ************************ **** **** */
/* M equation: Get the oeffiients */
/* ************************ **** **** */
l0 = os(alpha2) * os(beta2) * os(gamma2) - os(delta2);
l1 = sin(alpha2) * sin(beta2) * os(gamma2);
l2 = os(alpha2) * sin(beta2) * sin(gamma2);
l3 = -sin(alpha2) * os(beta2) * sin(gamma2);
l4 = sin(alpha2) * sin(gamma2);
m0 = l0 - l1 + l2 - l3;
m1 = l0 + l1 + l2 + l3;
m2 = l0 - l1 - l2 + l3;
m3 = l0 + l1 - l2 - l3;
/* Q equation: Get the oeffiients */
/* ************************ **** **** */
temp1 = d0*m1 - d2*m0;
Q00 = temp1 * temp1;
temp2 = d1*m1 - d3*m0;
Q40 = temp2 * temp2;
temp1 = d1 * m1 - d3 * m0;
temp2 = d0 * m1 - d2 * m0;
Q20 = 2.0 * temp1 * temp2 + d4*d4*m0*m1;
temp1 = d0 * m1 + d2 * m0;
Q11 = - d4 * m4 * temp1;
temp2 = d1 * m1 + d3 * m0;
Q31 = - d4 * m4 * temp2;
temp1 = m4 * m4 - 2.0 * m0 * m3 - 2.0 * m1 * m2;
Q02 = 2.0 * d0 * d0 * m1 * m3 +
2.0 * d2 * d2 * m0 * m2 + d0 * d2 * temp1;
Q42 = 2.0 * d1 * d1 * m1 * m3 +
2.0 * d3 * d3 * m0 * m2 + d1 * d3 * temp1;
Q22 = 4.0 * d0 * d1 * m1 * m3 +
4.0 * d2 * d3 * m0 * m2 +
d4 * d4 * (m0 * m3 + m1 * m2) +
(d0 * d3 + d1 * d2) * temp1;
temp1 = d0 * m3 + d2 * m2;
Q13 = - d4 * m4 * temp1;
temp2 = d1 * m3 + d3 * m2;
Q04 = temp1 * temp1;
temp2 = d1*m3 - d3*m2;
Q44 = temp2 * temp2;
temp1 = d1 * m3 - d3 * m2;
temp2 = d0 * m3 - d2 * m2;
Q24 = 2.0 * temp1 * temp2 + d4*d4*m2*m3;
/* ************************ **** **** **** **** *** * */
/* Get the oeffiients for the loop polynomial */
/* ************************ **** **** **** **** *** * */
for (deg_index=0; deg_index<=MAX_DEGREE; deg_index++)
{
loop_poly[deg_index℄ = 0.0;
b0[deg_index℄ = 0.0;
b1[deg_index℄ = 0.0;
b2[deg_index℄ = 0.0;
a0[deg_index℄ = 0.0;
a1[deg_index℄ = 0.0;
a2[deg_index℄ = 0.0;
a3[deg_index℄ = 0.0;
a4[deg_index℄ = 0.0;
}
b0[0℄ = P00;
b0[1℄ = P10;
b0[2℄ = P20;
b1[0℄ = P01;
b1[1℄ = P11;
b2[1℄ = P12;
b2[2℄ = P22;
a0[0℄ = Q00;
a0[2℄ = Q20;
a0[4℄ = Q40;
a1[1℄ = Q11;
a1[3℄ = Q31;
a2[0℄ = Q02;
a2[2℄ = Q22;
a2[4℄ = Q42;
a3[1℄ = Q13;
a3[3℄ = Q33;
a4[0℄ = Q04;
a4[2℄ = Q24;
a4[4℄ = Q44;
poly_multiply(b0,2,b0,2, b0b 0);
poly_multiply(b1,2,b1,2, b1b 1);
poly_multiply(b2,2,b2,2, b2b 2);
poly_multiply(b0,2,b1,2, b0b 1);
poly_multiply(b1,2,b2,2, b1b 2);
poly_multiply(b2,2,b0,2, b2b 0);
/* ************** */
/* A0^2 B2^4 term */
/* ************** */
poly_multiply(a0,4,a0,4, temp1_poly);
poly_multiply(b2b2,4,b2b 2,4 ,tem p2_p oly) ;
/* A0 A4 B1^4 */
/* ********** */
poly_multiply(a0,4,a4,4, temp1_poly);
poly_multiply(b1b1,4,b1b 1,4 ,tem p2_p oly) ;
poly_multiplyadd(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* **************** */
/* -2 A0 A2 B0 B2^3 */
/* **************** */
poly_multiply(a0,4,a2,4, temp1_poly);
poly_multiply(b2b0,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplysalesub(te mp1 _pol y,8,
temp2_poly,8,
2.0, loop_poly);
/* ************** */
/* -A0 A1 B1 B2^3 */
/* ************** */
poly_multiply(a0,4,a1,4, temp1_poly);
poly_multiply(b1b2,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplysub(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* *************** */
/* A0 A2 B1^2 B2^2 */
/* *************** */
poly_multiply(a0,4,a2,4, temp1_poly);
poly_multiply(b1b1,4,b2b 2,4 ,tem p2_p oly) ;
/* 3 A0 A3 B0 B1 B2^2 */
/* ****************** */
poly_multiply(a0,4,a3,4, temp1_poly);
poly_multiply(b0b1,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplysaleadd(te mp1 _pol y,8,
temp2_poly,8,
3.0, loop_poly);
/* ***************** */
/* 2 A0 A4 B0^2 B2^2 */
/* ***************** */
poly_multiply(a0,4,a4,4, temp1_poly);
poly_multiply(b0b0,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplysaleadd(te mp1 _pol y,8,
temp2_poly,8,
2.0, loop_poly);
/* ************** */
/* -A0 A3 B1^3 B2 */
/* ************** */
poly_multiply(a0,4,a3,4, temp1_poly);
poly_multiply(b1b1,4,b1b 2,4 ,tem p2_p oly) ;
poly_multiplysub(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* ******************* */
/* -4 A0 A4 B0 B1^2 B2 */
/* ******************* */
poly_multiplysalesub(te mp1 _pol y,8,
temp2_poly,8,
4.0, loop_poly);
/* ************ */
/* A1^2 B0 B2^3 */
/* ************ */
poly_multiply(a1,4,a1,4, temp1_poly);
poly_multiply(b2b0,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplyadd(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* ***************** */
/* -A1 A2 B0 B1 B2^2 */
/* ***************** */
poly_multiply(a1,4,a2,4, temp1_poly);
poly_multiply(b0b1,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplysub(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* ************** */
/* -A1 A4 B0 B1^3 */
/* ************** */
poly_multiply(a1,4,a4,4, temp1_poly);
poly_multiply(b0b1,4,b1b 1,4 ,tem p2_p oly) ;
poly_multiplysub(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* **************** */
/* A1 A3 B0 B1^2 B2 */
/* **************** */
poly_multiply(a1,4,a3,4, temp1_poly);
/* ****************** */
/* 3 A1 A4 B0^2 B1 B2 */
/* ****************** */
poly_multiply(a1,4,a4,4, temp1_poly);
poly_multiply(b0b0,4,b1b 2,4 ,tem p2_p oly) ;
poly_multiplysaleadd(te mp1 _pol y,8,
temp2_poly,8,
3.0, loop_poly);
/* ****************** */
/* -2 A1 A3 B0^2 B2^2 */
/* ****************** */
poly_multiply(a1,4,a3,4, temp1_poly);
poly_multiply(b0b0,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplysalesub(te mp1 _pol y,8,
temp2_poly,8,
2.0, loop_poly);
/* ************** */
/* A2^2 B0^2 B2^2 */
/* ************** */
poly_multiply(a2,4,a2,4, temp1_poly);
poly_multiply(b0b0,4,b2b 2,4 ,tem p2_p oly) ;
poly_multiplyadd(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* *************** */
/* A2 A4 B0^2 B1^2 */
/* *************** */
poly_multiplyadd(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* ***************** */
/* -A2 A3 B0^2 B1 B2 */
/* ***************** */
poly_multiply(a2,4,a3,4, temp1_poly);
poly_multiply(b0b0,4,b1b 2,4 ,tem p2_p oly) ;
poly_multiplysub(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* **************** */
/* -2 A2 A4 B0^3 B2 */
/* **************** */
poly_multiply(a2,4,a4,4, temp1_poly);
poly_multiply(b0b0,4,b2b 0,4 ,tem p2_p oly) ;
poly_multiplysalesub(te mp1 _pol y,8,
temp2_poly,8,
2.0, loop_poly);
/* ************** */
/* -A3 A4 B0^3 B1 */
/* ************** */
poly_multiply(a3,4,a4,4, temp1_poly);
poly_multiply(b0b0,4,b0b 1,4 ,tem p2_p oly) ;
poly_multiplysub(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* ************ */
/* A3^2 B0^3 B2 */
/* ************ */
poly_multiply(a3,4,a3,4, temp1_poly);
/* ********* */
/* A4^2 B0^4 */
/* ********* */
poly_multiply(a4,4,a4,4, temp1_poly);
poly_multiply(b0b0,4,b0b 0,4 ,tem p2_p oly) ;
poly_multiplyadd(temp1_p oly ,8,t emp2 _pol y,8, loo p_po ly);
/* ************************ * */
/* Print the Loop Polynomial */
/* ************************ * */
poly_print("Loop losure polynomial = \n\n", loop_poly, MAX_DEGREE);
/* ************************* **** **** **** **** *** **** **** **** *** *
poly_funs.h
This file delares the funtions whih at on polynomials
(see the file poly_funs. for their definitions).
poly_eval: evaluates a polynomial numerially
poly_multiply: multiplies two polynomials and
returns their produt
poly_multiplyadd: multiplies two polynomials and
adds their produt to a third polynomial
poly_multiplysub: multiplies two polynomials and subtrats
their produt from a third polynomial
poly_multiplysaleadd: multiplies two polynomials, sales
their produt and adds it to
a third polynomial
poly_multiplysalesub: multiplies two polynomials, sales
their produt and subtrats it from
a third polynomial
poly_print: prints out a polynomial, with a label-string
Copyright, 1998, William J. Wedemeyer
************************** *** **** **** **** **** *** **** **** **** *** * */
double *poly2, int degree2,
double *poly_produt);
void poly_multiplyadd(double *poly1, int degree1,
double *poly2, int degree2,
double *poly_output);
void poly_multiplysub(double *poly1, int degree1,
double *poly2, int degree2,
double *poly_output);
/* ************************* **** **** **** **** *** **** **** **** *** *
poly_funs.
This file defines funtions whih at on polynomials:
poly_eval: evaluates a polynomial numerially
poly_multiply: multiplies two polynomials and
returns their produt
poly_multiplyadd: multiplies two polynomials and
adds their produt to a third polynomial
poly_multiplysub: multiplies two polynomials and subtrats
their produt from a third polynomial
poly_multiplysaleadd: multiplies two polynomials, sales
their produt and adds it to
a third polynomial
poly_multiplysalesub: multiplies two polynomials, sales
their produt and subtrats it from
a third polynomial
poly_print: prints out a polynomial, with a label-string
Copyright, 1998, William J. Wedemeyer
************************** *** **** **** **** **** *** **** **** **** *** * */
#inlude <stdio.h>
#inlude <math.h>
/* Evaluate a polynomial */
/* ********************* */
double poly_eval(double *poly, int degree, double arg)
{
int deg_index;
double fator;
double output;
fator = 1.0;
output = poly[0℄;
for (deg_index=1; deg_index<=degree; deg_index++)
{
fator *= arg;
output += poly[deg_index℄ * fator;
}
return output;
} /* loses poly_eval() */
/* ************************* */
/* Polynomial Multipliation */
/* ************************* */
void poly_multiply(double *poly1, int degree1,
double *poly2, int degree2,
double *poly_produt)
{
int deg_index;
int deg1_index;
/* Initialization: Zero out the produt polynomial */
for (deg_index=0; deg_index<=degree1+degree 2; deg_index++)
{
poly_produt[deg_index℄ = 0.0;
} /* loses loop over produt polynomial */
/* Now multiply the polynomials */
for (deg1_index=0; deg1_index<=degree1; deg1_index++)
{
prefator = poly1[deg1_index℄;
/* Inner loop over poly2 terms */
for (deg2_index=0; deg2_index<=degree2; deg2_index++)
{
poly_produt[deg1_index +deg 2_in dex℄ +=
prefator*poly2[deg2_index ℄;
} /* loses inner loop over poly2 terms */
} /* loses outer loop over poly1 terms */
return;
} /* loses poly_multiply() */
/* ************************** **** **** **** ** */
/* Polynomial Multipliation, then Addition */
double *poly2, int degree2,
double *poly_output)
{
int deg_index;
int deg1_index;
int deg2_index;
double prefator;
/* Multiply the polynomials and add to poly_output */
for (deg1_index=0; deg1_index<=degree1; deg1_index++)
{
prefator = poly1[deg1_index℄;
/* Inner loop over poly2 terms */
for (deg2_index=0; deg2_index<=degree2; deg2_index++)
{
poly_output[deg1_index+ deg2 _ind ex℄ +=
prefator*poly2[deg2_index ℄;
} /* loses inner loop over poly2 terms */
} /* loses outer loop over poly1 terms */
return;
} /* loses poly_multiplyadd() */
/* ************************** **** **** **** **** * */
/* Polynomial Multipliation, then Subtration */
/* ************************** **** **** **** **** * */
void poly_multiplysub(double *poly1, int degree1,
{
int deg_index;
int deg1_index;
int deg2_index;
double prefator;
/* Multiply the polynomials and subtrat from poly_output */
for (deg1_index=0; deg1_index<=degree1; deg1_index++)
{
prefator = poly1[deg1_index℄;
/* Inner loop over poly2 terms */
for (deg2_index=0; deg2_index<=degree2; deg2_index++)
{
poly_output[deg1_index+ deg2 _ind ex℄ -=
prefator*poly2[deg2_index ℄;
} /* loses inner loop over poly2 terms */
} /* loses outer loop over poly1 terms */
return;
} /* loses poly_multiplysub() */
/* ************************** **** **** **** **** *** **** *** */
/* Polynomial Multipliation, then Saling and Addition */
/* ************************** **** **** **** **** *** **** *** */
void poly_multiplysaleadd(do uble *poly1, int degree1,
double *poly2, int degree2,
double sale, double *poly_output)
int deg1_index;
int deg2_index;
double prefator;
/* Multiply the polynomials and add to poly_output */
for (deg1_index=0; deg1_index<=degree1; deg1_index++)
{
prefator = sale*poly1[deg1_index℄;
/* Inner loop over poly2 terms */
for (deg2_index=0; deg2_index<=degree2; deg2_index++)
{
poly_output[deg1_index+ deg2 _ind ex℄ +=
prefator*poly2[deg2_index ℄;
} /* loses inner loop over poly2 terms */
} /* loses outer loop over poly1 terms */
return;
} /* loses poly_multiplysaleadd() */
/* ************************** **** **** **** **** *** **** **** ** */
/* Polynomial Multipliation, then Saling and Subtration */
/* ************************** **** **** **** **** *** **** **** ** */
void poly_multiplysalesub(do uble *poly1, int degree1,
double *poly2, int degree2,
double sale, double *poly_output)
{
int deg_index;
double prefator;
/* Multiply the polynomials and subtrat from poly_output */
for (deg1_index=0; deg1_index<=degree1; deg1_index++)
{
prefator = sale*poly1[deg1_index℄;
/* Inner loop over poly2 terms */
for (deg2_index=0; deg2_index<=degree2; deg2_index++)
{
poly_output[deg1_index+ deg2 _ind ex℄ -=
prefator*poly2[deg2_index ℄;
} /* loses inner loop over poly2 terms */
} /* loses outer loop over poly1 terms */
return;
} /* loses poly_multiplysalesub() */
/* ****************** */
/* Print a polynomial */
/* ****************** */
void poly_print(har *poly_label, double *poly, int degree)
{
int deg_index;
printf("================ === ==== ==== ==== ==== \n\ n");
{
printf("\t%+e ", poly[0℄);
}
for (deg_index=1;
deg_index<degree;
deg_index++)
{
if (poly[deg_index℄ != 0.0)
{
printf("+\n\t%+e w^%d ", poly[deg_index℄, deg_index);
}
}
deg_index = degree;
if (poly[deg_index℄ != 0.0)
{
printf("+\n\t%+e w^%d ", poly[deg_index℄, deg_index);
}
printf("\n\n");
printf("================ === ==== ==== ==== ==== \n\ n");