#!/usr/bin/perl

use strict;
use warnings;

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

use ExpressionOO;


my ($expression, $expression_file, $sample_annotations_file);

$expression = Expression::new();
print("expression is a reference to ", ref($expression), "\n");
print("expression is ", $expression, "\n");


$expression_file = $ARGV{'-e'};
# Perl will invoke this code as ref($expression)::read($expression, $expression_file)
$expression->read($expression_file);
print("Read a gene expression data set with ", $expression->num_genes,
	 " genes and ", $expression->num_samples, " samples.\n");
$sample_annotations_file = $ARGV{'-s'};
if (defined($sample_annotations_file))
  {
    $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, " distinct annotations\n");
    print("The samples annotations are ", join(" ", @{$expression->get_distinct_sample_annotations()}), "\n");
  }

my ($gid, $sid);
$gid = "AFFX-BioB-5_at";
$sid = "25";

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

my $annotation = "AML";
my $number = $expression->get_num_samples_for_annotation($annotation);
print("Annotation $annotation has $number samples.\n");
print("The samples associated with annotation $annotation are ",
	 Dumper($expression->get_samples_for_annotation($annotation)));


__END__

=head1 NAME

lecture-08.pl: introduce basis of object-oriented programming in Perl.

=head1 SYNOPSIS

lecture-08.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
