Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Last active July 13, 2017 17:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ismael-VC/b86f2d3f0ded2f61377c to your computer and use it in GitHub Desktop.
Save Ismael-VC/b86f2d3f0ded2f61377c to your computer and use it in GitHub Desktop.
GC Count
#!/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