3 # BioPerl module for Bio::MapIO
5 # Cared for by Jason Stajich <jason@bioperl.org>
7 # Copyright Jason Stajich
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
15 Bio::MapIO - A Map Factory object
20 my $mapio = Bio::MapIO->new(-format => "mapmaker",
21 -file => "mapfile.map");
23 while( my $map = $mapio->next_map ) {
25 foreach my $marker ( $map->each_element ) {
26 # loop through the markers associated with the map
32 This is the Factory object for reading Maps from a data stream or file.
38 User feedback is an integral part of the evolution of this and other
39 Bioperl modules. Send your comments and suggestions preferably to
40 the Bioperl mailing list. Your participation is much appreciated.
42 bioperl-l@bioperl.org - General discussion
43 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
47 Report bugs to the Bioperl bug tracking system to help us keep track
48 of the bugs and their resolution. Bug reports can be submitted the web:
50 http://bugzilla.open-bio.org/
52 =head1 AUTHOR - Jason Stajich
54 Email jason@bioperl.org
58 The rest of the documentation details each of the object methods.
59 Internal methods are usually preceded with a _
64 # Let the code begin...
71 use base
qw(Bio::Root::Root Bio::Root::IO Bio::Factory::MapFactoryI);
76 Usage : my $obj = Bio::MapIO->new();
77 Function: Builds a new Bio::MapIO object
85 my($caller,@args) = @_;
87 my $class = ref($caller) || $caller;
89 # or do we want to call SUPER on an object if $caller is an
91 if( $class =~ /Bio::MapIO::(\S+)/ ) {
92 my ($self) = $class->SUPER::new
(@args);
93 $self->_initialize(@args);
98 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
99 my $format = $param{'-format'} ||
100 $class->_guess_format( $param{'-file'} || $ARGV[0] ) ||
102 $format = "\L$format"; # normalize capitalization to lower case
104 # normalize capitalization
105 return unless( $class->_load_format_module($format) );
106 return "Bio::MapIO::$format"->new(@args);
111 =head2 Bio::Factory::MapFactoryI methods
118 Usage : my $map = $factory->next_map;
119 Function: Get a map from the factory
120 Returns : L<Bio::Map::MapI>
127 Usage : $factory->write_map($map);
128 Function: Write a map out through the factory
130 Args : L<Bio::Map::MapI>
135 =head2 attach_EventHandler
137 Title : attach_EventHandler
138 Usage : $parser->attatch_EventHandler($handler)
139 Function: Adds an event handler to listen for events
141 Args : L<Bio::Event::EventHandlerI>
145 sub attach_EventHandler
{
146 my ($self,$handler) = @_;
147 return if( ! $handler );
148 if( ! $handler->isa('Bio::Event::EventHandlerI') ) {
149 $self->warn("Ignoring request to attatch handler ".ref($handler). ' because it is not a Bio::Event::EventHandlerI');
151 $self->{'_handler'} = $handler;
157 Title : _eventHandler
159 Function: Get the EventHandler
160 Returns : L<Bio::Event::EventHandlerI>
168 return $self->{'_handler'};
172 my($self, @args) = @_;
173 $self->{'_handler'} = undef;
175 # initialize the IO part
176 $self->_initialize_io(@args);
177 # $self->attach_EventHandler(Bio::MapIO::MapEventBuilder->new());
180 =head2 _load_format_module
182 Title : _load_format_module
183 Usage : *INTERNAL MapIO stuff*
184 Function: Loads up (like use) a module at run time on demand
191 sub _load_format_module
{
192 my ($self,$format) = @_;
193 my $module = "Bio::MapIO::" . $format;
196 $ok = $self->_load_module($module);
200 $self: $format cannot be found
202 For more information about the MapIO system please see the MapIO docs.
203 This includes ways of checking for formats at compile time, not run time
213 Title : _guess_format
214 Usage : $obj->_guess_format($filename)
217 Returns : guessed format of filename (lower case)
224 return unless $_ = shift;
225 return 'mapmaker' if /\.(map)$/i;
226 return 'mapxml' if /\.(xml)$/i;