Skip to content

Instantly share code, notes, and snippets.

@raphink
Created July 30, 2018 17:17
Show Gist options
  • Save raphink/2c1e37bca4b2e7706dfb19f12998462e to your computer and use it in GitHub Desktop.
Save raphink/2c1e37bca4b2e7706dfb19f12998462e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'csv'
FILE1, FILE2, FILE3 = ARGV
HEADER = [ 'RSID', 'CHROMOSOME' , 'POSITION' , 'RESULT' ]
def phase(file1, file2)
csv1 = CSV.read(file1)[1..-1]
csv2 = CSV.read(file2)[1..-1]
csv1.each_with_index.map do |l, i|
l[3] = (l[3].split('') & csv2[i][3].split('')).join.ljust(2, '-')
l
end
end
CSV.open(FILE3, 'w') do |csv|
csv << HEADER
phase(FILE1, FILE2).each do |l|
csv << l
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment