Created
July 30, 2018 17:17
-
-
Save raphink/2c1e37bca4b2e7706dfb19f12998462e to your computer and use it in GitHub Desktop.
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 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