This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile flags used: