ensembl-hive  2.8.1
Ditag.pm
Go to the documentation of this file.
1 =head1 LICENSE
2 
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5 
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 
18 =cut
19 
20 
21 =head1 CONTACT
22 
23  Please email comments or questions to the public Ensembl
24  developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25 
26  Questions may also be sent to the Ensembl help desk at
27  <http://www.ensembl.org/Help/Contact>.
28 
29 =cut
30 
31 =head1 NAME
32 
34 
35 =head1 SYNOPSIS
36 
37  my $feature = Bio::EnsEMBL::Map::Ditag->new(
38  -dbID => $tag_id,
39  -name => $name,
40  -type => $type,
41  -tag_count => $tag_count,
42  -sequence => $sequence,
43  -adaptor => $dbAdaptor
44  );
45 
46 =head1 DESCRIPTION
47 
48 Represents an unmapped ditag object in the EnsEMBL database.
49 Corresponds to original tag containing the full sequence. This can be
50 a single piece of sequence like CAGE tags or a ditag with concatenated
51 sequence from 5' and 3' end like GIS or GSC tags.
52 
53 =head1 METHODS
54 
55 =cut
56 
57 package Bio::EnsEMBL::Map::Ditag;
58 
59 use strict;
60 use vars qw(@ISA);
61 
63 use Bio::EnsEMBL::Utils::Exception qw( throw );
64 use Bio::EnsEMBL::Utils::Argument qw( rearrange );
65 
66 @ISA = qw(Bio::EnsEMBL::Storable);
67 
68 
69 =head2 new
70 
71  Arg [1] : (optional) int $dbID
72  Arg [2] : (optional) string name
73  Arg [3] : (optional) string type
74  Arg [4] : (optional) int tag_count
75  Arg [5] : (optional) string sequence
76  Arg [6] : (optional) Bio::EnsEMBL::Map::DBSQL::DitagAdaptor $adaptor
77 
78  Description: Creates a new ditag
79  Returntype : Bio::EnsEMBL::Map::Ditag
80  Exceptions : none
81  Caller : general
82 
83 =cut
84 
85 sub new {
86  my ($caller, @args) = @_;
87  my ($dbID, $name, $type, $tag_count, $sequence, $adaptor) = rearrange(
88  [ 'DBID', 'NAME', 'TYPE', 'TAG_COUNT', 'SEQUENCE', 'ADAPTOR' ], @args);
89  my $class = ref($caller) || $caller;
90 
91  if(!$name or !$type or !$sequence) {
92  throw('Missing information for Ditag object:
93  Bio::EnsEMBL::Map::Ditag->new (
94  -dbID => $tag_id,
95  -name => $name,
96  -type => $type,
97  -tag_count => $tag_count,
98  -sequence => $sequence,
99  -adaptor => $dbAdaptor
100  );');
101  }
102 
103  if(!$tag_count){ $tag_count = 0; }
104 
105  if(!($sequence =~ /^[ATCGN]+$/i)){
106  throw('ditag sequence contains non-standard characters: '.$sequence);
107  }
108 
109  my $self = bless( {'dbID' => $dbID,
110  'name' => $name,
111  'type' => $type,
112  'tag_count' => $tag_count,
113  'sequence' => $sequence
114  }, $class);
115 
116  $self->adaptor($adaptor);
117  return $self;
118 }
119 
120 =head2 name
121 
122  Arg [1] : (optional) string $type
123  Example : $type = $ditag->name;
124  Description: Getter/Setter for the name of a ditag
125  Returntype : text
126  Caller : general
127 
128 =cut
129 
130 sub name {
131  my $self = shift;
132 
133  if(@_) {
134  $self->{'name'} = shift;
135  }
136 
137  return $self->{'name'};
138 }
139 
140 =head2 dbID
141 
142  Arg [1] : (optional) int id
143  Example : $ditag_id = $ditag->dbID;
144  Description: Getter/Setter for the dbID of a ditag
145  Returntype : int
146  Caller : general
147 
148 =cut
149 
150 sub dbID {
151  my $self = shift;
152 
153  if(@_) {
154  $self->{'dbID'} = shift;
155  }
156 
157  return $self->{'dbID'};
158 }
159 
160 
161 =head2 type
162 
163  Arg [1] : (optional) string $type
164  Example : $type = $ditag->type;
165  Description: Getter/Setter for the type of a ditag
166  Returntype : text
167  Caller : general
168 
169 =cut
170 
171 sub type {
172  my $self = shift;
173 
174  if(@_) {
175  $self->{'type'} = shift;
176  }
177 
178  return $self->{'type'};
179 }
180 
181 =head2 tag_count
182 
183  Arg [1] : (optional) string $tag_count
184  Example : $type = $ditag->tag_count;
185  Description: Getter/Setter for the tag_count of a ditag
186  Returntype : int
187  Caller : general
188 
189 =cut
190 
191 sub tag_count {
192  my $self = shift;
193 
194  if(@_) {
195  $self->{'tag_count'} = shift;
196  }
197 
198  return $self->{'tag_count'};
199 }
200 
201 =head2 sequence
202 
203  Arg [1] : (optional) string $sequence
204  Example : $sequence = $ditag->sequence;
205  Description: Getter/Setter for the sequence of a ditag
206  Returntype : text
207  Caller : general
208 
209 =cut
210 
211 sub sequence {
212  my $self = shift;
213 
214  if(@_) {
215  $self->{'sequence'} = shift;
216  }
217 
218  return $self->{'sequence'};
219 }
220 
221 
222 =head2 get_ditagFeatures
223 
224  Arg : none
225  Example : @features = @{$ditag->get_ditagFeatures};
226  Description: Fetch ditag_features created from this ditag
227  Returntype : listref of Bio::EnsEMBL::Map::DitagFeature
228  Caller : general
229 
230 =cut
231 
232 sub get_ditagFeatures {
233  my $self = shift;
234 
235  return $self->adaptor->db->get_adaptor("ditagFeature")
236  ->fetch_all_by_ditagID($self->dbID);
237 }
238 
239 1;
EnsEMBL
Definition: Filter.pm:1
Bio::EnsEMBL::Map::DBSQL::DitagAdaptor
Definition: DitagAdaptor.pm:20
Bio::EnsEMBL::Storable
Definition: Storable.pm:23
Bio::EnsEMBL::Map::DitagFeature
Definition: DitagFeature.pm:35
Bio::EnsEMBL::Map::Ditag::new
public Bio::EnsEMBL::Map::Ditag new()
Bio::EnsEMBL::DBSQL::BaseAdaptor::db
public Bio::EnsEMBL::DBSQL::DBAdaptor db()
Bio::EnsEMBL::Map::Ditag
Definition: Ditag.pm:28
Bio::EnsEMBL::Utils::Argument
Definition: Argument.pm:34
Bio::EnsEMBL::DBSQL::DBAdaptor::get_adaptor
public Adaptor get_adaptor()
Bio::EnsEMBL::Utils::Exception
Definition: Exception.pm:68
Bio::EnsEMBL::Storable::adaptor
public Bio::EnsEMBL::DBSQL::BaseAdaptor adaptor()