Archive Ensembl HomeArchive Ensembl Home
BaseWriter.pm
Go to the documentation of this file.
00001 #
00002 # You may distribute this module under the same terms as perl itself
00003 #
00004 
00005 =pod
00006 
00007 =head1 NAME
00008 
00009 Bio::EnsEMBL::Compara::Production::Projection::Writer::BaseWriter
00010 
00011 =head1 DESCRIPTION
00012 
00013 Base class for working with writers
00014 
00015 =head1 AUTHOR
00016 
00017 Andy Yates (ayatesatebiacuk)
00018 
00019 =head1 CONTACT
00020 
00021 This modules is part of the EnsEMBL project (http://www.ensembl.org)
00022 
00023 Questions can be posted to the dev mailing list: dev@ensembl.org
00024 
00025 =cut
00026 
00027 package Bio::EnsEMBL::Compara::Production::Projection::Writer::BaseWriter;
00028 
00029 use strict;
00030 use warnings;
00031 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00032 use Bio::EnsEMBL::Utils::Exception qw(throw);
00033 use Bio::EnsEMBL::Utils::Scalar qw(assert_ref);
00034 
00035 
00036 =head2 new()
00037 
00038   Arg[-projections] : required; 
00039   Description : New method used for a new instance of the given object. 
00040                 Required fields are indicated accordingly. Fields are specified
00041                 using the Arguments syntax (case insensitive).
00042 
00043 =cut
00044 
00045 sub new {
00046   my ( $class, @args ) = @_;
00047   my $self = bless( {}, ref($class) || $class );
00048   my ( $projections, ) = rearrange( [qw(projections )], @args );
00049 
00050   assert_ref( $projections, 'ARRAY' );
00051   confess(
00052 'The attribute projections must be specified during construction or provide a builder subroutine'
00053   ) if !defined $projections;
00054   $self->{projections} = $projections if defined $projections;
00055 
00056   return $self;
00057 }
00058 
00059 =head2 projections()
00060 
00061   Description : Getter. 
00062 
00063 =cut
00064 
00065 sub projections {
00066   my ($self) = @_;
00067   return $self->{projections};
00068 }
00069 
00070 =head2 write()
00071 
00072 The subroutine we call in order to write projection data out
00073 
00074 =cut
00075 
00076 sub write {
00077   my ($self) = @_;
00078   foreach my $p (@{$self->projections()}) {
00079     $self->write_projection($p);
00080   }
00081 }
00082 
00083 =head2 write_projection()
00084 
00085 The subroutine we call in order to write a single projection out 
00086 
00087 =cut
00088 
00089 sub write_projection {
00090   my ($self, $projection) = @_;
00091   throw('Not overriden in the implementing class');
00092 }
00093 
00094 1;