2 # BioPerl module for Bio::MapIO
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason@bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::MapIO - A Map Factory object
21 my $mapio = Bio::MapIO->new(-format => "mapmaker",
22 -file => "mapfile.map");
24 while( my $map = $mapio->next_map ) {
26 foreach my $marker ( $map->each_element ) {
27 # loop through the markers associated with the map
33 This is the Factory object for reading Maps from a data stream or file.
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to
41 the Bioperl mailing list. Your participation is much appreciated.
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
48 Please direct usage questions or support issues to the mailing list:
50 I<bioperl-l@bioperl.org>
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 of the bugs and their resolution. Bug reports can be submitted the web:
62 https://github.com/bioperl/bioperl-live/issues
64 =head1 AUTHOR - Jason Stajich
66 Email jason@bioperl.org
70 The rest of the documentation details each of the object methods.
71 Internal methods are usually preceded with a _
76 # Let the code begin...
83 use base
qw(Bio::Root::Root Bio::Root::IO Bio::Factory::MapFactoryI);
88 Usage : my $obj = Bio::MapIO->new();
89 Function: Builds a new Bio::MapIO object
97 my($caller,@args) = @_;
99 my $class = ref($caller) || $caller;
101 # or do we want to call SUPER on an object if $caller is an
103 if( $class =~ /Bio::MapIO::(\S+)/ ) {
104 my ($self) = $class->SUPER::new
(@args);
105 $self->_initialize(@args);
110 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
111 my $format = $param{'-format'} ||
112 $class->_guess_format( $param{'-file'} || $ARGV[0] ) ||
114 $format = "\L$format"; # normalize capitalization to lower case
116 # normalize capitalization
117 return unless( $class->_load_format_module($format) );
118 return "Bio::MapIO::$format"->new(@args);
127 Usage : $format = $stream->format()
128 Function: Get the map format
134 # format() method inherited from Bio::Root::IO
137 =head2 Bio::Factory::MapFactoryI methods
144 Usage : my $map = $factory->next_map;
145 Function: Get a map from the factory
146 Returns : L<Bio::Map::MapI>
153 Usage : $factory->write_map($map);
154 Function: Write a map out through the factory
156 Args : L<Bio::Map::MapI>
161 =head2 attach_EventHandler
163 Title : attach_EventHandler
164 Usage : $parser->attatch_EventHandler($handler)
165 Function: Adds an event handler to listen for events
167 Args : L<Bio::Event::EventHandlerI>
171 sub attach_EventHandler
{
172 my ($self,$handler) = @_;
173 return if( ! $handler );
174 if( ! $handler->isa('Bio::Event::EventHandlerI') ) {
175 $self->warn("Ignoring request to attatch handler ".ref($handler). ' because it is not a Bio::Event::EventHandlerI');
177 $self->{'_handler'} = $handler;
183 Title : _eventHandler
185 Function: Get the EventHandler
186 Returns : L<Bio::Event::EventHandlerI>
194 return $self->{'_handler'};
198 my($self, @args) = @_;
199 $self->{'_handler'} = undef;
201 # initialize the IO part
202 $self->_initialize_io(@args);
203 # $self->attach_EventHandler(Bio::MapIO::MapEventBuilder->new());
206 =head2 _load_format_module
208 Title : _load_format_module
209 Usage : *INTERNAL MapIO stuff*
210 Function: Loads up (like use) a module at run time on demand
217 sub _load_format_module
{
218 my ($self,$format) = @_;
219 my $module = "Bio::MapIO::" . $format;
222 $ok = $self->_load_module($module);
226 $self: $format cannot be found
228 For more information about the MapIO system please see the MapIO docs.
229 This includes ways of checking for formats at compile time, not run time
239 Title : _guess_format
240 Usage : $obj->_guess_format($filename)
243 Returns : guessed format of filename (lower case)
250 return unless $_ = shift;
251 return 'mapmaker' if /\.(map)$/i;
252 return 'mapxml' if /\.(xml)$/i;