Create a gist now

Instantly share code, notes, and snippets.

Daniel Spångberg's C code. See http://saml.rilspace.org/node/248
#include <stdio.h>
int main()
{
char buf[1000];
int gc=0;
int at=0;
FILE *f=fopen("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","r");
while (fgets(buf,1000,f))
if (*buf!='>') {
char c, *ptr=buf;
while ((c=*ptr++)) {
if ((c=='A') | (c=='T'))
at++;
else if ((c=='G') | (c=='C')) {
gc++;
}
}
}
fclose(f);
int total = at + gc;
printf("%.10f\n",(100.*gc)/total);
return 0;
}
@samuell
Owner
samuell commented May 10, 2013

Compile flags used:

gcc -O3 -march=core2 -o gc gc.c 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment