#!/usr/bin/perl

use strict;
use warnings;

use Condition;

my ($condition1_file, $condition2_file, $mapping_file) = @ARGV;
my ($file, $condition1, $condition2, $mapping);
# read the genes from $condition1_file.
$condition1 = Condition::read_condition_genes($condition1_file);
# read the genes from $condition2_file.
$condition2 = Condition::read_condition_genes($condition2_file);

# read the mapping from $mapping_file (if it exists).
if (defined($mapping_file))
  {
    $mapping = Condition::read_mapping($mapping_file);
    $condition1 = Condition::map_gene_names($condition1, $mapping);
    $condition2 = Condition::map_gene_names($condition2, $mapping);
  }


# question 8. 
# my (@rapamycin_up, @heat_shock_up, $both_up, $only_rapamycin_up, $len);
# $len = 100;

# # @rapamycin_up = (1, 2, 3, 4);
# # @heat_shock_up = (3, 2, 5, 6, 7);
# for my $i (0 .. 10000)
#   {
#     $rapamycin_up[$i] = rand();
#     $heat_shock_up[$i] = rand();
#   }

# perform the comparison.
my ($both, $only_condition1) = 
  # pass the references to the two arrays.
  #
  # use the fully qualified name of the subroutine.
  Condition::condition_compare($condition1, $condition2);
print("There are ", scalar(@$both), " genes in both arrays.\n");
print("There are ", scalar(@$only_condition1), " genes only in condition 1.\n");
print("both contains ", join(" ", @$both), "\n");
print("only_condition1 contains ", join(" ", @$only_condition1, "\n"));


