Archive Ensembl HomeArchive Ensembl Home
Ditag.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003   Copyright (c) 1999-2012 The European Bioinformatics Institute and
00004   Genome Research Limited.  All rights reserved.
00005 
00006   This software is distributed under a modified Apache license.
00007   For license details, please see
00008 
00009     http://www.ensembl.org/info/about/code_licence.html
00010 
00011 =head1 CONTACT
00012 
00013   Please email comments or questions to the public Ensembl
00014   developers list at <dev@ensembl.org>.
00015 
00016   Questions may also be sent to the Ensembl help desk at
00017   <helpdesk@ensembl.org>.
00018 
00019 =cut
00020 
00021 =head1 NAME
00022 
00023 Bio::EnsEMBL::Map::Ditag
00024 
00025 =head1 SYNOPSIS
00026 
00027   my $feature = Bio::EnsEMBL::Map::Ditag->new(
00028     -dbID      => $tag_id,
00029     -name      => $name,
00030     -type      => $type,
00031     -tag_count => $tag_count,
00032     -sequence  => $sequence,
00033     -adaptor   => $dbAdaptor
00034   );
00035 
00036 =head1 DESCRIPTION
00037 
00038 Represents an unmapped ditag object in the EnsEMBL database.
00039 Corresponds to original tag containing the full sequence. This can be
00040 a single piece of sequence like CAGE tags or a ditag with concatenated
00041 sequence from 5' and 3' end like GIS or GSC tags.
00042 
00043 =head1 METHODS
00044 
00045 =cut
00046 
00047 package Bio::EnsEMBL::Map::Ditag;
00048 
00049 use strict;
00050 use vars qw(@ISA);
00051 
00052 use Bio::EnsEMBL::Storable;
00053 use Bio::EnsEMBL::Utils::Exception qw( throw );
00054 use Bio::EnsEMBL::Utils::Argument  qw( rearrange );
00055 
00056 @ISA = qw(Bio::EnsEMBL::Storable);
00057 
00058 
00059 =head2 new
00060 
00061   Arg [1]    : (optional) int $dbID
00062   Arg [2]    : (optional) string name
00063   Arg [3]    : (optional) string type
00064   Arg [4]    : (optional) int tag_count
00065   Arg [5]    : (optional) string sequence
00066   Arg [6]    : (optional) Bio::EnsEMBL::Map::DBSQL::DitagAdaptor $adaptor
00067 
00068   Description: Creates a new ditag
00069   Returntype : Bio::EnsEMBL::Map::Ditag
00070   Exceptions : none
00071   Caller     : general
00072 
00073 =cut
00074 
00075 sub new {
00076   my ($caller, @args) = @_;
00077   my ($dbID, $name, $type, $tag_count, $sequence, $adaptor) = rearrange(
00078       [ 'DBID', 'NAME', 'TYPE', 'TAG_COUNT', 'SEQUENCE', 'ADAPTOR' ], @args);
00079   my $class = ref($caller) || $caller;
00080 
00081   if(!$name or !$type or !$sequence) {
00082     throw('Missing information for Ditag object:
00083               Bio::EnsEMBL::Map::Ditag->new (
00084                                               -dbID      => $tag_id,
00085                                               -name      => $name,
00086                                               -type      => $type,
00087                                               -tag_count => $tag_count,
00088                                               -sequence  => $sequence,
00089                                               -adaptor   => $dbAdaptor
00090                                              );');
00091   }
00092 
00093   if(!$tag_count){ $tag_count = 0; }
00094 
00095   if(!($sequence =~ /^[ATCGN]+$/i)){
00096     throw('ditag sequence contains non-standard characters: '.$sequence);
00097   }
00098 
00099   my $self = bless( {'dbID'        => $dbID,
00100                      'name'        => $name,
00101                      'type'        => $type,
00102              'tag_count'   => $tag_count,
00103              'sequence'    => $sequence
00104                     }, $class);
00105 
00106   $self->adaptor($adaptor);
00107   return $self;
00108 }
00109 
00110 =head2 name
00111 
00112   Arg [1]    : (optional) string $type
00113   Example    : $type = $ditag->name;
00114   Description: Getter/Setter for the name of a ditag
00115   Returntype : text
00116   Caller     : general
00117 
00118 =cut
00119 
00120 sub name {
00121   my $self = shift;
00122 
00123   if(@_) {
00124     $self->{'name'} = shift;
00125   }
00126 
00127   return $self->{'name'};
00128 }
00129 
00130 =head2 dbID
00131 
00132   Arg [1]    : (optional) int id
00133   Example    : $ditag_id = $ditag->dbID;
00134   Description: Getter/Setter for the dbID of a ditag
00135   Returntype : int
00136   Caller     : general
00137 
00138 =cut
00139 
00140 sub dbID {
00141   my $self = shift;
00142 
00143   if(@_) {
00144     $self->{'dbID'} = shift;
00145   }
00146 
00147   return $self->{'dbID'};
00148 }
00149 
00150 
00151 =head2 type
00152 
00153   Arg [1]    : (optional) string $type
00154   Example    : $type = $ditag->type;
00155   Description: Getter/Setter for the type of a ditag
00156   Returntype : text
00157   Caller     : general
00158 
00159 =cut
00160 
00161 sub type {
00162   my $self = shift;
00163 
00164   if(@_) {
00165     $self->{'type'} = shift;
00166   }
00167 
00168   return $self->{'type'};
00169 }
00170 
00171 =head2 tag_count
00172 
00173   Arg [1]    : (optional) string $tag_count
00174   Example    : $type = $ditag->tag_count;
00175   Description: Getter/Setter for the tag_count of a ditag
00176   Returntype : int
00177   Caller     : general
00178 
00179 =cut
00180 
00181 sub tag_count {
00182   my $self = shift;
00183 
00184   if(@_) {
00185     $self->{'tag_count'} = shift;
00186   }
00187 
00188   return $self->{'tag_count'};
00189 }
00190 
00191 =head2 sequence
00192 
00193   Arg [1]    : (optional) string $sequence
00194   Example    : $sequence = $ditag->sequence;
00195   Description: Getter/Setter for the sequence of a ditag
00196   Returntype : text
00197   Caller     : general
00198 
00199 =cut
00200 
00201 sub sequence {
00202   my $self = shift;
00203 
00204   if(@_) {
00205     $self->{'sequence'} = shift;
00206   }
00207 
00208   return $self->{'sequence'};
00209 }
00210 
00211 
00212 =head2 get_ditagFeatures
00213 
00214   Arg        : none
00215   Example    : @features = @{$ditag->get_ditagFeatures};
00216   Description: Fetch ditag_features created from this ditag
00217   Returntype : listref of Bio::EnsEMBL::Map::DitagFeature
00218   Caller     : general
00219 
00220 =cut
00221 
00222 sub get_ditagFeatures {
00223   my $self = shift;
00224 
00225   return $self->adaptor->db->get_adaptor("ditagFeature")
00226           ->fetch_all_by_ditagID($self->dbID);
00227 }
00228 
00229 1;