Ejemplo n.º 1
0
Archivo: helix.c Proyecto: josch/stride
void Helix(CHAIN **Chain, int Cn, HBOND **HBond, COMMAND *Cmd, float **PhiPsiMap)
{

  int BondNumb, i;
  float *Prob, CONST;
  RESIDUE **r;

  CONST = 1+Cmd->C1_H;

  Prob = (float *)ckalloc(MAX_RES*sizeof(float));

  for( i=0; i<Chain[Cn]->NRes; i++ )
    Prob[i] = 0.0; 


  for( i=0; i<Chain[Cn]->NRes-5; i++ ) {

    r = &Chain[Cn]->Rsd[i];

    if( r[0]->Prop->PhiZn != ERR && r[0]->Prop->PsiZn != ERR &&
        r[1]->Prop->PhiZn != ERR && r[1]->Prop->PsiZn != ERR &&
        r[2]->Prop->PhiZn != ERR && r[2]->Prop->PsiZn != ERR &&
        r[3]->Prop->PhiZn != ERR && r[3]->Prop->PsiZn != ERR &&
        r[4]->Prop->PhiZn != ERR && r[4]->Prop->PsiZn != ERR ) {

      if( (BondNumb = FindPolInt(HBond,r[4],r[0])) != ERR ) {
	Prob[i] = HBond[BondNumb]->Energy*(CONST+Cmd->C2_H*
	    0.5*(PhiPsiMap[r[0]->Prop->PhiZn][r[0]->Prop->PsiZn]+
		 PhiPsiMap[r[4]->Prop->PhiZn][r[4]->Prop->PsiZn]));

      }
    }
  }
  
  for( i=0; i<Chain[Cn]->NRes-5; i++ ) {

    if( Prob[i] < Cmd->Treshold_H1 && Prob[i+1] < Cmd->Treshold_H1 ) {

      r = &Chain[Cn]->Rsd[i];

      r[1]->Prop->Asn = 'H'; 
      r[2]->Prop->Asn = 'H'; 
      r[3]->Prop->Asn = 'H'; 
      r[4]->Prop->Asn = 'H';
      if( r[0]->Prop->PhiZn!= ERR && r[0]->Prop->PsiZn != ERR &&
	  PhiPsiMap[r[0]->Prop->PhiZn][r[0]->Prop->PsiZn] > Cmd->Treshold_H3 )
	r[0]->Prop->Asn = 'H';
      if( r[5]->Prop->PhiZn != ERR && r[5]->Prop->PsiZn != ERR &&
	  PhiPsiMap[r[5]->Prop->PhiZn][r[5]->Prop->PsiZn] > Cmd->Treshold_H4 )
	r[5]->Prop->Asn = 'H';
    }
  }

  for( i=0; i<Chain[Cn]->NRes-4; i++ ) {

    r = &Chain[Cn]->Rsd[i];

    if(  FindBnd(HBond,r[3],r[0]) != ERR && FindBnd(HBond,r[4],r[1]) != ERR &&
       /*************************** This should be improved **************************/
         ( (r[1]->Prop->Asn != 'H' && r[2]->Prop->Asn != 'H') ||
	   (r[2]->Prop->Asn != 'H' && r[3]->Prop->Asn != 'H') ) ) 
       /******************************************************************************/
      {
	r[1]->Prop->Asn = 'G'; 
	r[2]->Prop->Asn = 'G'; 
	r[3]->Prop->Asn = 'G'; 
      }
  }

  for( i=0; i<Chain[Cn]->NRes-6; i++ ) {

    r = &Chain[Cn]->Rsd[i];

    if( FindBnd(HBond,r[5],r[0]) != ERR && FindBnd(HBond,r[6],r[1]) != ERR &&
        r[1]->Prop->Asn == 'C' && r[2]->Prop->Asn == 'C' && 
        r[3]->Prop->Asn == 'C' && r[4]->Prop->Asn == 'C' && 
        r[5]->Prop->Asn == 'C' ) {
      r[1]->Prop->Asn = 'I'; 
      r[2]->Prop->Asn = 'I';
      r[3]->Prop->Asn = 'I'; 
      r[4]->Prop->Asn = 'I'; 
      r[5]->Prop->Asn = 'I'; 
    }
  }

  if( Cmd->Info ) {
    fprintf(stdout,"%s%c\n",Chain[Cn]->File,Chain[Cn]->Id);

    for( i=0; i<Chain[Cn]->NRes-4; i++ ) {

      r = &Chain[Cn]->Rsd[i];

      if( r[0]->Prop->PhiZn != ERR && r[0]->Prop->PsiZn != ERR &&
	  r[4]->Prop->PhiZn != ERR && r[4]->Prop->PsiZn != ERR ) {
	
	fprintf(stdout,"%s (%d) %c %10.7f %8.5f %8.5f | %4d %4d\n",
		r[0]->PDB_ResNumb,i,r[0]->Prop->Asn,Prob[i],
		PhiPsiMap[r[0]->Prop->PhiZn][r[0]->Prop->PsiZn],
		PhiPsiMap[r[4]->Prop->PhiZn][r[4]->Prop->PsiZn],
		r[4]->Prop->PhiZn,r[4]->Prop->PsiZn);
      }
    }
  }
  free(Prob);
}
Ejemplo n.º 2
0
int Link(HBOND **HBond, CHAIN **Chain, int Cn1, int Cn2, RESIDUE *Res1_1, 
	 RESIDUE *Res1_2, RESIDUE *Res2_2, RESIDUE *Res2_1, RESIDUE *CRes1, 
	 RESIDUE *CRes2, float **PhiPsiMap, PATTERN **Pattern, int *NumPat, 
	 char *Text, float Treshold, COMMAND *Cmd, int Test)
{

  int BondNumber1, BondNumber2, Flag = 0;
  static char *Result[2] = {" NO \n"," YES \n"};
  float Prob1, Prob2, Conf, Coeff;

  if( (BondNumber1 = FindPolInt(HBond,Res1_1,Res1_2)) == ERR ) 
    return(FAILURE);

  if( (BondNumber2 = FindPolInt(HBond,Res2_2,Res2_1)) == ERR ) 
    return(FAILURE);

  if( CRes1 == NULL ) {
    if( CRes2->Prop->PhiZn == ERR || CRes2->Prop->PsiZn == ERR )
      return(FAILURE);
    Conf = PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn];
  }
  else
  if( CRes2 == NULL ) {
    if( CRes1->Prop->PhiZn == ERR || CRes1->Prop->PsiZn == ERR )
      return(FAILURE);
    Conf = PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn];
  }
  else {
    if( CRes2->Prop->PhiZn == ERR || CRes2->Prop->PsiZn == ERR ||
        CRes1->Prop->PhiZn == ERR || CRes1->Prop->PsiZn == ERR )
      return(FAILURE);
    Conf = 
      0.5*(PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn]+
	   PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn]);
  }
  Coeff = 1+Cmd->C1_E+Cmd->C2_E*Conf;
  Prob1 = HBond[BondNumber1]->Energy*Coeff;
  Prob2 = HBond[BondNumber2]->Energy*Coeff;

  if( Prob1 < Treshold && Prob2 < Treshold ) {

    if( !Test ) {
      Pattern[*NumPat] = (PATTERN *)ckalloc(sizeof(PATTERN));
      Pattern[*NumPat]->ExistPattern = YES;
      Pattern[*NumPat]->Hb1 = HBond[BondNumber1];
      Pattern[*NumPat]->Hb2 = HBond[BondNumber2];
      Pattern[*NumPat]->Nei1 = NULL;
      Pattern[*NumPat]->Nei2 = NULL;
      strcpy(Pattern[*NumPat]->Type,Text);
      (*NumPat)++;
    }
    Flag = 1;
  }

  if( Cmd->Info && Flag ) {
    fprintf(stdout,"%s %c: %3s %c: %3s | %c: %3s %c: %3s | ",
	    Text,
	    Chain[Cn1]->Id,Res1_1->PDB_ResNumb,
	    Chain[Cn2]->Id,Res1_2->PDB_ResNumb,
	    Chain[Cn2]->Id,Res2_2->PDB_ResNumb,
	    Chain[Cn1]->Id,Res2_1->PDB_ResNumb);
    fprintf(stdout,"%8.6f %6.4f | ", Prob1,HBond[BondNumber1]->Energy);
    fprintf(stdout,"%8.6f %6.4f | ", Prob2,HBond[BondNumber2]->Energy);

    if( CRes1 != NULL && 
        CRes1->Prop->PhiZn != ERR && CRes1->Prop->PsiZn != ERR )
      fprintf(stdout,"%6.4f %2d %2d | ",   
	      PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn],
	      CRes1->Prop->PhiZn,CRes1->Prop->PsiZn);
    else
      fprintf(stdout,"000000 00 00 | ");

    if( CRes2 != NULL &&
        CRes2->Prop->PhiZn != ERR && CRes2->Prop->PsiZn != ERR )
      fprintf(stdout,"%6.4f %2d %2d | ",   
	      PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn],
	      CRes2->Prop->PhiZn,CRes2->Prop->PsiZn);
    else
      fprintf(stdout,"000000 00 00 | ");
    
    fprintf(stdout,"%s",Result[Flag]);
  }
  
  return(Flag);
  
}