bug 2549; fixed small bug in Bio::Taxon which doesn't catch -common_name
[bioperl-live.git] / Bio / MapIO / mapmaker.pm
blobebbfcf0409820ccd958179c706c14bb43864f3a8
1 # $Id$
3 # BioPerl module for Bio::MapIO::mapmaker
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
13 =head1 NAME
15 Bio::MapIO::mapmaker - A Mapmaker Map reader
17 =head1 SYNOPSIS
19 # do not use this object directly it is accessed through the Bio::MapIO system
21 use Bio::MapIO;
22 my $mapio = Bio::MapIO->new(-format => "mapmaker",
23 -file => "mapfile.map");
24 while ( my $map = $mapio->next_map ) { # get each map
25 foreach my $marker ( $map->each_element ) {
26 # loop through the markers associated with the map
30 =head1 DESCRIPTION
32 This object contains code for parsing and processing Mapmaker output
33 and creating L<Bio::Map::MapI> objects from it.
35 =head1 FEEDBACK
37 =head2 Mailing Lists
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
46 =head2 Reporting Bugs
48 Report bugs to the Bioperl bug tracking system to help us keep track
49 of the bugs and their resolution. Bug reports can be submitted via the
50 web:
52 http://bugzilla.open-bio.org/
54 =head1 AUTHOR - Jason Stajich
56 Email jason@bioperl.org
58 =head1 APPENDIX
60 The rest of the documentation details each of the object methods.
61 Internal methods are usually preceded with a _
63 =cut
65 # Let the code begin...
67 package Bio::MapIO::mapmaker;
68 use strict;
70 use Bio::Map::SimpleMap;
71 use Bio::Map::LinkagePosition;
72 use Bio::Map::Marker;
74 use base qw(Bio::MapIO);
76 =head2 next_map
78 Title : next_map
79 Usage : my $map = $factory->next_map;
80 Function: Get one or more map objects from the Mapmaker input
81 Returns : Bio::Map::MapI
82 Args : none
84 See L<Bio::Map::MapI>
86 =cut
88 sub next_map{
89 my ($self) = @_;
90 my $map = Bio::Map::SimpleMap->new(-name => '',
91 -units => 'cM',
92 -type => 'Genetic');
94 # Mapmaker input can be free-form, like the result of a copy-paste
95 # from a terminal, with no particular format before or after the
96 # map data. The $in_map variable is a flag that's set to 1 when
97 # we're reading map data lines and set back to 0 when we're finished.
98 my ($in_map,$runningDistance);
100 while ( defined ($_ = $self->_readline()) ) {
101 if ( /^\s+Markers\s+Distance/ ) {
102 $in_map = 1;
103 next;
105 next unless $in_map;
107 s/ +/\t/;
108 my ($number,$name,$distance) = split;
109 $runningDistance += $distance unless ($distance =~ /-+/);
110 $runningDistance = '0.0' if ($runningDistance == 0 || $distance =~ /-+/);
112 my $pos = Bio::Map::LinkagePosition->new(-order => $number,
113 -map => $map,
114 -value => $runningDistance );
115 my $marker = Bio::Map::Marker->new(-name => $name,
116 -position => $pos );
118 if ($distance =~ /-+/) { # last marker
119 $in_map = 0;
120 return $map;
125 =head2 write_map
127 Title : write_map
128 Usage : $factory->write_map($map);
129 Function: Write a map out through the factory
130 Returns : none
131 Args : Bio::Map::MapI
133 =cut
135 sub write_map{
136 my ($self,@args) = @_;
137 $self->throw_not_implemented();