Aug-29-2018, 12:21 PM
(This post was last modified: Aug-29-2018, 12:35 PM by Gribouillis.)
I suggest to convert the file externally by a C program for speed
#include<stdio.h> #include<stdlib.h> #include<ctype.h> /* This is a C program */ int main() { FILE *fp1, *fp2; char ch; fp1 = fopen("source.txt", "r"); if (fp1 == NULL) { puts("Cannot open source.txt"); exit(1); } fp2 = fopen("target.txt", "w"); if (fp2 == NULL) { puts("Cannot open target.txt"); fclose(fp1); exit(1); } while((ch=fgetc(fp1))!=EOF) { switch(ch){ case 'a': case 'c': case 'g': case 't': case 'A': case 'C': case 'G': case 'T': ch = toupper(ch); fputc(ch,fp2); } } printf("File successfully converted.\n"); return 0; }Edit: Actually, using fgetc() is much slower than using fread(). This can be improved a lot but on my computer it takes only 0.1 second for 10 MB..