gc=0
total=0
f=File.open("/tmp/test.fasta")
while l= f.gets
l=l.to_s
if l[0] != '>'
gc += l.count("GC")
total += l.size()
end
end
print gc.to_f/total, " ", gc, " ", total, "\n"
Crystal ではこっちが速い
gc=0
total=0
f=File.open("/tmp/test.fasta")
while l= f.gets
l=l.to_s
if l[0] != '>'
l.each_char{|x|
gc+= 1 if x == 'C' || x== 'G'
total += 1
}
end
end
print gc.to_f/total, "\n"
• • •
Missing some Tweet in this thread? You can try to
force a refresh