Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import std.stdio;
import std.string;
import std.algorithm;
import std.regex;
void main() {
File file = File("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","r");
int gcCount = 0;
int atCount = 0;
int totalBaseCount = 0;
string line;
char c;
while (!file.eof()) {
line = file.readln();
if (line.length > 0 && !startsWith(line, ">")) {
for(uint i = 0; i < line.length; i++) {
c = line[i];
if (c == 'G' || c == 'C') {
gcCount++;
} else if ( c == 'A' || c == 'T' ) {
atCount++;
}
}
}
}
float gcFraction = ( cast(float)gcCount / cast(float)totalBaseCount );
writeln( gcFraction * 100 );
}
Owner
samuell commented May 10, 2013

Compile flags used:

dmd -ofgc_samuel -O -release -inline gc_samuel.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment