#!/usr/bin/env python

# Copyright (C) 2011-2012 CRS4.
#
# This file is part of Seal.
#
# Seal is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Seal is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with Seal.  If not, see <http://www.gnu.org/licenses/>.

#########################################################
# You need a working Hadoop cluster to use this.
#########################################################


import site
import os
import sys

IntegrationTestDir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".."))
site.addsitedir(IntegrationTestDir)

from seal_integration_test import SealIntegrationTest
import pydoop.hdfs as hdfs

class TestRecabSmallSnps(SealIntegrationTest):
	def __init__(self):
		super(TestRecabSmallSnps, self).__init__( os.path.realpath(os.path.dirname(__file__)) )

	def setup(self):
		super(TestRecabSmallSnps, self).setup()
		hdfs.put(os.path.join(self.test_dir, "chr1.vcf"), self.make_hdfs_test_path())

	def run_program(self, hdfs_input, hdfs_output):
		self.run_cmd_and_output_if_failure([
		  "%s/scripts/seal" % self.seal_dir, "recab_table",
		  "-D", "seal.recab.skip-known-variant-sites=true",
		  "-D", "seal.recab.snps-only=false",
		  "-D", "seal.recab.smoothing=0",
		  "--vcf", os.path.join(self.make_hdfs_test_path(),  "chr1.vcf"),
		  hdfs_input, hdfs_output])

if __name__ == '__main__':
	success = TestRecabSmallSnps().test_method()
	sys.exit( 0 if success else 1 )
