3 # BioPerl module for Bio::MapIO
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Jason Stajich <jason@bioperl.org>
9 # Copyright Jason Stajich
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::MapIO - A Map Factory object
22 my $mapio = Bio::MapIO->new(-format => "mapmaker",
23 -file => "mapfile.map");
25 while( my $map = $mapio->next_map ) {
27 foreach my $marker ( $map->each_element ) {
28 # loop through the markers associated with the map
34 This is the Factory object for reading Maps from a data stream or file.
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to
42 the Bioperl mailing list. Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 I<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
60 Report bugs to the Bioperl bug tracking system to help us keep track
61 of the bugs and their resolution. Bug reports can be submitted the web:
63 http://bugzilla.open-bio.org/
65 =head1 AUTHOR - Jason Stajich
67 Email jason@bioperl.org
71 The rest of the documentation details each of the object methods.
72 Internal methods are usually preceded with a _
77 # Let the code begin...
84 use base
qw(Bio::Root::Root Bio::Root::IO Bio::Factory::MapFactoryI);
89 Usage : my $obj = Bio::MapIO->new();
90 Function: Builds a new Bio::MapIO object
98 my($caller,@args) = @_;
100 my $class = ref($caller) || $caller;
102 # or do we want to call SUPER on an object if $caller is an
104 if( $class =~ /Bio::MapIO::(\S+)/ ) {
105 my ($self) = $class->SUPER::new
(@args);
106 $self->_initialize(@args);
111 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
112 my $format = $param{'-format'} ||
113 $class->_guess_format( $param{'-file'} || $ARGV[0] ) ||
115 $format = "\L$format"; # normalize capitalization to lower case
117 # normalize capitalization
118 return unless( $class->_load_format_module($format) );
119 return "Bio::MapIO::$format"->new(@args);
124 =head2 Bio::Factory::MapFactoryI methods
131 Usage : my $map = $factory->next_map;
132 Function: Get a map from the factory
133 Returns : L<Bio::Map::MapI>
140 Usage : $factory->write_map($map);
141 Function: Write a map out through the factory
143 Args : L<Bio::Map::MapI>
148 =head2 attach_EventHandler
150 Title : attach_EventHandler
151 Usage : $parser->attatch_EventHandler($handler)
152 Function: Adds an event handler to listen for events
154 Args : L<Bio::Event::EventHandlerI>
158 sub attach_EventHandler
{
159 my ($self,$handler) = @_;
160 return if( ! $handler );
161 if( ! $handler->isa('Bio::Event::EventHandlerI') ) {
162 $self->warn("Ignoring request to attatch handler ".ref($handler). ' because it is not a Bio::Event::EventHandlerI');
164 $self->{'_handler'} = $handler;
170 Title : _eventHandler
172 Function: Get the EventHandler
173 Returns : L<Bio::Event::EventHandlerI>
181 return $self->{'_handler'};
185 my($self, @args) = @_;
186 $self->{'_handler'} = undef;
188 # initialize the IO part
189 $self->_initialize_io(@args);
190 # $self->attach_EventHandler(Bio::MapIO::MapEventBuilder->new());
193 =head2 _load_format_module
195 Title : _load_format_module
196 Usage : *INTERNAL MapIO stuff*
197 Function: Loads up (like use) a module at run time on demand
204 sub _load_format_module
{
205 my ($self,$format) = @_;
206 my $module = "Bio::MapIO::" . $format;
209 $ok = $self->_load_module($module);
213 $self: $format cannot be found
215 For more information about the MapIO system please see the MapIO docs.
216 This includes ways of checking for formats at compile time, not run time
226 Title : _guess_format
227 Usage : $obj->_guess_format($filename)
230 Returns : guessed format of filename (lower case)
237 return unless $_ = shift;
238 return 'mapmaker' if /\.(map)$/i;
239 return 'mapxml' if /\.(xml)$/i;