174 #define DATAENV "DATADIR"
175 #define DATADIR "AMDATA:"
176 #define EXPLPGP "Explicit.pgp"
177 #define ALLHPGP "AllH.pgp"
200 sNType1, sNType2, sNType3, sNType4, sNType5;
215 static int GenH(
PDB *pdb,
BOOL *err_flag);
218 static BOOL AddH(
PDB *hlist,
PDB **position,
int HType);
219 static void SetRawAtnam(
char *out,
char *in);
220 static PDB *StripDummyH(
PDB *pdb,
int *nhyd);
265 if((nhydrogens=GenH(pdb,&err_flag))<=0)
270 pdb = StripDummyH(pdb, &nhydrogens);
306 while(fgets(buffer,159,fp))
309 if((buffer[0] ==
'#')||(buffer[0] ==
'!'))
316 "%4s%4s%1x%4s%1x%4s%1x%4s%1x%4s%1x%4s%1x%1d%10lf%10lf%10lf",
330 printf(
"%4s %4s %4s %4s %4s %4s %4s %1d %8.3f %8.3f %8.3f\n",
331 sGRes[n],sGAtom[n][1],sGAtom[n][2],sGAtom[n][3],sGAtom[n][4],
332 sGAtom[n][5],sGAtom[n][6],sHType[n],sGR[n],
338 sAlpha[n] *= (
PI/180.0);
339 sBeta[n] *= (
PI/180.0);
371 static int GenH(
PDB *pdb,
BOOL *err_flag)
377 int k, n, m, j, ittot;
386 sFac = 0.5 * (
REAL)sqrt((
double)3.0);
391 sNType1=0; sNType2=0; sNType3=0; sNType4=0; sNType5=0;
411 if(!strncmp(p->
resnam,
"NTER",4))
434 strcpy(sGRName,p->
resnam);
436 printf(
"Group name is: %s\n",sGRName);
438 strcpy(sGNat[k],p->
atnam);
440 printf(
"Atom %d name: %s\n",k,sGNat[k]);
447 }
while((p !=
NULL) &&
455 for(n=1;n<=sNpgp;n++)
458 printf(
"sGRes(%d)=%s\n",n,sGRes[n]);
460 if(strncmp(sGRName,sGRes[n],4))
continue;
462 printf(
"Entry found for this res. in PGP\n");
468 for(m=1;m<=6;m++) strcpy(sGHName[m],sGAtom[n][m]);
471 if((hlist = makeh(sHType[n],sGR[n],sAlpha[n],sBeta[n],firstres))
477 if(!AddH(hlist,position,sHType[n]))
return(-1);
479 if(*err_flag)
return(-1);
486 printf(
"Rechecking for NTER...\n");
488 for(n=1;n<=sNpgp;n++)
491 printf(
"sGRes(%d)=%s\n",n,sGRes[n]);
493 if(strncmp(
"NTER",sGRes[n],4))
continue;
495 printf(
"Entry found for NTER in PGP.\n");
501 for(m=1;m<=6;m++) strcpy(sGHName[m],sGAtom[n][m]);
504 if((hlist = makeh(sHType[n],sGR[n],sAlpha[n],
505 sBeta[n],firstres))!=
NULL)
510 if(!AddH(hlist,position,sHType[n]))
return(-1);
512 if(*err_flag)
return(-1);
521 if(strncmp(sGRName,
"CTER",4))
524 for(j=sKMax-1;j>0;j--)
if(!strncmp(sGNat[j],c,4))
break;
529 sprintf(buffer,
"\nError==> genh() found no carbonyl carbon \
530 in residue %d\n\n",p->
resnum);
541 fprintf(stderr,
"Warning=> genh() found no carbonyl carbon \
546 fprintf(stderr,
"Warning=> genh() found no carbonyl carbon \
547 preceeding the last residue\n");
575 ittot=sNType1+sNType2+sNType3+sNType4+sNType5;
577 gHaddInfo.
Total = ittot;
578 gHaddInfo.
T1 = sNType1;
579 gHaddInfo.
T2 = sNType2;
580 gHaddInfo.
T3 = sNType3;
581 gHaddInfo.
T4 = sNType4;
582 gHaddInfo.
T5 = sNType5;
623 static char *nt =
"NT ",
625 REAL x1,y1,z1,x2,y2,z2,x3,y3,z3,
626 x4,y4,z4,x5,y5,z5,x6,y6,z6,
649 unsigned short nt_point;
657 if(hlist_start ==
NULL)
return(
NULL);
663 if(HType==1) num_ant=4;
else num_ant=3;
666 if(firstres && HType==4 && !strncmp(sGHName[2],n,4))
677 for(k=1; k<=sKMax; k++)
681 strcpy(sGNat[nt_point],n);
685 if(!strncmp(sGHName[1],sGNat[k],4))
687 if(!strncmp(sGNat[k],nt,4)) nt_point=k;
694 if(x1 > (
REAL)9998.0 &&
699 else if(!strncmp(sGHName[2],sGNat[k],4))
701 if(!strncmp(sGNat[k],nt,4)) nt_point=k;
708 if(x2 > (
REAL)9998.0 &&
713 else if(!strncmp(sGHName[3],sGNat[k],4))
715 if(!strncmp(sGNat[k],nt,4)) nt_point=k;
722 if(x3 > (
REAL)9998.0 &&
727 else if(!strncmp(sGHName[4],sGNat[k],4))
729 if(!strncmp(sGNat[k],nt,4)) nt_point=k;
736 if(x4 > (
REAL)9998.0 &&
753 for(jj=1;jj<=4;jj++)
if(!strncmp(sGHName[jj],n,4)) ok =
TRUE;
758 for(jj=1;jj<=4;jj++)
if(!strncmp(sGHName[jj],nt,4)) ok =
TRUE;
764 sprintf(buffer,
"Error==> makeh() unable to find all atoms \
765 required by PGP parameter for %3s %5d%c\n",sGRName,sNo,sIns);
767 screen(
"Atoms required by PGP\n");
771 sprintf(buffer,
" %4s",sGHName[jj]);
775 screen(
"Atoms in current residue\n");
777 for(jj=1;jj<=sKMax;jj++)
779 sprintf(buffer,
" %4s",sGNat[jj]);
793 r21=(
REAL)sqrt((
double)(x21*x21 + y21*y21 + z21*z21));
798 r23=(
REAL)sqrt((
double)(x23*x23 + y23*y23 + z23*z23));
808 x5 = y5 = z5 = (
REAL)9999.0;
815 r24=(
REAL)sqrt((
double)(x24*x24 + y24*y24 + z24*z24));
816 xv25=x21/r21+x24/r24+x23/r23;
817 yv25=y21/r21+y24/r24+y23/r23;
818 zv25=z21/r21+z24/r24+z23/r23;
819 rv25=(
REAL)sqrt((
double)(xv25*xv25 + yv25*yv25 + zv25*zv25));
820 x5=x2+BondLen*xv25/rv25;
821 y5=y2+BondLen*yv25/rv25;
822 z5=z2+BondLen*zv25/rv25;
828 strcpy(hlist->
atnam,sGHName[5]);
829 SetRawAtnam(hlist->
atnam_raw, sGHName[5]);
844 printf(
"makeh() Type 1 allocated hlist = %d\n",(
int)hlist);
851 cosa=(
REAL)cos((
double)alpha);
852 sina=(
REAL)sin((
double)alpha);
861 x4 = y4 = z4 = (
REAL)9999.0;
862 x5 = y5 = z5 = (
REAL)9999.0;
875 rab=(
REAL)sqrt((
double)(xab*xab+yab*yab+zab*zab));
882 rapb=(
REAL)sqrt((
double)(xapb*xapb+yapb*yapb+zapb*zapb));
886 xs=yplus*zmin-zplus*
ymin;
887 ys=zplus*xmin-xplus*zmin;
888 zs=xplus*ymin-yplus*
xmin;
889 x4=x2+BondLen*(cosa*xplus+sina*xs);
890 y4=y2+BondLen*(cosa*yplus+sina*ys);
891 z4=z2+BondLen*(cosa*zplus+sina*zs);
892 x5=x2+BondLen*(cosa*xplus-sina*xs);
893 y5=y2+BondLen*(cosa*yplus-sina*ys);
894 z5=z2+BondLen*(cosa*zplus-sina*zs);
900 strcpy(hlist->
atnam,sGHName[4]);
901 SetRawAtnam(hlist->
atnam_raw, sGHName[4]);
916 printf(
"makeh() Type 2a allocated hlist = %d\n",(
int)hlist);
922 strcpy(hlist->
atnam,sGHName[5]);
923 SetRawAtnam(hlist->
atnam_raw, sGHName[5]);
938 printf(
"makeh() Type 2b allocated hlist = %d\n",(
int)hlist);
956 scalpr=(x21*x32+y21*y32+z21*z32)/r23;
963 r21p=(
REAL)sqrt((
double)(x21p*x21p+y21p*y21p+z21p*z21p));
982 x4 = y4 = z4 = (
REAL)9999.0;
983 x5 = y5 = z5 = (
REAL)9999.0;
984 x6 = y6 = z6 = (
REAL)9999.0;
988 x4=x3+BondLen*(cosax+sina*xv);
989 y4=y3+BondLen*(cosay+sina*yv);
990 z4=z3+BondLen*(cosaz+sina*zv);
993 x5=x3+BondLen*(cosax+sina*(sFac*xs-0.5*xv));
994 y5=y3+BondLen*(cosay+sina*(sFac*ys-0.5*yv));
995 z5=z3+BondLen*(cosaz+sina*(sFac*zs-0.5*zv));
996 x6=x3+BondLen*(cosax+sina*(-sFac*xs-0.5*xv));
997 y6=y3+BondLen*(cosay+sina*(-sFac*ys-0.5*yv));
998 z6=z3+BondLen*(cosaz+sina*(-sFac*zs-0.5*zv));
1004 strcpy(hlist->
atnam,sGHName[4]);
1005 SetRawAtnam(hlist->
atnam_raw, sGHName[4]);
1020 printf(
"makeh() Type 3a allocated hlist = %d\n",(
int)hlist);
1026 strcpy(hlist->
atnam,sGHName[5]);
1027 SetRawAtnam(hlist->
atnam_raw, sGHName[5]);
1042 printf(
"makeh() Type 3b allocated hlist = %d\n",(
int)hlist);
1048 strcpy(hlist->
atnam,sGHName[6]);
1049 SetRawAtnam(hlist->
atnam_raw, sGHName[6]);
1064 printf(
"makeh() Type 3c allocated hlist = %d\n",(
int)hlist);
1076 x4 = y4 = z4 = (
REAL)9999.0;
1080 cosb=(
REAL)cos((
double)beta);
1081 sinb=(
REAL)sin((
double)beta);
1082 x4=x3+BondLen*(cosax+sina*(cosb*xv+sinb*xs));
1083 y4=y3+BondLen*(cosay+sina*(cosb*yv+sinb*ys));
1084 z4=z3+BondLen*(cosaz+sina*(cosb*zv+sinb*zs));
1090 strcpy(hlist->
atnam,sGHName[4]);
1091 SetRawAtnam(hlist->
atnam_raw, sGHName[4]);
1106 printf(
"makeh() Type 5 allocated hlist = %d\n",(
int)hlist);
1119 x4 = y4 = z4 = (
REAL)9999.0;
1126 scalpr=(x21*x32+y21*y32+z21*z32)/r21;
1136 rp23=(
REAL)sqrt((
double)(xp23*xp23+yp23*yp23+zp23*zp23));
1140 x4=x2+BondLen*(sina*xv-cosa*xh);
1141 y4=y2+BondLen*(sina*yv-cosa*yh);
1142 z4=z2+BondLen*(sina*zv-cosa*zh);
1148 strcpy(hlist->
atnam,sGHName[4]);
1149 SetRawAtnam(hlist->
atnam_raw, sGHName[4]);
1164 printf(
"makeh() Type 4 allocated hlist = %d\n",(
int)hlist);
1171 return(hlist_start);
1197 static BOOL AddH(
PDB *hlist,
PDB **position,
int HType)
1210 if(!position[k])
continue;
1214 if((((HType==3)||(HType==5))
1215 &&(!(strncmp(p->
atnam,sGHName[3],4))))||
1217 (((HType==1)||(HType==2)||(HType==4))
1218 &&(!strncmp(p->
atnam,sGHName[2],4))))
1235 p->
atnum = ++atomcount;
1252 if((HType==2)||(HType==3))
1270 p->
atnum = ++atomcount;
1305 p->
atnum = ++atomcount;
1355 if(pgpfile !=
NULL && pgpfile[0])
1357 fp = fopen(pgpfile,
"r");
1373 if((fp = fopen(basename,
"r")) ==
NULL)
1376 #if (unix || __unix__ || msdos || __msdos__ || __unix || __MACH__ || __APPLE__)
1381 sprintf(buffer,
"%s/%s",datadir,basename);
1382 fp = fopen(buffer,
"r");
1387 sprintf(buffer,
"Error: The %s environment variable has not \
1394 sprintf(buffer,
"%s%s",
DATADIR,basename);
1395 fp = fopen(buffer,
"r");
1421 static void SetRawAtnam(
char *out,
char *in)
1428 if(strlen(instr) > 3)
1439 strncpy(out+1, instr, 4);
1459 static PDB *StripDummyH(
PDB *pdb,
int *nhyd)
1463 for(p=pdb; p!=
NULL;)
1465 if((p->
atnam[0] ==
'H') &&
Include file for PDB routines.
Header for window/normal interface routines.
void blPadterm(char *string, int length)
int fsscanf(char *buffer, char *format,...)
Include file for fsscanf()
int blHAddPDB(FILE *fp, PDB *pdb)
Header file for general purpose routines.
FILE * blOpenPGPFile(char *pgpfile, BOOL AllHyd)
System-type variable type definitions.
Type definitions for maths.
char chain[blMAXCHAINLABEL]
void blRenumAtomsPDB(PDB *pdb, int offset)
#define PADMINTERM(string, len)