Ejemplo n.º 1
0
/*>BOOL blAreResiduePointersBonded(PDB *res1, PDB *res2, REAL tol)
   ---------------------------------------------------------------
*//**
   \param[in] *res1      Start of first residue
   \param[in] *res2      Start of second residue
   \param[in] tol        Tolerance for distances
   \return               Are they bonded

   Tests whether two residue are bonded using pointers to start of
   residues

-  23.06.15 Original   By: ACRM
*/
BOOL blAreResiduePointersBonded(PDB *res1, PDB *res2, REAL tol)
{
   PDB *res1next,
       *res2next,
       *p,
       *q;

   if((res1 != NULL) && (res2 != NULL))
   {
      /* Find the following residues                                    */
      res1next = blFindNextResidue(res1);
      res2next = blFindNextResidue(res2);

      /* Step through the atoms in each residue and see if they are
         bonded
      */
      for(p=res1; p!=res1next; NEXT(p))
      {
         for(q=res2; q!=res2next; NEXT(q))
         {
            if(blIsBonded(p, q, tol))
               return(TRUE);
         }
      }
   }
   return(FALSE);
}
Ejemplo n.º 2
0
/*>PDB *blFindAtomWildcardInRes(PDB *pdb, char *pattern)
   -----------------------------------------------------
*//**

   \param[in]     *pdb      Pointer to start of a residue
   \param[in]     *pattern  Atom name pattern to find
   \return                  Pointer to requested atom or NULL if not
                            found.

   Finds an atom within the residue given as a PDB pointer. Allows 
   single character wildcards. Thus ?G? maybe used for any atom at the
   gamma position.

   Returns the first atom which matches

-  27.08.96 Original   By: ACRM
-  07.07.14 Use bl prefix for functions By: CTP
*/
PDB *blFindAtomWildcardInRes(PDB *pdb, char *pattern)
{
   PDB  *p, *pNext;
   int  i;
   BOOL ok;
   
   pNext = blFindNextResidue(pdb);
   
   for(p=pdb; p!=pNext; NEXT(p))
   {
      if(!strncmp(p->atnam,pattern,4))
         return(p);
      ok = TRUE;
      for(i=0; i<4; i++)
      {
         if((pattern[i] != p->atnam[i]) && pattern[i] != '?')
         {
            ok = FALSE;
            break;
         }
      }
      if(ok)
         return(p);
   }
   return(NULL);
}
Ejemplo n.º 3
0
/*>BOOL blBuildConectData(PDB *pdb, REAL tol)
   ------------------------------------------
*//**
   \param[in,out]   *pdb   PDB linked list
   \param[in]       tol    Tolerence for distance between atoms
   \return                 Were all CONECTs added OK

   Deletes all current connectivity data and rebuilds it using covalent
   radii data. A return of FALSE indicates that there were too many
   connections for an atom. If this happens, MAXCONECT needs to be 
   increased in pdb.h

-  19.02.15  Original   By: ACRM
-  26.02.15  Added tol paramater
-  12.05.15  Conects are built involving backbone C and N if either atom
             is a HETATM
*/
BOOL blBuildConectData(PDB *pdb, REAL tol)
{
   PDB  *p, 
        *q,
        *res,
        *nextRes;
   BOOL retval=TRUE;

   /* Clear all current connect data                                    */
   for(p=pdb; p!=NULL; NEXT(p))
   {
      p->nConect = 0;
   }

   for(res=pdb; res!=NULL; res=nextRes)
   {
      nextRes = blFindNextResidue(res);

      /* Check for any HETATM connections within this residue           */
      for(p=res; p!=nextRes; NEXT(p))
      {
         for(q=p->next; q!=nextRes; NEXT(q))
         {
            if(!strncmp(p->record_type, "HETATM", 6) ||
               !strncmp(q->record_type, "HETATM", 6))
            {
               if(blIsBonded(p, q, tol))
               {
                  if(!blAddConect(p,q))
                     retval=FALSE;
               }
            }
         }
      }

      /* Check for connections between residues which don't involve backbone
         C or N, or do involve HETATMS
      */
      for(p=res; p!=nextRes; NEXT(p))
      {
         for(q=nextRes; q!=NULL; NEXT(q))
         {
            if(strncmp(p->atnam, "C   ", 4) ||
               strncmp(q->atnam, "N   ", 4) ||
               !strncmp(p->record_type, "HETATM", 6) ||
               !strncmp(q->record_type, "HETATM", 6))
            {
               if(blIsBonded(p, q, tol))
               {
                  if(!blAddConect(p,q))
                     retval=FALSE;
               }
            }
         }
      }
   }

   return(retval);
}
Ejemplo n.º 4
0
/*>BOOL blRepOneSChain(PDB *pdb, char *ResSpec, char aa, char *ChiTable,
                     char *RefCoords)
   ---------------------------------------------------------------------
*//**

   \param[in,out] *pdb        PDB linked list to modify
   \param[in]     *ResSpec    Residue spec for residue to replace in the
                              format [c]nnn[i]
   \param[in]     aa          The 1-letter code for the new sidechain
   \param[in]     *ChiTable   The equivalent Chi table
   \param[in]     *RefCoords  The reference coordinates file
   \return                      Success?

   Replace a single sidechain. Takes a PDB linked list, a residues
   specfication (in the form [c]nnn[i] where [c] is an optional chain
   name, nnn is a residue number and [i] is an optional insert code)
   and a 1-letter code of the required sidechain and does a simple
   maximum overlap replacement of the sidechain. Also requires filenames 
   of the two datafiles.
   
-  12.08.96 Original based on RepSChain()
-  15.08.96 Removed unused variables
-  07.07.14 Use bl prefix for functions By: CTP
-  23.02.15 Modified for new blRenumAtomsPDB() which takes an offset
*/
BOOL blRepOneSChain(PDB *pdb, char *ResSpec, char aa, char *ChiTable,
                  char *RefCoords)
{
   PDB   *ResStart,                 /* Start of residue                 */
         *NextRes;                  /* Start of next residue            */
   BOOL  noenv = FALSE;             /* Flag for no env. var. found      */
   
   if(sFirstCall)
   {
      FILE  *fp_ChiTable;

      /* Allocate 2D array for equivalent torsions                      */
      if((sChiTab = (int **)blArray2D(sizeof(int), NUMAAKNOWN, NUMAAKNOWN)) 
         == NULL)
         return(FALSE);
   
      /* Open files                                                     */
      if((fp_ChiTable = blOpenFile(ChiTable,"DATADIR","r",&noenv)) == NULL)
      {
         if(noenv)
         {
            sprintf(gRSCError,"DATADIR environment variable not set\n");
         }
         else
         {
            sprintf(gRSCError,"Unable to open chi link table: %s\n",
                    ChiTable);
         }
         return(FALSE);
      }

      if((sFp_RefCoords = blOpenFile(RefCoords,"DATADIR","r",&noenv)) == 
         NULL)
      {
         if(noenv)
         {
            sprintf(gRSCError,"DATADIR environment variable not set\n");
         }
         else
         {
            sprintf(gRSCError,"Unable to open reference coordinates: \
%s\n", RefCoords);
         }
         return(FALSE);
      }

      /* Read the equivalent chi table and the atom table               */
      ReadChiTable(fp_ChiTable, sChiTab);
      
      /* Close the table files                                          */
      fclose(fp_ChiTable);
      
      sFirstCall = FALSE;
   }
   
   /* Find the specified residue and the one following                  */
   if((ResStart = blFindResidueSpec(pdb, ResSpec))==NULL)
   {
      sprintf(gRSCError,"Residue specification not in PDB list\n");
      return(FALSE);
   }
   NextRes = blFindNextResidue(ResStart);
   
   /* If there is a sequence mismatch, replace the residue              */
   if(aa != blThrone(ResStart->resnam))
   {
      if(DoReplace(ResStart, NextRes, aa, sChiTab, sFp_RefCoords) == 
         NULL) 
      {
         return(FALSE);
      }
   }
   
   blRenumAtomsPDB(pdb, 1);
   
   return(TRUE);
}
Ejemplo n.º 5
0
PDB *FindNextResidue(PDB *pdb)
{
   DEPRECATED("FindNextResidue()","blFindNextResidue()");
   return(blFindNextResidue(pdb));
}
Ejemplo n.º 6
0
PDB *FindEndPDB(PDB *start)
{
   DEPRECATED("FindEndPDB()","blFindNextResidue()");
   return(blFindNextResidue(start));
}