File Coverage

Bio/Tools/HMMER/Domain.pm
Criterion Covered Total %
statement 38 61 62.3
branch 3 6 50.0
condition n/a
subroutine 11 18 61.1
pod 11 15 73.3
total 63 100 63.0


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Tools::HMMER::Domain
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Ewan Birney
7             #
8             # Copyright Ewan Birney
9             #
10             # You may distribute this module under the same terms as perl itself
11              
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::Tools::HMMER::Domain - One particular domain hit from HMMER
17              
18             =head1 SYNOPSIS
19              
20             Read the Bio::Tools::HMMER::Results docs
21              
22             =head1 DESCRIPTION
23              
24             A particular domain score. We reuse the Homol SeqFeature system
25             here, so this inherits off Homol SeqFeature. As this code
26             originally came from a separate project, there are some backward
27             compatibility stuff provided to keep this working with old code.
28              
29             Don't forget this inherits off Bio::SeqFeature, so all your usual
30             nice start/end/score stuff is ready for use.
31              
32             =head1 CONTACT
33              
34             Ewan Birney, birney@ebi.ac.uk
35              
36             =head1 CONTRIBUTORS
37              
38             Jason Stajich, jason@bioperl.org
39              
40             =head1 APPENDIX
41              
42             The rest of the documentation details each of the object
43             methods. Internal methods are usually preceded with a _
44              
45             =cut
46              
47             #'
48             package Bio::Tools::HMMER::Domain;
49              
50 1     1   700 use Bio::SeqFeature::Generic;
  1         2  
  1         25  
51 1     1   5 use strict;
  1         1  
  1         18  
52              
53              
54 1     1   4 use base qw(Bio::SeqFeature::FeaturePair);
  1         1  
  1         367  
