Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/DB/UpdateableSeqI.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 # | |
2 # $Id: UpdateableSeqI.pm,v 1.6 2002/12/01 00:05:19 jason Exp $ | |
3 # | |
4 # BioPerl module for Bio::DB::UpdateableSeqI | |
5 # | |
6 # Cared for by Jason Stajich <jason@bioperl.org> | |
7 # | |
8 # Copyright Jason Stajich | |
9 # | |
10 # You may distribute this module under the same terms as perl itself | |
11 # | |
12 # _history | |
13 # June 18, 2000 - module begun | |
14 # | |
15 # POD Doc - main docs before code | |
16 | |
17 =head1 NAME | |
18 | |
19 Bio::DB::UpdateableSeqI - An interface for writing to a database of sequences. | |
20 | |
21 =head1 SYNOPSIS | |
22 | |
23 # get a Bio::DB::UpdateableSeqI somehow | |
24 eval { | |
25 my ( @updatedseqs, @newseqs, @deadseqs); | |
26 my $seq = $db->get_Seq_by_id('ROA1_HUMAN'); | |
27 $seq->desc('a new description'); | |
28 | |
29 push @updatedseqs, $seq; | |
30 | |
31 $db->write_seq(\@updatedseqs, \@newseqs, \@deadseqs); | |
32 }; | |
33 if( $@ ) { | |
34 print STDERR "an error when trying to write seq : $@\n"; | |
35 } | |
36 | |
37 =head1 DESCRIPTION | |
38 | |
39 This module seeks to provide a simple method for pushing sequence changes | |
40 back to a Sequence Database - which can be an SQL compliant database, a file | |
41 based database, AceDB, etc. | |
42 | |
43 =head1 AUTHOR | |
44 | |
45 Jason Stajich E<lt>jason@bioperl.orgE<gt> | |
46 | |
47 =head2 Reporting Bugs | |
48 | |
49 Report bugs to the Bioperl bug tracking system to help us keep track | |
50 the bugs and their resolution. Bug reports can be submitted via email | |
51 or the web: | |
52 | |
53 bioperl-bugs@bioperl.org | |
54 http://bugzilla.bioperl.org/ | |
55 | |
56 =head1 APPENDIX | |
57 | |
58 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ | |
59 | |
60 =cut | |
61 | |
62 #Lets start some code | |
63 | |
64 package Bio::DB::UpdateableSeqI; | |
65 | |
66 use strict; | |
67 | |
68 use vars qw( @ISA ); | |
69 | |
70 use Bio::DB::SeqI; | |
71 | |
72 @ISA = qw(Bio::DB::SeqI); | |
73 | |
74 =head2 write_seq | |
75 | |
76 Title : write_seq | |
77 Usage : write_seq(\@updatedseqs, \@addedseqs, \@deadseqs) | |
78 Function: updates sequences in first array, | |
79 adds sequences in the second array, | |
80 and removes sequences in the third array. | |
81 Example : | |
82 Returns : | |
83 Args : arrays of sequence objects that must be obtained from | |
84 Bio::DB::UpdateableSeqI. | |
85 | |
86 =cut | |
87 | |
88 sub write_seq { | |
89 my ($self) = @_; | |
90 | |
91 $self->throw("Abstract database call of write_seq. Your database has not implemented this method!"); | |
92 | |
93 } | |
94 | |
95 =head2 _add_seq | |
96 | |
97 Title : _add_seq | |
98 Usage : _add_seq($seq) | |
99 Function: Adds a new sequence | |
100 Example : | |
101 Returns : will throw an exception if | |
102 sequences accession number already exists | |
103 Args : a new seq object - should have an accession number | |
104 | |
105 =cut | |
106 | |
107 sub _add_seq { | |
108 my ($self ) = @_; | |
109 | |
110 $self->throw("Abstract database call of _add_seq. Your database has not implemented this method!"); | |
111 | |
112 } | |
113 | |
114 =head2 _remove_seq | |
115 | |
116 Title : _remove_seq | |
117 Usage : _remove_seq($seq) | |
118 Function: Removes an existing sequence | |
119 Example : | |
120 Returns : will throw an exception if | |
121 sequence does not exists for the primary_id | |
122 Args : a seq object that was retrieved from Bio::DB::UpdateableSeqI | |
123 | |
124 =cut | |
125 | |
126 sub _remove_seq { | |
127 my ($self) = @_; | |
128 | |
129 $self->throw("Abstract database call of _remove_seq. Your database has not implemented this method!"); | |
130 | |
131 } | |
132 | |
133 =head2 _update_seq | |
134 | |
135 Title : _update_seq | |
136 Usage : _update_seq($seq) | |
137 Function: Updates a sequence | |
138 Example : | |
139 Returns : will throw an exception if | |
140 sequence is out of sync from expected val. | |
141 Args : a seq object that was retrieved from Bio::DB::UpdateableSeqI | |
142 | |
143 =cut | |
144 | |
145 sub _update_seq { | |
146 my ($self) = @_; | |
147 | |
148 $self->throw("Abstract database call of _update_seq. Your database has not implemented this method!"); | |
149 | |
150 } | |
151 | |
152 | |
153 =head1 Methods inherieted from Bio::DB::RandomAccessI | |
154 | |
155 =head2 get_Seq_by_id | |
156 | |
157 Title : get_Seq_by_id | |
158 Usage : $seq = $db->get_Seq_by_id('ROA1_HUMAN') | |
159 Function: Gets a Bio::Seq object by its name | |
160 Returns : a Bio::Seq object | |
161 Args : the id (as a string) of a sequence | |
162 Throws : "id does not exist" exception | |
163 | |
164 | |
165 =cut | |
166 | |
167 =head2 get_Seq_by_acc | |
168 | |
169 Title : get_Seq_by_acc | |
170 Usage : $seq = $db->get_Seq_by_acc('X77802'); | |
171 Function: Gets a Bio::Seq object by accession number | |
172 Returns : A Bio::Seq object | |
173 Args : accession number (as a string) | |
174 Throws : "acc does not exist" exception | |
175 | |
176 | |
177 =cut | |
178 | |
179 =head1 Methods inheirited from Bio::DB::SeqI | |
180 | |
181 =head2 get_PrimarySeq_stream | |
182 | |
183 Title : get_PrimarySeq_stream | |
184 Usage : $stream = get_PrimarySeq_stream | |
185 Function: Makes a Bio::DB::SeqStreamI compliant object | |
186 which provides a single method, next_primary_seq | |
187 Returns : Bio::DB::SeqStreamI | |
188 Args : none | |
189 | |
190 | |
191 =cut | |
192 | |
193 =head2 get_all_primary_ids | |
194 | |
195 Title : get_all_ids | |
196 Usage : @ids = $seqdb->get_all_primary_ids() | |
197 Function: gives an array of all the primary_ids of the | |
198 sequence objects in the database. These | |
199 maybe ids (display style) or accession numbers | |
200 or something else completely different - they | |
201 *are not* meaningful outside of this database | |
202 implementation. | |
203 Example : | |
204 Returns : an array of strings | |
205 Args : none | |
206 | |
207 | |
208 =cut | |
209 | |
210 =head2 get_Seq_by_primary_id | |
211 | |
212 Title : get_Seq_by_primary_id | |
213 Usage : $seq = $db->get_Seq_by_primary_id($primary_id_string); | |
214 Function: Gets a Bio::Seq object by the primary id. The primary | |
215 id in these cases has to come from $db->get_all_primary_ids. | |
216 There is no other way to get (or guess) the primary_ids | |
217 in a database. | |
218 | |
219 The other possibility is to get Bio::PrimarySeqI objects | |
220 via the get_PrimarySeq_stream and the primary_id field | |
221 on these objects are specified as the ids to use here. | |
222 Returns : A Bio::Seq object | |
223 Args : accession number (as a string) | |
224 Throws : "acc does not exist" exception | |
225 | |
226 | |
227 =cut | |
228 | |
229 1; | |
230 | |
231 | |
232 |