~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to Bio/DB/HIV/HIVAnnotProcessor.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: HIVAnnotProcessor.pm 221 2008-12-11 13:05:24Z maj $
 
2
#
 
3
# BioPerl module for HIVAnnotProcessor
 
4
#
 
5
# Cared for by Mark A. Jensen <maj@fortinbras.us>
 
6
#
 
7
# Copyright Mark A. Jensen
 
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
HIVAnnotProcessor - Adds HIV-specific annotations to Bio::SeqIO streams
 
16
 
 
17
=head1 SYNOPSIS
 
18
 
 
19
   sub get_Stream_by_query {
 
20
       my ($self, $query ) = @_;
 
21
       my $stream = $self->get_seq_stream('-query' => $query, '-mode'=>'query');
 
22
       return new Bio::DB::HIV::HIVAnnotProcessor( -hiv_query=>$query, 
 
23
                                                   -source_stream=>$stream );
 
24
   }
 
25
 
 
26
 
 
27
=head1 DESCRIPTION
 
28
 
 
29
Bio::DB::HIV::HIVAnnotProcessor is chained to the C<next_seq> of a sequence stream returned from a query to the Los Alamos HIV sequence database made using L<Bio::DB::HIV> and L<Bio::DB::Query::HIVQuery>. It adds the annotations obtained in the C<Bio::DB::Query::HIVQuery> to the Bio::Seq objects themselves via the C<$seq-E<gt>annotation> method.
 
30
 
 
31
=head1 FEEDBACK
 
32
 
 
33
=head2 Mailing Lists
 
34
 
 
35
User feedback is an integral part of the evolution of this and other
 
36
Bioperl modules. Send your comments and suggestions preferably to
 
37
the Bioperl mailing list.  Your participation is much appreciated.
 
38
 
 
39
  bioperl-l@bioperl.org                  - General discussion
 
40
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
41
 
 
42
=head2 Reporting Bugs
 
43
 
 
44
Report bugs to the Bioperl bug tracking system to help us keep track
 
45
of the bugs and their resolution. Bug reports can be submitted via
 
46
the web:
 
47
 
 
48
  http://bugzilla.open-bio.org/
 
49
 
 
50
=head1 AUTHOR - Mark A. Jensen
 
51
 
 
52
Email maj@fortinbras.us
 
53
 
 
54
=head1 CONTRIBUTORS
 
55
 
 
56
=head1 APPENDIX
 
57
 
 
58
The rest of the documentation details each of the object methods.
 
59
Internal methods are usually preceded with a _
 
60
 
 
61
=cut
 
62
 
 
63
# Let the code begin...
 
64
 
 
65
package Bio::DB::HIV::HIVAnnotProcessor;
 
66
use strict;
 
67
 
 
68
# Object preamble - inherits from Bio::Root::Root
 
69
 
 
70
use Bio::Root::Root;
 
71
use base qw( Bio::Root::Root);
 
72
 
 
73
=head1 Constructor
 
74
 
 
75
=head2 new
 
76
 
 
77
 Title   : new
 
78
 Usage   : my $obj = new HIVAnnotProcessor();
 
79
 Function: Builds a new HIVAnnotProcessor object 
 
80
 Returns : an instance of HIVAnnotProcessor
 
81
 Args    :
 
82
 
 
83
=cut
 
84
 
 
85
sub new {
 
86
    my($class,@args) = @_;
 
87
    my $self = $class->SUPER::new(@args);
 
88
    my ($hiv_query, $source_stream) =
 
89
        $self->_rearrange([qw(HIV_QUERY SOURCE_STREAM)], @args); 
 
90
 
 
91
 
 
92
    $hiv_query                  && $self->hiv_query($hiv_query);
 
93
    $source_stream              && $self->source_stream($source_stream);
 
94
 
 
95
    return $self;
 
96
}
 
97
 
 
98
=head1 Bio::Factory::SequenceProcessorI compliance
 
99
 
 
100
=head2 source_stream
 
101
 
 
102
 Title   : source_stream
 
103
 Usage   : $hap->source_stream($newval)
 
104
 Function: 
 
105
 Example : 
 
106
 Returns : value of source_stream (a scalar)
 
107
 Args    : on set, new value (a scalar or undef, optional)
 
108
 
 
109
=cut
 
110
 
 
111
sub source_stream{
 
112
    my $self = shift;
 
113
    if (@_) {
 
114
        $self->throw(-class=>'Bio::Root::BadParameter',
 
115
                     -text=>'Requires a Bio::SeqIO as argument',
 
116
                     -value=>$_[0]) unless $_[0]->isa('Bio::SeqIO');
 
117
    }
 
118
    return $self->{'source_stream'} = shift if @_;
 
119
    return $self->{'source_stream'};
 
120
}
 
121
 
 
122
=head2 next_seq
 
123
 
 
124
 Title   : next_seq
 
125
 Usage   : $seqobj = stream->next_seq
 
126
 Function: Reads the next sequence object from the stream, 
 
127
         : adds annotations from the HIVQuery object according
 
128
         : to the sequence id, and returns sequence object
 
129
 Returns : a Bio::Seq sequence object
 
130
 Args    : none
 
131
 
 
132
=cut
 
133
 
 
134
sub next_seq {
 
135
    my $self = shift;
 
136
    my $q = $self->hiv_query;
 
137
    my $seqo = $self->source_stream->next_seq;
 
138
    return $seqo unless ($q && $seqo);
 
139
    
 
140
    my $ac = $q->get_annotations_by_id($seqo->primary_id);
 
141
    $seqo->annotation($ac) if $ac;
 
142
    my $acc = $q->get_accessions_by_id($seqo->primary_id);
 
143
    $seqo->accession_number($acc) if $acc;
 
144
 
 
145
    return $seqo;
 
146
}
 
147
 
 
148
=head2 write_seq
 
149
 
 
150
 Title   : write_seq
 
151
 Usage   : $seqobj->write_seq
 
152
 Function: for HIVAnnotProcessor, throw an exception
 
153
 Example :
 
154
 Returns : Bio::Root::IOException
 
155
 Args    :
 
156
 
 
157
=cut
 
158
 
 
159
sub write_seq{
 
160
   my ($self,@args) = @_;
 
161
   $self->throw(-class=>'Bio::Root::IOException',
 
162
                -text=>'This stream is read-only',
 
163
                -value=>"");
 
164
}
 
165
 
 
166
=head1 HIVAnnotProcessor-specific methods
 
167
 
 
168
=head2 hiv_query
 
169
 
 
170
 Title   : hiv_query
 
171
 Usage   : $obj->hiv_query($newval)
 
172
 Function: 
 
173
 Example : 
 
174
 Returns : value of hiv_query (a Bio::DB::Query::HIVQuery object)
 
175
 Args    : on set, new value (an HIVQuery object, optional)
 
176
 
 
177
=cut
 
178
 
 
179
sub hiv_query{
 
180
    my $self = shift;
 
181
    if (@_) {
 
182
        $self->throw(-class=>'Bio::Root::BadParameter',
 
183
                     -text=>'Requires a Bio::DB::Query::HIVQuery as argument',
 
184
                     -value=>$_[0]) unless ref $_[0] && $_[0]->isa('Bio::DB::Query::HIVQuery');
 
185
    }
 
186
    return $self->{'hiv_query'} = shift if @_;
 
187
    return $self->{'hiv_query'};
 
188
}
 
189
 
 
190
 
 
191
1;
 
192