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