113 #define DADISTSQ (DADIST*DADIST)
115 #define HADISTSQ (HADIST*HADIST)
126 static BOOL FindBackboneAcceptor(
PDB *res,
PDB **AtomA,
PDB **AtomP);
127 static BOOL FindBackboneDonor(
PDB *res,
PDB **AtomH,
PDB **AtomD);
128 static BOOL FindSidechainAcceptor(
PDB *res,
PDB **AtomA,
PDB **AtomP);
129 static BOOL FindSidechainDonor(
PDB *res,
PDB **AtomH,
PDB **AtomD);
183 if(FindBackboneDonor(res1, &AtomH, &AtomD))
187 if(FindBackboneAcceptor(res2, &AtomA, &AtomP))
197 while(FindSidechainAcceptor(res2, &AtomA, &AtomP))
204 if(FindBackboneAcceptor(res1, &AtomA, &AtomP))
208 if(FindBackboneDonor(res2, &AtomH, &AtomD))
218 while(FindSidechainDonor(res2, &AtomH, &AtomD))
232 while(FindSidechainDonor(res1, &AtomH, &AtomD))
236 if(FindBackboneAcceptor(res2, &AtomA, &AtomP))
246 while(FindSidechainAcceptor(res2, &AtomA, &AtomP))
255 while(FindSidechainAcceptor(res1, &AtomA, &AtomP))
259 if(FindBackboneDonor(res2, &AtomH, &AtomD))
269 while(FindSidechainDonor(res2, &AtomH, &AtomD))
317 if(
DISTSQ(AtomD, AtomA) < sDADistSq)
324 AtomA->
x, AtomA->
y, AtomA->
z,
325 AtomD->
x, AtomD->
y, AtomD->
z);
327 if((
DISTSQ(AtomD, AtomA) < sDADistSq) &&
335 AtomH->
x, AtomH->
y, AtomH->
z,
336 AtomA->
x, AtomA->
y, AtomA->
z);
348 AtomA->
x, AtomA->
y, AtomA->
z,
349 AtomH->
x, AtomH->
y, AtomH->
z);
379 static BOOL FindBackboneAcceptor(
PDB *res,
PDB **AtomA,
PDB **AtomP)
393 for(p=res; p!=NextRes;
NEXT(p))
395 if(!strncmp(p->
atnam,
"O ",4) ||
396 !strncmp(p->
atnam,
"OXT ",4) ||
397 !strncmp(p->
atnam,
"O1 ",4) ||
398 !strncmp(p->
atnam,
"O2 ",4))
400 if(!strncmp(p->
atnam,
"C ",4))
427 static BOOL FindBackboneDonor(
PDB *res,
PDB **AtomH,
PDB **AtomD)
432 if((res ==
NULL) || (!strncmp(res->
resnam,
"PRO", 3)))
441 for(p=res; p!=NextRes;
NEXT(p))
443 if(!strncmp(p->
atnam,
"H ",4))
445 if(!strncmp(p->
atnam,
"N ",4))
478 static BOOL FindSidechainAcceptor(
PDB *res,
PDB **AtomA,
PDB **AtomP)
504 for( ; p!=NextRes;
NEXT(p))
506 if((p->
atnam[0] ==
'O' && strncmp(p->
atnam,
"O ", 4)
507 && strncmp(p->
atnam,
"O1 ", 4)
508 && strncmp(p->
atnam,
"O2 ", 4)
509 && strncmp(p->
atnam,
"OXT ", 4)) ||
511 (p->
atnam[0] ==
'A') ||
513 (p->
atnam[0] ==
'N' && strncmp(p->
atnam,
"N ", 4)))
520 ((*AtomP)->atnam_raw[2] == (*AtomA)->atnam_raw[2]))
566 static BOOL FindSidechainDonor(
PDB *res,
PDB **AtomH,
PDB **AtomD)
589 for( ; p!=NextRes;
NEXT(p))
592 if(p->
atnam[0] ==
'A')
602 if(p->
atnam[0] ==
'H' && strncmp(p->
atnam,
"H ", 4))
611 while((p!=
NULL) && (p!=NextRes) && (p->
atnam[0] ==
'H'))
621 if( (*AtomD)->atnam[0] ==
'O' ||
622 ((*AtomD)->atnam[0] ==
'N' &&
623 !strncmp((*AtomD)->resnam,
"LYS",3)))
668 if(FindBackboneDonor(res1, &AtomH, &AtomD))
672 if(FindBackboneAcceptor(res2, &AtomA, &AtomP))
682 while(FindSidechainAcceptor(res2, &AtomA, &AtomP))
725 if(FindBackboneAcceptor(res1, &AtomA, &AtomP))
729 if(FindBackboneDonor(res2, &AtomH, &AtomD))
739 while(FindSidechainDonor(res2, &AtomH, &AtomD))
794 if(FindBackboneDonor(res1, &AtomH, &AtomD))
798 if(FindBackboneAcceptor(res2, &AtomA, &AtomP))
816 while(FindSidechainAcceptor(res2, &AtomA, &AtomP))
830 if(FindBackboneAcceptor(res1, &AtomA, &AtomP))
834 if(FindBackboneDonor(res2, &AtomH, &AtomD))
851 while(FindSidechainDonor(res2, &AtomH, &AtomD))
872 while(FindSidechainDonor(res1, &AtomH, &AtomD))
876 if(FindBackboneAcceptor(res2, &AtomA, &AtomP))
893 while(FindSidechainAcceptor(res2, &AtomA, &AtomP))
909 while(FindSidechainAcceptor(res1, &AtomA, &AtomP))
913 if(FindBackboneDonor(res2, &AtomH, &AtomD))
930 while(FindSidechainDonor(res2, &AtomH, &AtomD))
961 int main(
int argc,
char **argv)
971 if(argc != 2 || argv[1][0] ==
'-')
973 fprintf(stderr,
"Usage: hbond <file.pdb>\n");
974 fprintf(stderr,
"Generates a list of all HBonds in the PDB file\n");
979 if((fp = fopen(argv[1],
"r")))
982 if((pgp =
blOpenFile(
"Explicit.pgp",
"DATADIR",
"r",&noenv)))
998 printf(
"%s%d%s HBonded to %s%d%s\n",
1006 fprintf(stderr,
"No hydrogens added to PDB file\n");
1011 fprintf(stderr,
"No atoms read from PDB file\n");
1016 fprintf(stderr,
"Unable to open PGP file: Explicit.pgp\n");
1021 fprintf(stderr,
"Unable to open PDB file: %s\n");
int main(int argc, char **argv)
Include file for PDB routines.
void blSetMaxProteinHBondDADistance(REAL dist)
Header file for hbond determining code.
REAL blAngle(REAL xi, REAL yi, REAL zi, REAL xj, REAL yj, REAL zj, REAL xk, REAL yk, REAL zk)
int blIsMCAcceptorHBonded(PDB *res1, PDB *res2, int type)
FILE * blOpenFile(char *filename, char *envvar, char *mode, BOOL *noenv)
int blIsHBonded(PDB *res1, PDB *res2, int type)
PDB * blReadPDB(FILE *fp, int *natom)
int blIsMCDonorHBonded(PDB *res1, PDB *res2, int type)
Include file for angle functions.
int blHAddPDB(FILE *fp, PDB *pdb)
Header file for general purpose routines.
System-type variable type definitions.
PDB * blFindNextResidue(PDB *pdb)
Type definitions for maths.
char chain[blMAXCHAINLABEL]
HBLIST * blListAllHBonds(PDB *res1, PDB *res2)
BOOL blValidHBond(PDB *AtomH, PDB *AtomD, PDB *AtomA, PDB *AtomP)