~ubuntu-branches/ubuntu/edgy/bioperl/edgy

« back to all changes in this revision

Viewing changes to Bio/DB/UpdateableSeqI.pm

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2002-03-20 01:16:30 UTC
  • Revision ID: james.westby@ubuntu.com-20020320011630-wyvmxwc7o5bi4665
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# $Id: UpdateableSeqI.pm,v 1.4 2001/06/18 08:27:51 heikki Exp $
 
3
#
 
4
# BioPerl module for Bio::DB::UpdateableSeqI
 
5
#
 
6
# Cared for by Jason Stajich <jason@chg.mc.duke.edu>
 
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@chg.mc.duke.eduE<gt>
 
46
 
 
47
=head2 Reporting Bugs
 
48
 
 
49
Report bugs to the Bioperl bug tracking system to help us keep track the bugs and 
 
50
their resolution. Bug reports can be submitted via email or the web:
 
51
 
 
52
    bioperl-bugs@bioperl.org                   
 
53
    http://www.bioperl.org/bioperl-bugs/           
 
54
 
 
55
=head1 APPENDIX
 
56
 
 
57
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
 
58
 
 
59
=cut
 
60
 
 
61
#Lets start some code
 
62
 
 
63
package Bio::DB::UpdateableSeqI;
 
64
 
 
65
use strict;
 
66
 
 
67
use vars qw( @ISA );
 
68
 
 
69
use Bio::DB::SeqI;
 
70
 
 
71
@ISA = qw(Bio::DB::SeqI);
 
72
 
 
73
=head2 write_seq
 
74
 
 
75
  Title   : write_seq
 
76
  Usage   : write_seq(\@updatedseqs, \@addedseqs, \@deadseqs)
 
77
  Function: updates sequences in first array,
 
78
            adds sequences in the second array,
 
79
            and removes sequences in the third array.
 
80
  Example :
 
81
  Returns :
 
82
  Args    : arrays of sequence objects that must be obtained from
 
83
            Bio::DB::UpdateableSeqI.
 
84
 
 
85
=cut
 
86
 
 
87
sub write_seq {
 
88
    my ($self) = @_;
 
89
    
 
90
    $self->throw("Abstract database call of write_seq. Your database has not implemented this method!");
 
91
 
 
92
}
 
93
 
 
94
=head2 _add_seq
 
95
 
 
96
 Title   : _add_seq
 
97
 Usage   : _add_seq($seq)
 
98
 Function: Adds a new sequence
 
99
 Example : 
 
100
 Returns : will throw an exception if
 
101
           sequences accession number already exists
 
102
 Args    : a new seq object - should have an accession number
 
103
 
 
104
=cut
 
105
 
 
106
sub _add_seq {
 
107
    my ($self ) = @_;
 
108
    
 
109
    $self->throw("Abstract database call of _add_seq. Your database has not implemented this method!");
 
110
 
 
111
}
 
112
 
 
113
=head2 _remove_seq
 
114
 
 
115
 Title   : _remove_seq
 
116
 Usage   : _remove_seq($seq)
 
117
 Function: Removes an existing sequence
 
118
 Example : 
 
119
 Returns : will throw an exception if
 
120
           sequence does not exists for the primary_id
 
121
 Args    : a seq object that was retrieved from Bio::DB::UpdateableSeqI
 
122
 
 
123
=cut
 
124
 
 
125
sub _remove_seq {
 
126
    my ($self) = @_;
 
127
    
 
128
    $self->throw("Abstract database call of _remove_seq. Your database has not implemented this method!");
 
129
 
 
130
}
 
131
 
 
132
=head2 _update_seq
 
133
 
 
134
 Title   : _update_seq
 
135
 Usage   : _update_seq($seq)
 
136
 Function: Updates a sequence
 
137
 Example : 
 
138
 Returns : will throw an exception if
 
139
           sequence is out of sync from expected val.
 
140
 Args    : a seq object that was retrieved from Bio::DB::UpdateableSeqI
 
141
 
 
142
=cut
 
143
 
 
144
sub _update_seq {
 
145
    my ($self) = @_;
 
146
    
 
147
    $self->throw("Abstract database call of _update_seq. Your database has not implemented this method!");
 
148
 
 
149
}
 
150
 
 
151
 
 
152
=head1 Methods inherieted from Bio::DB::RandomAccessI
 
153
 
 
154
=head2 get_Seq_by_id
 
155
 
 
156
 Title   : get_Seq_by_id
 
157
 Usage   : $seq = $db->get_Seq_by_id('ROA1_HUMAN')
 
158
 Function: Gets a Bio::Seq object by its name
 
159
 Returns : a Bio::Seq object
 
160
 Args    : the id (as a string) of a sequence
 
161
 Throws  : "id does not exist" exception
 
162
 
 
163
 
 
164
=cut
 
165
 
 
166
=head2 get_Seq_by_acc
 
167
 
 
168
 Title   : get_Seq_by_acc
 
169
 Usage   : $seq = $db->get_Seq_by_acc('X77802');
 
170
 Function: Gets a Bio::Seq object by accession number
 
171
 Returns : A Bio::Seq object
 
172
 Args    : accession number (as a string)
 
173
 Throws  : "acc does not exist" exception
 
174
 
 
175
 
 
176
=cut
 
177
 
 
178
=head1 Methods inheirited from Bio::DB::SeqI
 
179
 
 
180
=head2 get_PrimarySeq_stream
 
181
 
 
182
 Title   : get_PrimarySeq_stream
 
183
 Usage   : $stream = get_PrimarySeq_stream
 
184
 Function: Makes a Bio::DB::SeqStreamI compliant object
 
185
           which provides a single method, next_primary_seq
 
186
 Returns : Bio::DB::SeqStreamI
 
187
 Args    : none
 
188
 
 
189
 
 
190
=cut
 
191
 
 
192
=head2 get_all_primary_ids
 
193
 
 
194
 Title   : get_all_ids
 
195
 Usage   : @ids = $seqdb->get_all_primary_ids()
 
196
 Function: gives an array of all the primary_ids of the 
 
197
           sequence objects in the database. These
 
198
           maybe ids (display style) or accession numbers
 
199
           or something else completely different - they
 
200
           *are not* meaningful outside of this database
 
201
           implementation.
 
202
 Example :
 
203
 Returns : an array of strings
 
204
 Args    : none
 
205
 
 
206
 
 
207
=cut
 
208
 
 
209
=head2 get_Seq_by_primary_id
 
210
 
 
211
 Title   : get_Seq_by_primary_id
 
212
 Usage   : $seq = $db->get_Seq_by_primary_id($primary_id_string);
 
213
 Function: Gets a Bio::Seq object by the primary id. The primary
 
214
           id in these cases has to come from $db->get_all_primary_ids.
 
215
           There is no other way to get (or guess) the primary_ids
 
216
           in a database.
 
217
 
 
218
           The other possibility is to get Bio::PrimarySeqI objects
 
219
           via the get_PrimarySeq_stream and the primary_id field
 
220
           on these objects are specified as the ids to use here.
 
221
 Returns : A Bio::Seq object
 
222
 Args    : accession number (as a string)
 
223
 Throws  : "acc does not exist" exception
 
224
 
 
225
 
 
226
=cut
 
227
 
 
228
1;
 
229
 
 
230
 
 
231