Bio/SeqFeature/SimilarityPair.pm

filter: Statementstmt 81.1% 43 / 53 Branchbran 58.3% 14 / 24 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 91.6% 11 / 12 Podpod 100% 8 / 8 totaltotal 74.7% 80 / 107 CC 15 SCAR 21.5
CC
15
Cov
72%
new
17.4
significance
6.0
bits
2.1
CRAP 8.6
« Bio/SearchIO/Writer/HitTableWriter.pm ↑ Summary Bio/Search/Result/GenericResult.pm »
1 #
2 # BioPerl module for Bio::SeqFeature::SimilarityPair
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 #
6 # Cared for by Hilmar Lapp <hlapp@gmx.net>
7 #
8 # Copyright Hilmar Lapp
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::SeqFeature::SimilarityPair - Sequence feature based on the similarity
17 of two sequences.
18  
19 =head1 SYNOPSIS
20  
21 $sim_pair = Bio::SeqFeature::SimilarityPair->from_searchResult($blastHit);
22  
23 $sim = $sim_pair->query(); # a Bio::SeqFeature::Similarity object - the query
24 $sim = $sim_pair->hit(); # dto - the hit.
25  
26 # some properties for the similarity pair
27 $expect = $sim_pair->significance();
28 $score = $sim_pair->score();
29 $bitscore = $sim_pair->bits();
30  
31 # this will not write the description for the sequence (only its name)
32 print $sim_pair->query()->gff_string(), "\n";
33  
34 =head1 DESCRIPTION
35  
36 Lightweight similarity search result as a pair of Similarity
37 features. This class inherits off Bio::SeqFeature::FeaturePair and
38 therefore implements Bio::SeqFeatureI, whereas the two features of the
39 pair are descendants of Bio::SeqFeature::Generic, with better support
40 for representing similarity search results in a cleaner way.
41  
42 =head1 FEEDBACK
43  
44 =head2 Mailing Lists
45  
46 User feedback is an integral part of the evolution of this and other
47 Bioperl modules. Send your comments and suggestions preferably to one
48 of the Bioperl mailing lists. Your participation is much appreciated.
49  
50 bioperl-l@bioperl.org - General discussion
51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
52  
53 =head2 Support
54  
55 Please direct usage questions or support issues to the mailing list:
56  
57 I<bioperl-l@bioperl.org>
58  
59 rather than to the module maintainer directly. Many experienced and
60 reponsive experts will be able look at the problem and quickly
61 address it. Please include a thorough description of the problem
62 with code and data examples if at all possible.
63  
64 =head2 Reporting Bugs
65  
66 Report bugs to the Bioperl bug tracking system to help us keep track
67 the bugs and their resolution. Bug reports can be submitted via the
68 web:
69  
70 https://github.com/bioperl/bioperl-live/issues
71  
72 =head1 AUTHOR - Hilmar Lapp
73  
74 Email hlapp@gmx.net or hilmar.lapp@pharma.novartis.com
75  
76 =head1 APPENDIX
77  
78 The rest of the documentation details each of the object
79 methods. Internal methods are usually preceded with a _
80  
81 =cut
82  
83  
84 # Let the code begin...
85  
86  
87 package Bio::SeqFeature::SimilarityPair;
88 51 $Bio::SeqFeature::SimilarityPair::VERSION = '1.7.8';
89 51 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
90  
91 51 ▶use Bio::SeqFeature::Similarity;
Subroutine BEGIN: called CC=1 SCAR=0.0
92 51 ▶use Bio::Factory::ObjectFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94 51 ▶use base qw(Bio::SeqFeature::FeaturePair);
Subroutine BEGIN: called CC=1 SCAR=0.0
95  
96 =head2 new
97  
98 Title : new
99 Usage : my $similarityPair = Bio::SeqFeature::SimilarityPair->new
100 (-hit => $hit,
101 -query => $query,
102 -source => 'blastp');
103 Function: Initializes a new SimilarityPair object
104 Returns : Bio::SeqFeature::SimilarityPair
105 Args : -query => The query in a Feature pair
106 -hit => (formerly '-subject') the subject/hit in a Feature pair
107  
108  
109 =cut
110  
111 1252 ▶sub new {
Subroutine new: called CC=11 SCAR=28.6
Pod documented
112 1252 my($class,@args) = @_;
113  
114 1252 ▶ if(! grep { lc($_) eq "-feature_factory"; } @args) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {lc $_ eq "-feature_factory";} @args) 1252 0 1252
115 # if no overriding factory is provided, provide our preferred one
116 1252 my $fact = Bio::Factory::ObjectFactory->new(
117 -type => "Bio::SeqFeature::Similarity",
118 -interface => "Bio::SeqFeatureI");
119 1252 push(@args, '-feature_factory', $fact);
120 }
121 1252 my $self = $class->SUPER::new(@args);
122  
123 1252 my ($primary, $hit, $query, $fea1, $source,$sbjct) =
124 $self->_rearrange([qw(PRIMARY
125 HIT
126 QUERY
127 FEATURE1
128 SOURCE
129 SUBJECT
130 )],@args);
131
132 1252 ▶ if( $sbjct ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sbjct) 0 1252 1252
133 0 ▶ if(! $hit) { $hit = $sbjct }
Branch: 1 branch
BranchTrueFalseTotal
if (not $hit) { } 0 0 0
134 else {
135 0 $self->warn("-hit and -subject were specified, using -hit and ignoring -subject");
136 }
137 }
138  
139 # set the query and subject feature if provided
140 1252 ▶ $self->query( $query) if $query && ! $fea1;
Branch: 1 branch
BranchTrueFalseTotal
if $query and not $fea1 9 1243 1252
Condition66%2/3
$query and not $fea1
!ll&&!rl&&r
124309
MC/DC50%1/2
$query and not $fea1
$query not $fea1
Truth table66%2/3
A and not(B)
A= $queryB= not $fea1
ABresult
0X0
100
111
141 1252 ▶ $hit && $self->hit($hit);
Branch: 1 branch
BranchTrueFalseTotal
$hit and $self->hit($hit) 9 1243 1252
142  
143 # the following refer to feature1, which is guaranteed to exist
144 1252 ▶ if( defined $primary || ! defined $self->primary_tag) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $primary or not defined $self->primary_tag) 0 1252 1252
Condition33%1/3
defined $primary or not defined $self->primary_tag
l!l&&r!l&&!r
001252
MC/DC0%0/2
defined $primary or not defined $self->primary_tag
defined $primary not defined $self->primary_tag
Truth table33%1/3
A or not(B)
A= defined $primaryB= not defined $self->primary_tag
ABresult
1X1
011
000
145 0 ▶ $primary = 'similarity' unless defined $primary;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $primary 0 0 0
146 0 $self->primary_tag($primary);
147 }
148  
149 1252 ▶ $source && $self->source_tag($source);
Branch: 1 branch
BranchTrueFalseTotal
$source and $self->source_tag($source) 9 1243 1252
150  
151 1252 return $self;
152 }
153  
154 #
155 # Everything else is just inherited from SeqFeature::FeaturePair.
156 #
157  
158 =head2 query
159  
160 Title : query
161 Usage : $query_feature = $obj->query();
162 $obj->query($query_feature);
163 Function: The query object for this similarity pair
164 Returns : Bio::SeqFeature::Similarity
165 Args : [optional] Bio::SeqFeature::Similarity
166  
167 See L<Bio::SeqFeature::Similarity>, L<Bio::SeqFeature::FeaturePair>
168  
169 =cut
170  
171 5037 ▶sub query {
Subroutine query: called CC=1 SCAR=0.0
Pod documented
172 5037 return shift->feature1(@_);
173 }
174  
175  
176  
177  
178 =head2 subject
179  
180 Title : subject
181 Usage : $sbjct_feature = $obj->subject();
182 $obj->subject($sbjct_feature);
183 Function: Get/Set Subject for a SimilarityPair
184 Returns : Bio::SeqFeature::Similarity
185 Args : [optional] Bio::SeqFeature::Similarity
186  
187 =cut
188  
189 8 ▶sub subject {
Subroutine subject: called CC=1 SCAR=0.0
Pod documented
190 8 my $self = shift;
191 8 $self->hit(@_);
192 }
193  
194 =head2 hit
195  
196 Title : hit
197 Usage : $sbjct_feature = $obj->hit();
198 $obj->hit($sbjct_feature);
199 Function: Get/Set Hit for a SimilarityPair
200 Returns : Bio::SeqFeature::Similarity
201 Args : [optional] Bio::SeqFeature::Similarity
202  
203  
204 =cut
205  
206 3880 ▶sub hit {
Subroutine hit: called CC=1 SCAR=0.0
Pod documented
207 3880 return shift->feature2(@_);
208 }
209  
210 =head2 source_tag
211  
212 Title : source_tag
213 Usage : $source = $obj->source_tag(); # i.e., program
214 $obj->source_tag($evalue);
215 Function: Gets the source tag (program name typically) for a feature
216 Returns : string
217 Args : [optional] string
218  
219  
220 =cut
221  
222 70 ▶sub source_tag {
Subroutine source_tag: called CC=2 SCAR=6.9
Pod documented
223 70 my ($self, @args) = @_;
224  
225 70 ▶ if(@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 66 4 70
226 66 $self->hit()->source_tag(@args);
227 }
228 70 return $self->query()->source_tag(@args);
229 }
230  
231 =head2 significance
232  
233 Title : significance
234 Usage : $evalue = $obj->significance();
235 $obj->significance($evalue);
236 Function:
237 Returns :
238 Args :
239  
240  
241 =cut
242  
243 0 ▶sub significance {
Subroutine significance: not called CC=2 SCAR=17.9
Pod documented
244 0 my ($self, @args) = @_;
245  
246 0 ▶ if(@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 0 0
247 0 $self->hit()->significance(@args);
248 }
249 0 return $self->query()->significance(@args);
250 }
251  
252 =head2 score
253  
254 Title : score
255 Usage : $score = $obj->score();
256 $obj->score($value);
257 Function:
258 Returns :
259 Args :
260  
261  
262 =cut
263  
264 118 ▶sub score {
Subroutine score: called CC=2 SCAR=6.9
Pod documented
265 118 my ($self, @args) = @_;
266  
267 118 ▶ if(@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 18 100 118
268 18 $self->hit()->score(@args);
269 }
270 # Note: You might think it's only getting set on the hit object.
271 # Actually, it's getting set on both hit and query.
272  
273 118 return $self->query()->score(@args);
274 }
275  
276 =head2 bits
277  
278 Title : bits
279 Usage : $bits = $obj->bits();
280 $obj->bits($value);
281 Function:
282 Returns :
283 Args :
284  
285  
286 =cut
287  
288 146 ▶sub bits {
Subroutine bits: called CC=2 SCAR=7.6
Pod documented
289 146 my ($self, @args) = @_;
290  
291 146 ▶ if(@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 146 146
292 0 $self->hit()->bits(@args);
293 }
294 146 return $self->query()->bits(@args);
295 }
296  
297 #################################################################
298 # aliases for backwards compatibility or convenience #
299 #################################################################
300  
301 51 *sbjct = \&subject;
302  
303 51 1;
« Bio/SearchIO/Writer/HitTableWriter.pm ↑ Summary Bio/Search/Result/GenericResult.pm »