Sha256: 522d52275c5961da545f7f4c7d4b63ee9d840c4256ba81f8c56a717e628c42d1

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

#!/usr/bin/env ruby
#
# An script to compare two 23andme SNP data files.
#
# Author: Preston Lee
# License: Apache 2

# Runtime libraries:
require 'erb'

# 3rd-party libraries:
require 'getopt/long'
require 'multimarkdown'

# Our libraries:
current_dir = File.dirname(File.expand_path(__FILE__))
gem_dir = File.join(current_dir, '..')
lib_path = File.join(gem_dir, 'lib')
$LOAD_PATH.unshift lib_path
require 'youandme'


def print_help_and_exit
	puts "Usage:"
	puts "\t#{$0} --directory <output_directory> --left <23andme_data_file.txt> --right <23andme_data_file.txt>"
	puts "\t#{$0} -d <output_directory> -l <23andme_data_file.txt> -r <23andme_data_file.txt>"
	exit(1)
end


begin
	opt = Getopt::Long.getopts(
	   ["--left", "-l", Getopt::REQUIRED],
	   ["--right", "-r", Getopt::REQUIRED],
	   ["--directory", "-d", Getopt::REQUIRED],
	   ["--help", "-h", Getopt::BOOLEAN]
	)
rescue
	print_help_and_exit
end



if(opt['help'])
	print_help_and_exit
end

puts "Checking data file existyness..."
loader = YouAndMe::RawDataFileLoader.new
left_file = opt['left']
right_file = opt['right']
unless(loader.check_file(left_file) and loader.check_file(right_file))
	puts "Please specify valid data files!"
	print_help_and_exit
end

puts "Parsing data files... (may take a while)"
max_rows = 0
left = loader.load_file(left_file, max_rows).sort{|a,b| a[:rsid] <=> b[:rsid]}
puts "\tLoaded #{left.length} SNPs from #{left_file}"
# y left[0..4]
right = loader.load_file(right_file, max_rows).sort{|a,b| a[:rsid] <=> b[:rsid]}
puts "\tLoaded #{right.length} SNPs from #{right_file}"
processor = YouAndMe::DataProcessor.new(left, right)
processor.process(true)


puts "Writing reports..."
processor.to_multimarkdown(left_file, right_file)
path = File.expand_path("#{opt['directory']}")
processor.write_multimarkdown(path)
processor.write_latex(path)
processor.write_html(path)


puts "Done!"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
youandme-0.2.2 bin/youandme
youandme-0.2.1 bin/youandme