#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;
use Getopt::Euclid;
use Expression;

my ($expression_file, $expression, $gene_ids_to_indices, $sample_ids_to_indices,
   $sample_annotations_file, $sample_ids_to_annotations, $sample_annotations_to_ids);
$expression_file = $ARGV{'-e'};
($expression, $gene_ids_to_indices, $sample_ids_to_indices) 
  = Expression::read($expression_file);
print("Read a gene expression data set with ", Expression::num_genes($expression),
	 " genes and ", Expression::num_samples($expression), " samples.\n");
$sample_annotations_file = $ARGV{'-s'};
if (defined($sample_annotations_file))
  {
    ($sample_ids_to_annotations, $sample_annotations_to_ids) 
	 = Expression::read_sample_annotations($sample_annotations_file);

    # print(Dumper($sample_ids_to_annotations));
    # print(Dumper($sample_annotations_to_ids));
    print("Read sample annotations for ", Expression::get_num_sample_annotations($sample_annotations_to_ids), " distinct annotations\n");
    print("The samples annotations are ", join(" ", @{Expression::get_distinct_sample_annotations($sample_annotations_to_ids)}), "\n");
    
  }

# for my $i (0 .. 500)
#   {
#     print($expression->[$i]->[1], "\n");
#   }
my ($gid, $sid);
$gid = "AFFX-BioB-5_at";
$sid = "25";

print("Expression value of gene $gid in sample $sid is ", Expression::get_value($expression, $gene_ids_to_indices, $sample_ids_to_indices, $gid, $sid), "\n");
print("Sample annotation for sample $sid is ", Expression::get_sample_annotation($sample_ids_to_annotations, $sid),
	 "\n");


__END__

=head1 NAME

lecture-05.pl

=head1 SYNOPSIS

lecture-05.pl -e <expression-file>

Reads <expression-file> and print some basic information about the
data. 

=head1 REQUIRED ARGUMENTS

=over

=item -e <expression-file>

=for Euclid:

expression-file.type: readable

=back

=head1 OPTIONS

=over

=item -s <sample-annotations-file>

=for Euclid:

sample-annotations-file.type: readable

=back

=cut
