/* Output from p2c, the Pascal-to-C translator */ /* From input file "cnvsinsq.p" */ #include "p2c.h" main(argc, argv) int argc; Char *argv[]; { /*Program reads one seq text a line at a time, and converts it to digital file to be used as input for bpexp2 or other versions of the bp neural net programs. This will make error space in sequences which are an even multiple of 9....*/ Char seq[3200000]; Char name[81]; long outpt, m, n, l; Char base; FILE *ifil, *ofil; long lngth; Char *TEMP; long FORLIM; PASCAL_MAIN(argc, argv); ofil = NULL; ifil = NULL; printf("Please give the name of the input file.\n"); fgets(name, 81, stdin); TEMP = strchr(name, '\n'); if (TEMP != NULL) *TEMP = 0; printf("Is the expected output 0 or 1?\n"); scanf("%ld%*[^\n]", &outpt); getchar(); /* p2c: cnvsinsq.p, line 20: * Warning: Symbol 'READONLY' is not defined [221] */ /* p2c: cnvsinsq.p, line 20: * Note: Ignoring block size in binary file [182] */ ifil = fopen(name, "r"); if (ifil == NULL) _EscIO(FileNotFound); rewind(ifil); printf("Enter length of sequence desired.\n"); scanf("%ld%*[^\n]", &lngth); getchar(); printf("Please give the name of the output file.\n"); fgets(name, 81, stdin); TEMP = strchr(name, '\n'); if (TEMP != NULL) *TEMP = 0; if (ofil != NULL) ofil = freopen(name, "r+", ofil); else ofil = fopen(name, "r+"); if (ofil == NULL) ofil = fopen(name, "w+"); if (ofil == NULL) _EscIO(FileNotFound); if (ofil != NULL) { /* p2c: cnvsinsq.p, line 27: Note: REWRITE does not specify a name [181] */ rewind(ofil); } else ofil = tmpfile(); if (ofil == NULL) _EscIO(FileNotFound); n = 0; while ((!P_eof(ifil)) & (!P_eoln(ifil))) { base = getc(ifil); if (base == '\n') base = ' '; n++; if (P_eoln(ifil)) { fscanf(ifil, "%*[^\n]"); getc(ifil); } } /*while*/ l = n; n = 0; rewind(ifil); FORLIM = l; for (n = 1; n <= FORLIM; n++) { base = getc(ifil); if (base == '\n') base = ' '; if (base == 'n') base = 'N'; if (base == 'a') base = 'A'; if (base == 'c') base = 'C'; if (base == 'g') base = 'G'; if (base == 't') base = 'T'; seq[n - 1] = base; if (P_eoln(ifil)) { fscanf(ifil, "%*[^\n]"); getc(ifil); } } m = 0; while (m <= (l-lngth+1)) { FORLIM = m + lngth; for (n = m + 1; n <= FORLIM; n++) { switch (seq[n - 1]) { case 'A': fprintf(ofil, "0 0 0 1 "); break; case 'C': fprintf(ofil, "0 0 1 0 "); break; case 'G': fprintf(ofil, "0 1 0 0 "); break; case 'N': fprintf(ofil, "0 0 0 0 "); break; case 'T': fprintf(ofil, "1 0 0 0 "); break; } if ((n-m) % 9 ==0) putc('\n',ofil); } m += lngth; if (lngth % 9 !=0) putc('\n', ofil); if (outpt == 1) fprintf(ofil, "1\n"); else fprintf(ofil, "0\n"); } /*while*/ if (ifil != NULL) fclose(ifil); ifil = NULL; if (ofil != NULL) fclose(ofil); ofil = NULL; if (ifil != NULL) fclose(ifil); if (ofil != NULL) fclose(ofil); exit(0); } /* End. */