static int splineisinside (Pedge_t *edges, int edgen, Ppoint_t *sps) { double roots[4]; int rooti, rootn; int ei; Ppoint_t lps[2], ip; double t, ta, tb, tc, td; for (ei = 0; ei < edgen; ei++) { lps[0] = edges[ei].a, lps[1] = edges[ei].b; /* if ((rootn = splineintersectsline (sps, lps, roots)) == 4) return 1; */ if ((rootn = splineintersectsline (sps, lps, roots)) == 4) continue; for (rooti = 0; rooti < rootn; rooti++) { if (roots[rooti] < EPSILON2 || roots[rooti] > 1 - EPSILON2) continue; t = roots[rooti]; td = t * t * t; tc = 3 * t * t * (1 - t); tb = 3 * t * (1 - t) * (1 - t); ta = (1 - t) * (1 - t) * (1 - t); ip.x = ta * sps[0].x + tb * sps[1].x + tc * sps[2].x + td * sps[3].x; ip.y = ta * sps[0].y + tb * sps[1].y + tc * sps[2].y + td * sps[3].y; if (DISTSQ (ip, lps[0]) < EPSILON1 || DISTSQ (ip, lps[1]) < EPSILON1) continue; return 0; } } return 1; }
/*>BOOL ResidueContact(PDB *p_start, PDB *p_stop, PDB *q_start, PDB *q_stop, REAL dist) ------------------------------------------------------------ Input: PDB *p_start Start of first residue PDB *p_stop Record after end of first residue PDB *q_start Start of second residue PDB *q_stop Record after end of second residue REAL dist Maximum distace to define contact Returns: BOOL In contact? See if a contact of <= dist Angstroms is made between atoms in the residue bounded by pointers p_start/p_stop and sidechain atoms bounded by q_start/q_stop 01.08.95 Original By: ACRM 30.01.09 Corrected initial self-contact check */ BOOL ResidueContact(PDB *p_start, PDB *p_stop, PDB *q_start, PDB *q_stop, REAL dist) { PDB *p, *q; /* Ignore contact with itself */ if(p_start==q_start) /* 30.01.09 Corrected from p and q */ return(FALSE); /* Square the distance to save on doing square roots */ dist *= dist; for(p=p_start; p!=p_stop; NEXT(p)) { for(q=q_start; q!=q_stop; NEXT(q)) { if(strncmp(q->atnam,"N ",4) && strncmp(q->atnam,"CA ",4) && strncmp(q->atnam,"C ",4) && strncmp(q->atnam,"O ",4)) { if(DISTSQ(p,q) <= dist) return(TRUE); } } } return(FALSE); }
/*>BOOL blIsBonded(PDB *p, PDB *q, REAL tol) ----------------------------------------- *//** \param[in] *p First PDB atom \param[in] *q Second PDB atom \param[in] tol Telerance for separation between atoms \return Bonded? Test whether two atoms are bonded - 19.02.15 Original By: ACRM - 26.02.15 Added tol parameter. Changed to used squared distances */ BOOL blIsBonded(PDB *p, PDB *q, REAL tol) { REAL r1, r2, bondDist; r1 = findCovalentRadius(p->element); r2 = findCovalentRadius(q->element); bondDist = (r1+r2+tol); if(DISTSQ(p,q) <= bondDist*bondDist) return(TRUE); return(FALSE); }
/*>int main(int argc, char **argv) ------------------------------- *//** - 27.07.12 Original By: ACRM - 22.07.14 Renamed deprecated functions with bl prefix. By: CTP - 07.11.14 Initialized closest - 12.03.15 Changed to allow multi-character chain names */ int main(int argc, char **argv) { FILE *in = stdin, *out = stdout; char infile[MAXBUFF], outfile[MAXBUFF]; PDB *pdb; int natoms; if(ParseCmdLine(argc, argv, infile, outfile)) { if(blOpenStdFiles(infile, outfile, &in, &out)) { if((pdb = blReadPDB(in,&natoms)) != NULL) { VEC3F cg; PDB *p, *closest = NULL; REAL bestDistSq = 99999.0, dist; blGetCofGPDB(pdb, &cg); for(p=pdb; p!=NULL; NEXT(p)) { if(!strncmp(p->atnam, "CA ",4)) { dist = DISTSQ(p, (&cg)); if(dist < bestDistSq) { bestDistSq = dist; closest = p; } } } fprintf(out, "%s%d%c\n", closest->chain, closest->resnum, closest->insert[0]); } else { fprintf(stderr,"No atoms read from PDB file\n"); } } } else { Usage(); } return(0); }