Bio/Search/HSP/HSPFactory.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 83.6% 46 / 55 CC 6 SCAR 8.9
CC
6
Cov
84%
type
4.3
create
2.0
new
2.0
CRAP 2.4
« Bio/SeqFeature/Gene/TranscriptI.pm ↑ Summary Bio/Search/Hit/HitFactory.pm »
1 #
2 # BioPerl module for Bio::Search::HSP::HSPFactory
3 #
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
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 # POD documentation - main docs before the code
13  
14 =head1 NAME
15  
16 Bio::Search::HSP::HSPFactory - A factory to create Bio::Search::HSP::HSPI objects
17  
18 =head1 SYNOPSIS
19  
20 use Bio::Search::HSP::HSPFactory;
21 my $factory = Bio::Search::HSP::HSPFactory->new();
22 my $resultobj = $factory->create(@args);
23  
24 =head1 DESCRIPTION
25  
26  
27 This is a general way of hiding the object creation process so that we
28 can dynamically change the objects that are created by the SearchIO
29 parser depending on what format report we are parsing.
30  
31 This object is for creating new HSPs.
32  
33 =head1 FEEDBACK
34  
35 =head2 Mailing Lists
36  
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to
39 the Bioperl mailing list. Your participation is much appreciated.
40  
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
43  
44 =head2 Support
45  
46 Please direct usage questions or support issues to the mailing list:
47  
48 I<bioperl-l@bioperl.org>
49  
50 rather than to the module maintainer directly. Many experienced and
51 reponsive experts will be able look at the problem and quickly
52 address it. Please include a thorough description of the problem
53 with code and data examples if at all possible.
54  
55 =head2 Reporting Bugs
56  
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 of the bugs and their resolution. Bug reports can be submitted via the
59 web:
60  
61 https://github.com/bioperl/bioperl-live/issues
62  
63 =head1 AUTHOR - Jason Stajich
64  
65 Email jason-at-bioperl.org
66  
67 =head1 APPENDIX
68  
69 The rest of the documentation details each of the object methods.
70 Internal methods are usually preceded with a _
71  
72 =cut
73  
74  
75 # Let the code begin...
76  
77  
78 package Bio::Search::HSP::HSPFactory;
79 11 $Bio::Search::HSP::HSPFactory::VERSION = '1.7.8';
80 11 ▶use vars qw($DEFAULT_TYPE);
Subroutine BEGIN: called CC=1 SCAR=0.0
81 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83  
84 11 ▶use base qw(Bio::Root::Root Bio::Factory::ObjectFactoryI);
Subroutine BEGIN: called CC=1 SCAR=0.0
85  
86 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
87 11 $DEFAULT_TYPE = 'Bio::Search::HSP::GenericHSP';
88 }
89  
90 =head2 new
91  
92 Title : new
93 Usage : my $obj = Bio::Search::HSP::HSPFactory->new();
94 Function: Builds a new Bio::Search::HSP::HSPFactory object
95 Returns : Bio::Search::HSP::HSPFactory
96 Args :
97  
98  
99 =cut
100  
101 16 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
102 16 my($class,@args) = @_;
103  
104 16 my $self = $class->SUPER::new(@args);
105 16 my ($type) = $self->_rearrange([qw(TYPE)],@args);
106 16 ▶ $self->type($type) if defined $type;
Branch: 1 branch
BranchTrueFalseTotal
if defined $type 16 0 16
107 16 return $self;
108 }
109  
110 =head2 create
111  
112 Title : create
113 Usage : $factory->create(%args)
114 Function: Create a new L<Bio::Search::HSP::HSPI> object
115 Returns : L<Bio::Search::HSP::HSPI>
116 Args : hash of initialization parameters
117  
118  
119 =cut
120  
121 23 ▶sub create{
Subroutine create: called CC=2 SCAR=7.1
Pod documented
122 23 my ($self,@args) = @_;
123 23 my $type = $self->type;
124 23 eval { $self->_load_module($type) };
125 0 ▶ if( $@ ) { $self->throw("Unable to load module $type"); }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 23 23
126 23 return $type->new(@args);
127 }
128  
129  
130 =head2 type
131  
132 Title : type
133 Usage : $factory->type('Bio::Search::HSP::GenericHSP');
134 Function: Get/Set the HSP creation type
135 Returns : string
136 Args : [optional] string to set
137  
138 =cut
139  
140 39 ▶sub type{
Subroutine type: called CC=4 SCAR=14.6
Pod documented
141 39 my ($self,$type) = @_;
142 39 ▶ if( defined $type ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 16 23 39
143 # redundancy with the create method which also calls _load_module
144 # I know - but this is not a highly called object so I am going
145 # to leave it in
146 16 eval {$self->_load_module($type) };
147 0 ▶ if( $@ ){ $self->warn("Cannot find module $type, unable to set type. $@") }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 16 16
148 16 else { $self->{'_type'} = $type; }
149 }
150 39 ▶ return $self->{'_type'} || $DEFAULT_TYPE;
Condition33%1/3
$self->{'_type'} || $Bio::Search::HSP::HSPFactory::DEFAULT_TYPE
l!l&&r!l&&!r
3900
MC/DC0%0/2
$self->{'_type'} || $Bio::Search::HSP::HSPFactory::DEFAULT_TYPE
$self->{'_type'} $Bio::Search::HSP::HSPFactory::DEFAULT_TYPE
Truth table33%1/3
A || B
A= $self->{'_type'}B= $Bio::Search::HSP::HSPFactory::DEFAULT_TYPE
ABresult
1X1
011
000
151 }
152  
153 11 1;
« Bio/SeqFeature/Gene/TranscriptI.pm ↑ Summary Bio/Search/Hit/HitFactory.pm »