Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (24 sloc) 0.669 kB
require "tempfile"
module Pearsons
def self.pearsons(rows, lower_bound=0.1)
if !block_given?
result = {}
pearsons(rows, lower_bound){|x, y, z| result[[x, y]] = z}
return result
end
data = Tempfile.new("data")
pearsons = Tempfile.new("output")
File.open(data.path, "w") do |o|
rows.each do |row|
o.puts row.join(" ");
end
end
%x{#{File.dirname(__FILE__)}/../pearsons < #{data.path} | awk '{if($3 > #{lower_bound}) print $0}' > #{pearsons.path}}
File.open(pearsons.path, "r") do |i|
i.each_line do |l|
x, y, p = l.split
yield(x, y, p.to_f)
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.