55              
56             sub new {
57 2434     2434 1 2685 my($class,@args) = @_;
58 2434         4237 my $self = $class->SUPER::new(@args);
59              
60 2434         2700 $self->{'alignlines'} = [];
61              
62 2434         3906 my $hmmf1 = Bio::SeqFeature::Generic->new(@args);
63 2434         3463 my $hmmf2 = Bio::SeqFeature::Generic->new(@args);
64              
65 2434         3726 $self->feature1($hmmf1);
66 2434         3426 $self->feature2($hmmf2);
67              
68 2434         3805 return $self;
69             }
70              
71             =head2 add_alignment_line
72              
73             Title : add_alignment_line
74             Usage : $domain->add_alignment_line($line_from_hmmer_output);
75             Function: add an alignment line to this Domain object
76             Returns : Nothing
77             Args : scalar
78              
79             Adds an alignment line, mainly for storing the HMMER alignments
80             as flat text which can be reguritated. You're right. This is *not
81             nice* and not the right way to do it. C'est la vie.
82              
83             =cut
84              
85             sub add_alignment_line {
86 40     40 1 25 my $self = shift;
87 40         35 my $line = shift;
88 40         27 push(@{$self->{'alignlines'}},$line);
  40         85  
89             }
90              
91             =head2 each_alignment_line
92              
93             Title : each_alignment_line
94             Usage : foreach $line ( $domain->each_alignment_line )
95             Function: reguritates the alignment lines as they were fed in.
96             only useful realistically for printing.
97             Example :
98             Returns :
99             Args : None
100              
101              
102             =cut
103              
104             sub each_alignment_line {
105 0     0 1 0 my $self = shift;
106 0         0 return @{$self->{'alignlines'}};
  0         0  
107             }
108              
109             =head2 get_nse
110              
111             Title : get_nse
112             Usage : $domain->get_nse()
113             Function: Provides a seqname/start-end format, useful
114             for unique keys. nse stands for name-start-end
115             It is used a lot in Pfam
116             Example :
117             Returns : A string
118             Args : Optional separator 1 and separator 2 (default / and -)
119              
120              
121             =cut
122              
123              
124              
125             sub get_nse {
126 3038     3038 1 2218 my $self = shift;
127 3038         2121 my $sep1 = shift;
128 3038         2168 my $sep2 = shift;
129              
130 3038 50       3978 if( !defined $sep2 ) {
131 3038         2640 $sep2 = "-";
132             }
133 3038 50       3846 if( !defined $sep1 ) {
134 3038         2300 $sep1 = "/";
135             }
136              
137 3038         4112 return sprintf("%s%s%d%s%d",$self->seq_id,$sep1,$self->start,$sep2,$self->end);
138             }
139              
140              
141             # =head2 start_seq
142              
143             # Title : start_seq
144             # Usage : Backward compatibility with old HMMER modules.
145             # should use $domain->start
146             # Function:
147             # Example :
148             # Returns :
149             # Args :
150              
151             # =cut
152              
153             sub start_seq {
154 0     0 0 0 my $self = shift;
155 0         0 my $start = shift;
156              
157 0         0 $self->warn("Using old domain->start_seq. Should use domain->start");
158 0         0 return $self->start($start);
159             }
160              
161             # =head2 end_seq
162              
163             # Title : end_seq
164             # Usage : Backward compatibility with old HMMER modules.
165             # should use $domain->end
166             # Function:
167             # Example :
168             # Returns :
169             # Args :
170              
171             # =cut
172              
173             sub end_seq {
174 0     0 0 0 my $self = shift;
175 0         0 my $end = shift;
176              
177 0         0 $self->warn("Using old domain->end_seq. Should use domain->end");
178 0         0 return $self->end($end);
179             }
180              
181             # =head2 start_hmm
182              
183             # Title : start_hmm
184             # Usage : Backward compatibility with old HMMER modules, and
185             # for convience. Equivalent to $self->homol_SeqFeature->start
186             # Function:
187             # Example :
188             # Returns :
189             # Args :
190              
191             # =cut
192              
193             sub start_hmm {
194 0     0 0 0 my $self = shift;
195 0         0 my $start = shift;
196 0         0 $self->warn("Using old domain->start_hmm. Should use domain->hstart");
197 0         0 return $self->hstart($start);
198             }
199              
200             # =head2 end_hmm
201              
202             # Title : end_hmm
203             # Usage : Backward compatibility with old HMMER modules, and
204             # for convience. Equivalent to $self->homol_SeqFeature->start
205             # Function:
206             # Example :
207             # Returns :
208             # Args :
209              
210             # =cut
211              
212             sub end_hmm {
213 0     0 0 0 my $self = shift;
214 0         0 my $end = shift;
215              
216 0         0 $self->warn("Using old domain->end_hmm. Should use domain->hend");
217 0         0 return $self->hend($end);
218             }
219              
220             =head2 hmmacc
221              
222             Title : hmmacc
223             Usage : $domain->hmmacc($newacc)
224             Function: set get for HMM accession number. This is placed in the homol
225             feature of the HMM
226             Example :
227             Returns :
228             Args :
229              
230              
231             =cut
232              
233             sub hmmacc{
234 1     1 1 2 my ($self,$acc) = @_;
235 1 50       2 if( defined $acc ) {
236 1         3 $self->feature2->add_tag_value('accession',$acc);
237             }
238 1         3 my @vals = $self->feature2->each_tag_value('accession');
239 1         2 return shift @vals;
240             }
241              
242             =head2 hmmname
243              
244             Title : hmmname
245             Usage : $domain->hmmname($newname)
246             Function: set get for HMM accession number. This is placed in the homol
247             feature of the HMM
248             Example :
249             Returns :
250             Args :
251              
252             =cut
253              
254             sub hmmname {
255 2437     2437 1 3384 return shift->hseq_id(@_);
256             }
257              
258             =head2 bits
259              
260             Title : bits
261             Usage :
262             Function: backward compatibility. Same as score
263             Example :
264             Returns :
265             Args :
266              
267             =cut
268              
269             sub bits{
270 3145     3145 1 4432 return shift->score(@_);
271             }
272              
273             =head2 evalue
274              
275             Title : evalue
276             Usage :
277             Function: $domain->evalue($value);
278             Example :
279             Returns :
280             Args :
281              
282             =cut
283              
284             sub evalue{
285 2435     2435 1 3728 return shift->_tag_value('evalue',@_);
286             }
287              
288             =head2 seqbits
289              
290             Title : seqbits
291             Usage :
292             Function: $domain->seqbits($value);
293             Example :
294             Returns :
295             Args :
296              
297             =cut
298              
299             sub seqbits {
300 2434     2434 1 3363 return shift->_tag_value('seqbits',@_);
301             }
302              
303             =head2 seq_range
304              
305             Title : seq_range
306             Usage :
307             Function: Throws an exception to catch scripts which need to upgrade
308             Example :
309             Returns :
310             Args :
311              
312             =cut
313              
314             sub seq_range{
315 0     0 1   my ($self,@args) = @_;
316              
317 0           $self->throw("You have accessed an old method. Please recode your script to the new bioperl HMMER module");
318             }
319              
320             =head2 hmm_range
321              
322             Title : hmm_range
323             Usage :
324             Function: Throws an exception to catch scripts which need to upgrade
325             Example :
326             Returns :
327             Args :
328              
329              
330             =cut
331              
332             sub hmm_range{
333 0     0 1   my ($self,@args) = @_;
334              
335 0           $self->throw("You have accessed an old method. Please recode your script to the new bioperl HMMER module");
336             }
337              
338             1; # says use was ok
339             __END__