Пример #1
0
int Process_HELIX(BUFFER Buffer, CHAIN **Chain, int *ChainNumber, COMMAND *Cmd)
{
  int CC, HC;
  char *Field[MAX_FIELD];
  BUFFER Tmp;

  if( Cmd->NActive && !ChInStr(Cmd->Active,SpaceToDash(Buffer[19])) )
     return(SUCCESS);
     
  for( CC=0; CC < *ChainNumber && Chain[CC]->Id != Buffer[19]; CC++ );

  if( CC == *ChainNumber ) {
    InitChain(&Chain[CC]); 
    Chain[CC]->Id = Buffer[19];
    (*ChainNumber)++;
  }

  HC = Chain[CC]->NHelix;
  Chain[CC]->Helix[HC] =  (HELIX *)ckalloc(sizeof(HELIX));

  SplitString(Buffer+15,Field,1);

  strcpy(Chain[CC]->Helix[HC]->Res1,Field[0]);

  SplitString(Buffer+27,Field,1);

  strcpy(Chain[CC]->Helix[HC]->Res2,Field[0]);

  strcpy(Tmp,Buffer);
  Tmp[25] = ' ';
  Tmp[37] = ' ';
  SplitString(Tmp+21,Field,1);
  strcpy(Chain[CC]->Helix[HC]->PDB_ResNumb1,Field[0]);
  SplitString(Tmp+33,Field,1);
  strcpy(Chain[CC]->Helix[HC]->PDB_ResNumb2,Field[0]);

  Chain[CC]->Helix[HC]->InsCode1 = Buffer[25];
  Chain[CC]->Helix[HC]->InsCode2 = Buffer[37];

  Tmp[40] = ' ';
  SplitString(Tmp+38,Field,1);
  Chain[CC]->Helix[HC]->Class = atoi(Field[0]);

  Chain[CC]->NHelix++;

  return(SUCCESS);
}
Пример #2
0
static int Process_ATOM(BUFFER Buffer, CHAIN **Chain, int *ChainNumber, 
			BOOLEAN *First_ATOM, StrideCmd *Cmd) {
  char *Field[MAX_FIELD];
  BUFFER Tmp;
  int CC, NR, NA;
  static char LastRes[MAX_CHAIN][RES_FIELD];
  RESIDUE *r;

  if( Cmd->NActive && !ChInStr(Cmd->Active,SpaceToDash(Buffer[21])) )
     return(SUCCESS);

  if( Buffer[16] != 'A' && Buffer[16] != ' ' && Buffer[16] != '1' ) 
    return(SUCCESS);

  if( *First_ATOM ) {
    for( CC=0; CC<MAX_CHAIN; CC++ ) 
      strcpy(LastRes[CC],"XXXX");
    *First_ATOM = NO;
  }
  
  for( CC=0; CC < *ChainNumber && Chain[CC]->Id != Buffer[21] ; CC++ );
  
  if( CC == *ChainNumber ) {
    InitChain(&Chain[CC]); 
    Chain[CC]->Id = Buffer[21];
    (*ChainNumber)++;
  }
  else
  if( Chain[CC]->Ter == 1 ) 
    return(SUCCESS);

  if( Buffer[34] != '.' || Buffer[42] != '.' || Buffer[50] != '.' )
    return(escape(FAILURE,"File %s has no coordinates\n",Cmd->InputFile));

  
  if( Cmd->Stringent && Buffer[63] != '.')
    return(escape(FAILURE,"File %s has no temperature factor\n",Cmd->InputFile));


  SplitString(Buffer+22,Field,1);
  if( strcmp(Field[0],LastRes[CC]) ) {
    if( strcmp(LastRes[CC],"XXXX") && !FindAtom(Chain[CC],Chain[CC]->NRes,"CA",&NA) ) {
      free(Chain[CC]->Rsd[Chain[CC]->NRes]);
      Chain[CC]->NRes--;
    }
    if( strcmp(LastRes[CC],"XXXX") ) Chain[CC]->NRes++;
    NR = Chain[CC]->NRes;
    strcpy(LastRes[CC],Field[0]);
    Chain[CC]->Rsd[NR] = (RESIDUE *)ckalloc(sizeof(RESIDUE));
    strcpy(Chain[CC]->Rsd[NR]->PDB_ResNumb,LastRes[CC]);
    Chain[CC]->Rsd[NR]->NAtom = 0;
    SplitString(Buffer+17,Field,1);
    strcpy(Chain[CC]->Rsd[NR]->ResType,Field[0]);
  }
  else 
    NR = Chain[CC]->NRes;
  
  NA = Chain[CC]->Rsd[NR]->NAtom;

  if( Buffer[16] != ' ' ) {
    strcpy(Tmp,Buffer);
    Tmp[16] = ' ';
    SplitString(Tmp+12,Field,1);
  }
  else
    SplitString(Buffer+12,Field,1);
  
  r = Chain[CC]->Rsd[NR];
  strcpy(r->AtomType[NA],Field[0]);


  strcpy(Tmp,Buffer);
  Buffer[38] = ' ';
  SplitString(Tmp+30,Field,1);
  r->Coord[NA][0] = atof(Field[0]);

  strcpy(Tmp,Buffer);
  Buffer[46] = ' ';
  SplitString(Tmp+38,Field,1);
  r->Coord[NA][1] = atof(Field[0]);

  strcpy(Tmp,Buffer);
  Buffer[54] = ' ';
  SplitString(Tmp+46,Field,1);
  r->Coord[NA][2] = atof(Field[0]);

  if( Buffer[57] == '.' ) {
    strcpy(Tmp,Buffer);
    Tmp[60] = ' ';
    SplitString(Tmp+54,Field,1);
    r->Occupancy[NA] = atof(Field[0]);
  }
  else 
    r->Occupancy[NA] = -1.00;
  
  SplitString(Buffer+63,Field,1);
  r->TempFactor[NA] = atof(Field[0]);

  r->NAtom++;

  if( r->NAtom > MAX_AT_IN_RES-1 )
    return(escape(FAILURE,"File %s has too many atoms in residue %s %s %c\n",
		  Cmd->InputFile,r->ResType,r->PDB_ResNumb,Chain[CC]->Id));

  return(SUCCESS);
}
Пример #3
0
int Process_SHEET(BUFFER Buffer, CHAIN **Chain, int *ChainNumber, COMMAND *Cmd)
{
  int CC, SC, STC;
  char *Field[MAX_FIELD];
  BUFFER Tmp;
  static char PreviousChain, PreviousSheetId[RES_FIELD];

  if( Cmd->NActive && !ChInStr(Cmd->Active,SpaceToDash(Buffer[21])) )
     return(SUCCESS);

  for( CC=0; CC < *ChainNumber && Chain[CC]->Id != Buffer[21]; CC++ );

  if( CC == *ChainNumber ) {
    InitChain(&Chain[CC]); 
    Chain[CC]->Id = Buffer[21];
    (*ChainNumber)++;
  }

  if( Chain[CC]->NSheet == -1 ) {
    PreviousChain = '*';
    strcpy(PreviousSheetId,"*");
  }

  SplitString(Buffer+7,Field,2);

  if( atoi(Field[0]) == 1 || Buffer[21] != PreviousChain ) {
    if( Buffer[21] == PreviousChain && !strcmp(PreviousSheetId,Field[1]) )
      return(FAILURE);
/*      die("Here it is! -> %s%c\n", Chain[CC]->File,Chain[CC]->Id);*/
    Chain[CC]->NSheet++;
    SC = Chain[CC]->NSheet;
    Chain[CC]->Sheet[SC] =  (SHEET *)ckalloc(sizeof(SHEET));
    Chain[CC]->Sheet[SC]->NStrand = 0;
    STC = Chain[CC]->Sheet[SC]->NStrand;
    strcpy(Chain[CC]->Sheet[SC]->SheetId,Field[1]);
  }
  else
    {
      SC = Chain[CC]->NSheet;
      STC = Chain[CC]->Sheet[SC]->NStrand;
    }
  
  SplitString(Buffer+17,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->ResType1[STC],Field[0]);

  SplitString(Buffer+28,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->ResType2[STC],Field[0]);

  strcpy(Tmp,Buffer);
  Tmp[27] = ' ';
  Tmp[38] = ' ';
  SplitString(Tmp+22,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumb1[STC],Field[0]);
  SplitString(Tmp+33,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumb2[STC],Field[0]);

  Chain[CC]->Sheet[SC]->InsCode1[STC] = Buffer[26];
  Chain[CC]->Sheet[SC]->InsCode2[STC] = Buffer[37];

  SplitString(Buffer+38,Field,1);
  Chain[CC]->Sheet[SC]->Sence[STC] = atoi(Field[0]);

  if( Buffer[45] != ' ' ) {
    Chain[CC]->Sheet[SC]->RegYN[STC] = 1;
    SplitString(Buffer+45,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->ResTypeReg1[STC],Field[0]);
    SplitString(Buffer+60,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->ResTypeReg2[STC],Field[0]);
    
    Tmp[55] = ' ';
    Tmp[70] = ' ';
    SplitString(Tmp+50,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumbReg1[STC],Field[0]);
    SplitString(Tmp+66,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumbReg2[STC],Field[0]);
    
    Chain[CC]->Sheet[SC]->InsCodeReg1[STC] = Buffer[54];
    Chain[CC]->Sheet[SC]->InsCodeReg2[STC] = Buffer[69];
    
    Tmp[45] = ' ';
    Tmp[60] = ' ';
    SplitString(Tmp+41,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->AtomNameReg1[STC],Field[0]);
    SplitString(Tmp+56,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->AtomNameReg2[STC],Field[0]);
  }
  else Chain[CC]->Sheet[SC]->RegYN[STC] = 0;

  strcpy(PreviousSheetId,Chain[CC]->Sheet[SC]->SheetId);
  PreviousChain = Buffer[21];
  Chain[CC]->Sheet[SC]->NStrand++;

  return(SUCCESS);
}