Last active
July 13, 2017 17:52
-
-
Save Ismael-VC/b86f2d3f0ded2f61377c to your computer and use it in GitHub Desktop.
GC Count
This file contains hidden or 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
#!/usr/bin/env julia | |
function gc_count(fasta::String) | |
file = open(fasta, "r") | |
lines = readall(file) | |
gc = at = 0 | |
for c in lines.data | |
if (c == 'G') || (c == 'C') | |
gc += 1 | |
elseif (c == 'A') || (c == 'T') | |
at += 1 | |
end | |
end | |
close(file) | |
gc_frac::Float64 = gc / (gc + at) | |
println("GC count: ", gc_frac) | |
end | |
function compile() | |
print("Compiling... ") | |
precompile(gc_count, (String,)) | |
println("Done!") | |
end | |
function main() | |
compile() | |
data = "Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa" | |
@time gc_count(data) | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment