GLYLIB  0.3.0b
rwm_line.c
Go to the documentation of this file.
00001 /**************************  rwm_line() *******************************/
00002 /* Author: Lachele Foley
00003    Modified for use in library by: Michael Tessier*/
00004 #include <load_pdb.h>
00005 //#include "../inc/load_pdb.h"
00006 extern int DEBUG,WARN,SILENT;
00007 /* This reads in the line */
00008 void rwm_line(int rwmln){
00009 int rwmdone=0, rwma=0, rwmb=0, rwmstop=-1, rwmmt=-1, rwmnl=-1;
00010 int shortline=-1;
00011 linetype rwmlt;
00012 char rwmaCL='I',rwmaRN='I',rwmtest='\0';
00013 /* Read in first six characters and determine line type */
00014 if(DEBUG>=1){printf("rwm_line 1\n");}
00015 for(rwma=0;rwma<6;rwma++){
00016         if(rwmstop!=0){
00017                 rwmdone=fgetc(IN);
00018 if(DEBUG>=2){printf("Just got new rwmdone \n");}
00019                 if(rwmdone==EOF){read_neek("EOF",rwmln,rwma);}
00020                 }
00021         if(((rwmdone=='\n')||(rwmdone==' '))&&(rwma==0)){
00022 if(DEBUG>=2){printf("Empty line found \n");}
00023                 if(rwmdone=='\n'){rwmnl=0;}
00024                 rwmmt=0;
00025                 }
00026         if((rwmdone=='\n')||(rwmstop==0)){
00027 if(DEBUG>=2){printf("resetting rwmdone \n");}
00028                 rwmnl=0;
00029                 rwmdone=' ';
00030                 rwmstop=0;
00031                 }
00032         ln[rwmln-1].f[0].c[rwma]=rwmdone;
00033         }
00034 if(rwmmt==0){ /* If this is an empty line */
00035         if(rwmnl!=0){
00036                 rwmdone=fgetc(IN);
00037                 while(rwmdone!='\n'){
00038                         rwmdone=fgetc(IN);
00039                         }
00040                 }
00041         /* if(WARN!=0){fprintf(OUT,"\n");} */
00042         return;
00043         }
00044 if(DEBUG>=1){printf("rwm_line 2\n");}
00045 // if the first six chars seem to be ok...
00046 // null-terminate the string
00047 ln[rwmln-1].f[0].c[6]='\0';
00048 
00049 // made it here?  find out the line type
00050 if(DEBUG>=1){printf("rwm_line 3 fieldname is >>>%s<<<\n",ln[rwmln-1].f[0].c);}
00051 rwmlt=get_type(ln[rwmln-1].f[0].c); 
00052 ln[rwmln-1].a=rwmlt.a; // class 
00053 ln[rwmln-1].b=rwmlt.b; // number for the sub-class
00054 
00055 
00056 
00057 /* Assign action switch from internal defaults */
00058 if(DEBUG>=1){printf("rwm_line 4\n");}
00059 if(DEBUG>=1){printf("rwmlt.a is %d and rwmlt.b is %d\n",rwmlt.a,rwmlt.b);} 
00060 /* If get_type returned a valid class: */
00061 
00062 
00063 if(rwmlt.a==-1){ // If this line type is unknown
00064 // do something....
00065         rwmaCL='I';
00066         rwmaRN='D';
00067         }
00068 //If there line was less than 6 characters
00069 if(rwmstop == 0)
00070  return;
00071 
00072 // If the rule is to modify, read in the rest of the line, first...  
00073 for(rwma=1;rwma<pdb_a[rwmlt.a].b[rwmlt.b].f;rwma++){
00074 //printf("in the read rest of line loop, chars is %d\n",pdb_a[rwmlt.a].b[rwmlt.b].c[rwma]);
00075         for(rwmb=0;rwmb<pdb_a[rwmlt.a].b[rwmlt.b].c[rwma];rwmb++){
00076                 ln[rwmln-1].f[rwma].c[rwmb]=fgetc(IN);
00077 //printf("the current character (%d) is >>%c<<\n",rwmb,ln[rwmln-1].f[rwma].c[rwmb]);
00078                 //fprintf(OUTC,"%c",ln[rwmln-1].f[rwma].c[rwmb]);
00079                 if(ln[rwmln-1].f[rwma].c[rwmb]=='\n'){
00080                         rwmb=pdb_a[rwmlt.a].b[rwmlt.b].c[rwma];
00081                         rwma=pdb_a[rwmlt.a].b[rwmlt.b].f;
00082                         shortline=0;
00083                         rwmtest='\n';
00084                         }
00085                 if(ln[rwmln-1].f[rwma].c[rwmb]==EOF){
00086                         read_neek("EOF",(rwmln),(rwma+1));
00087                         }
00088                 }
00089         ln[rwmln-1].f[rwma].c[rwmb]='\0';
00090         } 
00091 
00092 //printf("rwmtest is >>%c<<\t",rwmtest);
00093 if(shortline!=0) rwmtest=fgetc(IN);
00094 //printf("rwmtest is >>%c<<\n",rwmtest);
00095 
00096 if((rwmtest!='\n')&&(rwmtest!=EOF)){
00097         printf("Found line longer than 80 characters (likely line %d).  Ignoring rest of line.\n",rwmln);
00098         rwmtest='\0';
00099         while(rwmtest!='\n'){rwmtest=fgetc(IN);}
00100         }
00101 if(DEBUG>=0){printf("rwm_line 13\n");}
00102 /*if((WARN==0)&&(SILENT!=0)){fflush(OUTC);} */
00103 return;
00104 }
00105 
00106 /*This function written by Michael Tessier 20080828*/
00107 void rwm_line_char(char* curLine, int rwmln){
00108 int rwmdone=0, rwma=0, rwmb=0, rwmstop=-1, rwmmt=-1, rwmnl=-1;
00109 int itr,ishorta=0,ishortb=0;
00110 linetype rwmlt;
00111 char rwmaCL='I',rwmaRN='I';
00112 /* Read in first six characters and determine line type */
00113 if(DEBUG>=1){printf("rwm_line 1\n");}
00114 for(rwma=0;rwma<6;rwma++){
00115         if(rwmstop!=0){
00116                 rwmdone=curLine[rwma];
00117 if(DEBUG>=2){printf("Just got new rwmdone \n");}
00118                 //if(rwmdone==EOF){read_neek("EOF",rwmln,rwma);}
00119                 }
00120         if(((rwmdone=='\n')||(rwmdone==' '))&&(rwma==0)){
00121 if(DEBUG>=1){printf("Empty line found \n");}
00122                 if(rwmdone=='\n'){rwmnl=0;}
00123                 rwmmt=0;
00124                 }
00125         if((rwmdone=='\n')||(rwmstop==0)){
00126 if(DEBUG>=2){printf("resetting rwmdone \n");}
00127                 rwmnl=0;
00128                 rwmdone=' ';
00129                 rwmstop=0;
00130                 }
00131         ln[rwmln-1].f[0].c[rwma]=rwmdone;
00132         }
00133 if(rwmmt==0){ /* If this is an empty line */
00134         /*if(WARN!=0){fprintf(OUT,"\n");}*/
00135         return;
00136         }
00137 if(DEBUG>=1){printf("rwm_line 2\n");}
00138 // if the first six chars seem to be ok...
00139 // null-terminate the string
00140 ln[rwmln-1].f[0].c[6]='\0';
00141 
00142 // made it here?  find out the line type
00143 if(DEBUG>=1){printf("rwm_line 3 fieldname is >>>%s<<<\n",ln[rwmln-1].f[0].c);}
00144 rwmlt=get_type(ln[rwmln-1].f[0].c); 
00145 ln[rwmln-1].a=rwmlt.a; // class 
00146 ln[rwmln-1].b=rwmlt.b; // number for the sub-class
00147 
00148 
00149 
00150 if(DEBUG>=1){printf("rwmlt.a is %d and rwmlt.b is %d\n",rwmlt.a, rwmlt.b);}
00151 /* Assign action switch from internal defaults */
00152 if(DEBUG>=1){printf("rwm_line 4\n");}
00153 //if(DEBUG>=0){printf("rwmlt.a is %d and rwmlt.b is %d\n",rwmlt.a,rwmlt.b);} 
00154 /* If get_type returned a valid class: */
00155 
00156 
00157 if(rwmlt.a==-1){ // If this line type is unknown
00158 // do something....
00159         rwmaCL='I';
00160         rwmaRN='D';
00161         }
00162 //If there line was less than 6 characters
00163 if(rwmstop == 0)
00164  return;
00165 itr = 6;
00166 // If the rule is to modify, read in the rest of the line, first...  
00167 for(rwma=1;rwma<pdb_a[rwmlt.a].b[rwmlt.b].f;rwma++){
00168         for(rwmb=0;rwmb<pdb_a[rwmlt.a].b[rwmlt.b].c[rwma];rwmb++){
00169                 ln[rwmln-1].f[rwma].c[rwmb]=curLine[itr];
00170                 //fprintf(OUTC,"%c",ln[rwmln-1].f[rwma].c[rwmb]);
00171                 if(ln[rwmln-1].f[rwma].c[rwmb]=='\n'){
00172                         if(rwmb<pdb_a[rwmlt.a].b[rwmlt.b].c[rwma]-1){
00173                                 for(ishortb=0;ishortb<pdb_a[rwmlt.a].b[rwmlt.b].c[rwma];ishortb++)
00174                                         { ln[rwmln-1].f[rwma].c[ishortb]='\0'; }
00175                                 }
00176                         if(rwma<pdb_a[rwmlt.a].b[rwmlt.b].f-1){
00177                                 for(ishorta=rwma;ishorta<pdb_a[rwmlt.a].b[rwmlt.b].f;ishorta++){
00178                                 for(ishortb=0;ishortb<pdb_a[rwmlt.a].b[rwmlt.b].c[ishorta];ishortb++){
00179                                         ln[rwmln-1].f[ishorta].c[ishortb]='\0';
00180                                         }}
00181                                 }
00182                         rwmb=pdb_a[rwmlt.a].b[rwmlt.b].c[rwma];
00183                         rwma=pdb_a[rwmlt.a].b[rwmlt.b].f;
00184                         }
00185                 if(ln[rwmln-1].f[rwma].c[rwmb]==EOF){
00186                         read_neek("EOF",(rwmln),(rwma+1));
00187                         }
00188                 itr++;
00189                 }
00190         ln[rwmln-1].f[rwma].c[rwmb]='\0';
00191         } 
00192 //if(DEBUG>=0){printf("rwm_line 13\n");}
00193 /*if((WARN==0)&&(SILENT!=0)){fflush(OUTC);} */
00194 return;
00195 }
00196 
 All Classes Files Functions Variables Typedefs Defines