#!/usr/bin/perl -w
#<Logistic_regression.pl: Making input for Logistic_regression.R>
#Copyright (C) <2016>  <Ara Cho>

#This program 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.

#This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
use strict;

my $val_file = $ARGV[0];

open(V, $val_file) or die;
my %val = ();
while(<V>){
	my $line = $_; chomp $line;
	$val{$line} = "x";
} #while V
close(V);

my $input =  $ARGV[1];
my $output = $ARGV[2];
		
open(T, "> $output") or die;
open(I, $input) or die;
while(<I>){
	my $line = $_; chomp $line;
	my @ele = split /\t/, $line;
	if(exists$val{$ele[0]}){
		print T "$line\t1\n";
	}
	else{
		print T "$line\t0\n";
	}
} #while I
#		system "./Draw_logistic_regression.R $output";
#		my $output1 = $method."_".$nw."_".$type."-".$val_file.".txt";
#		my $output2 = $method."_".$nw."_".$type."-".$val_file."-reg.png";
#		my $output3 = $method."_".$nw."_".$type."-".$val_file."-hist.png";
#		my $output4 = $method."_".$nw."_".$type."-".$val_file.".png";
#		system "convert -append $output2 $output3 $output4";
#		system "rm $output2 $output3";
#		my $str_mv = "mv $output $output1 $output4 ./".$type;
#		system "$str_mv";
		close(I);
		close(T);


