/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "capsmark.p" */ #include /* capsmark: read sequence; make features for capitalized regions Tom Schneider NCI/FCRDC Bldg 469. Room 144 P.O. Box B Frederick, MD 21702-1201 (301) 846-5581 (-5532 for messages) toms@ncifcrf.gov http://www-lmmb.ncifcrf.gov/~toms/ National Cancer Institute Laboratory of Mathematical Biology */ /* end of program */ /* begin module version */ #define version 1.02 /* of capsmark.p 1997 October 17 origin 1997 October 17 */ #define updateversion 1.00 /* defines lowest acceptable current parameter file */ /* end module version */ /* begin module describe.capsmark */ /* name capsmark: read sequence; make features for capitalized regions synopsis capsmark(sequ: in, capsmarkp: in, searchp: out, output: out) files sequ: raw DNA sequence in lower case except for objects of interest marked in upper case. searchp: search parameters for the capitalized regions capsmarkp: parameters to control the program. The file must contain the following parameters, one per line: parameterversion: The version number of the program. This allows the user to be warned if an old parameter file is used. name: a string of characters to name the sequence. output: messages to the user description Sequences are often marked by people with capital letters to indicate interesting regions (exons, primers, mutations, etc) This program creates lister features for a raw sequence. examples documentation see also lister.p author Thomas Dana Schneider bugs technical notes */ /* end module describe.capsmark */ Static _TEXT sequ; /* file used by this program */ Static _TEXT capsmarkp; /* file used by this program */ Static _TEXT searchp; /* file used by this program */ Static jmp_buf _JL1; /* begin module halt */ Static Void halt() { /* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. */ printf(" program halt.\n"); longjmp(_JL1, 1); } /* end module halt version = 'delmod 6.16 84 mar 12 tds/gds'; */ /* begin module capitalize */ Static Char capitalize(c) Char c; { /* convert the character c to upper case */ long n = c; /* c is the n'th letter of the alphabet */ if (n >= 'a' && n <= 'z') c = _toupper(n); return c; } /* end module capitalize prgmod */ /* begin module decapitalize */ Static Char decapitalize(c) Char c; { /* convert the character c to lower case */ long n = c; /* c is the n'th letter of the alphabet */ if (n >= 'A' && n <= 'Z') c = _tolower(n); else c = (Char)n; return c; } #define maxnamelength 100 /* maximum length name */ /* end module decapitalize prgmod */ /* begin module capsmark.themain */ Static Void themain(sequ, capsmarkp, searchp) _TEXT *sequ, *capsmarkp, *searchp; { /* the main procedure of the program */ Char c; /* a character in the sequence */ Char name[maxnamelength]; /* name of the sequence */ long namelength = 0; /* length of the name */ long n; /* index to the name */ double parameterversion; /* parameter version number */ long position = 0; /* position in the sequence, starting with 1 */ boolean waslower = true; /* true if previous character was lower case */ printf("capsmark %4.2f\n", version); if (*capsmarkp->name != '\0') { if (capsmarkp->f != NULL) capsmarkp->f = freopen(capsmarkp->name, "r", capsmarkp->f); else capsmarkp->f = fopen(capsmarkp->name, "r"); } else rewind(capsmarkp->f); if (capsmarkp->f == NULL) _EscIO2(FileNotFound, capsmarkp->name); RESETBUF(capsmarkp->f, Char); fscanf(capsmarkp->f, "%lg%*[^\n]", ¶meterversion); getc(capsmarkp->f); if (parameterversion < updateversion) { printf("You have an old parameter file!\n"); halt(); } while (!P_eoln(capsmarkp->f)) { namelength++; name[namelength-1] = getc(capsmarkp->f); if (name[namelength-1] == '\n') name[namelength-1] = ' '; } if (*sequ->name != '\0') { if (sequ->f != NULL) sequ->f = freopen(sequ->name, "r", sequ->f); else sequ->f = fopen(sequ->name, "r"); } else rewind(sequ->f); if (sequ->f == NULL) _EscIO2(FileNotFound, sequ->name); RESETBUF(sequ->f, Char); if (*searchp->name != '\0') { if (searchp->f != NULL) searchp->f = freopen(searchp->name, "w", searchp->f); else searchp->f = fopen(searchp->name, "w"); } else { if (searchp->f != NULL) rewind(searchp->f); else searchp->f = tmpfile(); } if (searchp->f == NULL) _EscIO2(FileNotFound, searchp->name); SETUPBUF(searchp->f, Char); fprintf(searchp->f, "* capsmark %4.2f\n", version); while (!BUFEOF(sequ->f)) { if (P_eoln(sequ->f)) { /* end of line */ fscanf(sequ->f, "%*[^\n]"); getc(sequ->f); /* writeln(searchp) */ continue; } c = getc(sequ->f); if (c == '\n') c = ' '; if (c == 'n' || c == 't' || c == 'g' || c == 'c' || c == 'a') { position++; if (!waslower) /* upper case ending */ putc('\n', searchp->f); waslower = true; /* write(searchp, capitalize(c)); */ continue; } if (c != 'N' && c != 'T' && c != 'G' && c != 'C' && c != 'A') { printf("unidentified character: %c\n", c); continue; } position++; if (waslower) { /* begin upper case */ putc('"', searchp->f); for (n = 0; n < namelength; n++) putc(name[n], searchp->f); fprintf(searchp->f, ".%ld\"\n", position); } waslower = false; fputc(decapitalize(c), searchp->f); /* write(searchp, decapitalize(c)); */ } /* not end of line */ fprintf(searchp->f, "q\n"); /* searchfeatures: features for the lister program. To start the file, simply provide a name inside double quotes (eg "EcoRI"). Subsequent searches (eg gaattc) will be labeled with that name. To turn off the features, use an empty quote string, as "". The searchfeatures file can be concatenated with other features to create the features file for lister. */ } #undef maxnamelength /* end module capsmark.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; searchp.f = NULL; strcpy(searchp.name, "searchp"); capsmarkp.f = NULL; strcpy(capsmarkp.name, "capsmarkp"); sequ.f = NULL; strcpy(sequ.name, "sequ"); themain(&sequ, &capsmarkp, &searchp); _L1: if (sequ.f != NULL) fclose(sequ.f); if (capsmarkp.f != NULL) fclose(capsmarkp.f); if (searchp.f != NULL) fclose(searchp.f); exit(EXIT_SUCCESS); } /* End. */