Mercurial > repos > mahtabm > ensemb_rep_gvl
comparison variant_effect_predictor/Bio/Seq/RichSeq.pm @ 0:2bc9b66ada89 draft default tip
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 06:29:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2bc9b66ada89 |
---|---|
1 # $Id: RichSeq.pm,v 1.9 2002/11/11 18:16:31 lapp Exp $ | |
2 # | |
3 # BioPerl module for Bio::Seq::RichSeq | |
4 # | |
5 # Cared for by Ewan Birney <birney@ebi.ac.uk> | |
6 # | |
7 # Copyright Ewan Birney | |
8 # | |
9 # You may distribute this module under the same terms as perl itself | |
10 | |
11 # POD documentation - main docs before the code | |
12 | |
13 =head1 NAME | |
14 | |
15 Bio::Seq::RichSeq - Module implementing a sequence created from a rich | |
16 sequence database entry | |
17 | |
18 =head1 SYNOPSIS | |
19 | |
20 See Bio::Seq::RichSeqI and documentation of methods. | |
21 | |
22 =head1 DESCRIPTION | |
23 | |
24 This module implements Bio::Seq::RichSeqI, an interface for sequences | |
25 created from or created for entries from/of rich sequence databanks, | |
26 like EMBL, GenBank, and SwissProt. Methods added to the Bio::SeqI | |
27 interface therefore focus on databank-specific information. Note that | |
28 not every rich databank format may use all of the properties provided. | |
29 | |
30 =head1 Implemented Interfaces | |
31 | |
32 This class implementes the following interfaces. | |
33 | |
34 =over 4 | |
35 | |
36 =item Bio::Seq::RichSeqI | |
37 | |
38 Note that this includes implementing Bio::PrimarySeqI and Bio::SeqI. | |
39 | |
40 =item Bio::IdentifiableI | |
41 | |
42 =item Bio::DescribableI | |
43 | |
44 =item Bio::AnnotatableI | |
45 | |
46 =back | |
47 | |
48 =head1 FEEDBACK | |
49 | |
50 =head2 Mailing Lists | |
51 | |
52 User feedback is an integral part of the evolution of this | |
53 and other Bioperl modules. Send your comments and suggestions preferably | |
54 to one of the Bioperl mailing lists. | |
55 Your participation is much appreciated. | |
56 | |
57 bioperl-l@bioperl.org - General discussion | |
58 http://bio.perl.org/MailList.html - About the mailing lists | |
59 | |
60 =head2 Reporting Bugs | |
61 | |
62 Report bugs to the Bioperl bug tracking system to help us keep track | |
63 the bugs and their resolution. | |
64 Bug reports can be submitted via email or the web: | |
65 | |
66 bioperl-bugs@bio.perl.org | |
67 http://bugzilla.bioperl.org/ | |
68 | |
69 =head1 AUTHOR - Ewan Birney | |
70 | |
71 Email birney@ebi.ac.uk | |
72 | |
73 Describe contact details here | |
74 | |
75 =head1 APPENDIX | |
76 | |
77 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ | |
78 | |
79 =cut | |
80 | |
81 | |
82 # Let the code begin... | |
83 | |
84 | |
85 package Bio::Seq::RichSeq; | |
86 use vars qw($AUTOLOAD @ISA); | |
87 use strict; | |
88 | |
89 # Object preamble - inherits from Bio::Root::Object | |
90 | |
91 use Bio::Seq; | |
92 use Bio::Seq::RichSeqI; | |
93 | |
94 @ISA = qw(Bio::Seq Bio::Seq::RichSeqI); | |
95 | |
96 | |
97 =head2 new | |
98 | |
99 Title : new | |
100 Usage : $seq = Bio::Seq::RichSeq->new( -seq => 'ATGGGGGTGGTGGTACCCT', | |
101 -id => 'human_id', | |
102 -accession_number => 'AL000012', | |
103 ); | |
104 | |
105 Function: Returns a new seq object from | |
106 basic constructors, being a string for the sequence | |
107 and strings for id and accession_number | |
108 Returns : a new Bio::Seq::RichSeq object | |
109 | |
110 =cut | |
111 | |
112 sub new { | |
113 # standard new call.. | |
114 my($caller,@args) = @_; | |
115 my $self = $caller->SUPER::new(@args); | |
116 | |
117 $self->{'_dates'} = []; | |
118 $self->{'_secondary_accession'} = []; | |
119 | |
120 my ($dates, $xtra, $sv, | |
121 $keywords, $pid, $mol, | |
122 $division ) = $self->_rearrange([qw(DATES | |
123 SECONDARY_ACCESSIONS | |
124 SEQ_VERSION | |
125 KEYWORDS | |
126 PID | |
127 MOLECULE | |
128 DIVISION | |
129 )], | |
130 @args); | |
131 defined $division && $self->division($division); | |
132 defined $mol && $self->molecule($mol); | |
133 defined $keywords && $self->keywords($keywords); | |
134 defined $sv && $self->seq_version($sv); | |
135 defined $pid && $self->pid($pid); | |
136 | |
137 if( defined $dates ) { | |
138 if( ref($dates) =~ /array/i ) { | |
139 foreach ( @$dates) { | |
140 $self->add_date($_); | |
141 } | |
142 } else { | |
143 $self->add_date($dates); | |
144 } | |
145 } | |
146 | |
147 if( defined $xtra ) { | |
148 if( ref($xtra) =~ /array/i ) { | |
149 foreach ( @$xtra) { | |
150 $self->add_secondary_accession($_); | |
151 } | |
152 } else { | |
153 $self->add_secondary_accession($xtra); | |
154 } | |
155 } | |
156 | |
157 return $self; | |
158 } | |
159 | |
160 | |
161 =head2 division | |
162 | |
163 Title : division | |
164 Usage : $obj->division($newval) | |
165 Function: | |
166 Returns : value of division | |
167 Args : newvalue (optional) | |
168 | |
169 | |
170 =cut | |
171 | |
172 sub division { | |
173 my $obj = shift; | |
174 if( @_ ) { | |
175 my $value = shift; | |
176 $obj->{'_division'} = $value; | |
177 } | |
178 return $obj->{'_division'}; | |
179 | |
180 } | |
181 | |
182 =head2 molecule | |
183 | |
184 Title : molecule | |
185 Usage : $obj->molecule($newval) | |
186 Function: | |
187 Returns : type of molecule (DNA, mRNA) | |
188 Args : newvalue (optional) | |
189 | |
190 | |
191 =cut | |
192 | |
193 sub molecule { | |
194 my $obj = shift; | |
195 if( @_ ) { | |
196 my $value = shift; | |
197 $obj->{'_molecule'} = $value; | |
198 } | |
199 return $obj->{'_molecule'}; | |
200 | |
201 } | |
202 | |
203 =head2 add_date | |
204 | |
205 Title : add_date | |
206 Usage : $self->add_date($datestr) | |
207 Function: adds a date | |
208 Example : | |
209 Returns : a date string or an array of such strings | |
210 Args : | |
211 | |
212 | |
213 =cut | |
214 | |
215 sub add_date { | |
216 my ($self,@dates) = @_; | |
217 foreach my $dt ( @dates ) { | |
218 push(@{$self->{'_dates'}},$dt); | |
219 } | |
220 } | |
221 | |
222 =head2 get_dates | |
223 | |
224 Title : get_dates | |
225 Usage : | |
226 Function: | |
227 Example : | |
228 Returns : an array of date strings | |
229 Args : | |
230 | |
231 | |
232 =cut | |
233 | |
234 sub get_dates{ | |
235 my ($self) = @_; | |
236 return @{$self->{'_dates'}}; | |
237 } | |
238 | |
239 | |
240 =head2 pid | |
241 | |
242 Title : pid | |
243 Usage : | |
244 Function: Get (and set, depending on the implementation) the PID property | |
245 for the sequence. | |
246 Example : | |
247 Returns : a string | |
248 Args : | |
249 | |
250 | |
251 =cut | |
252 | |
253 sub pid { | |
254 my ($self,$pid) = @_; | |
255 | |
256 if(defined($pid)) { | |
257 $self->{'_pid'} = $pid; | |
258 } | |
259 return $self->{'_pid'}; | |
260 } | |
261 | |
262 | |
263 =head2 accession | |
264 | |
265 Title : accession | |
266 Usage : $obj->accession($newval) | |
267 Function: Whilst the underlying sequence object does not | |
268 have an accession, so we need one here. | |
269 | |
270 In this implementation this is merely a synonym for | |
271 accession_number(). | |
272 Example : | |
273 Returns : value of accession | |
274 Args : newvalue (optional) | |
275 | |
276 | |
277 =cut | |
278 | |
279 sub accession { | |
280 my ($obj,@args) = @_; | |
281 return $obj->accession_number(@args); | |
282 } | |
283 | |
284 =head2 add_secondary_accession | |
285 | |
286 Title : add_secondary_accession | |
287 Usage : $self->add_domment($ref) | |
288 Function: adds a secondary_accession | |
289 Example : | |
290 Returns : | |
291 Args : a string or an array of strings | |
292 | |
293 | |
294 =cut | |
295 | |
296 sub add_secondary_accession { | |
297 my ($self) = shift; | |
298 foreach my $dt ( @_ ) { | |
299 push(@{$self->{'_secondary_accession'}},$dt); | |
300 } | |
301 } | |
302 | |
303 =head2 get_secondary_accessions | |
304 | |
305 Title : get_secondary_accessions | |
306 Usage : | |
307 Function: | |
308 Example : | |
309 Returns : An array of strings | |
310 Args : | |
311 | |
312 | |
313 =cut | |
314 | |
315 sub get_secondary_accessions{ | |
316 my ($self,@args) = @_; | |
317 return @{$self->{'_secondary_accession'}}; | |
318 } | |
319 | |
320 =head2 seq_version | |
321 | |
322 Title : seq_version | |
323 Usage : $obj->seq_version($newval) | |
324 Function: | |
325 Example : | |
326 Returns : value of seq_version | |
327 Args : newvalue (optional) | |
328 | |
329 | |
330 =cut | |
331 | |
332 sub seq_version{ | |
333 my ($obj,$value) = @_; | |
334 if( defined $value) { | |
335 $obj->{'_seq_version'} = $value; | |
336 } | |
337 return $obj->{'_seq_version'}; | |
338 | |
339 } | |
340 | |
341 | |
342 =head2 keywords | |
343 | |
344 Title : keywords | |
345 Usage : $obj->keywords($newval) | |
346 Function: | |
347 Returns : value of keywords (a string) | |
348 Args : newvalue (optional) (a string) | |
349 | |
350 | |
351 =cut | |
352 | |
353 sub keywords { | |
354 my $obj = shift; | |
355 if( @_ ) { | |
356 my $value = shift; | |
357 $obj->{'_keywords'} = $value; | |
358 } | |
359 return $obj->{'_keywords'}; | |
360 | |
361 } | |
362 | |
363 # | |
364 ## | |
365 ### Deprecated methods kept for ease of transtion | |
366 ## | |
367 # | |
368 | |
369 sub each_date { | |
370 my ($self) = @_; | |
371 $self->warn("Deprecated method... please use get_dates"); | |
372 return $self->get_dates; | |
373 } | |
374 | |
375 | |
376 sub each_secondary_accession { | |
377 my ($self) = @_; | |
378 $self->warn("each_secondary_accession - deprecated method. use get_secondary_accessions"); | |
379 return $self->get_secondary_accessions; | |
380 | |
381 } | |
382 | |
383 sub sv { | |
384 my ($obj,$value) = @_; | |
385 $obj->warn("sv - deprecated method. use seq_version"); | |
386 $obj->seq_version($value); | |
387 } | |
388 | |
389 | |
390 1; |