File Coverage

Bio/MapIO/mapmaker.pm
Criterion Covered Total %
statement 32 34 94.1
branch 10 10 100.0
condition 3 3 100.0
subroutine 6 7 85.7
pod 2 2 100.0
total 53 56 94.6


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::MapIO::mapmaker
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Jason Stajich
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::MapIO::mapmaker - A Mapmaker Map reader
17              
18             =head1 SYNOPSIS
19              
20             # do not use this object directly it is accessed through the Bio::MapIO system
21              
22             use Bio::MapIO;
23             my $mapio = Bio::MapIO->new(-format => "mapmaker",
24             -file => "mapfile.map");
25             while ( my $map = $mapio->next_map ) { # get each map
26             foreach my $marker ( $map->each_element ) {
27             # loop through the markers associated with the map
28             }
29             }
30              
31             =head1 DESCRIPTION
32              
33             This object contains code for parsing and processing Mapmaker output
34             and creating L objects from it.
35              
36             =head1 FEEDBACK
37              
38             =head2 Mailing Lists
39              
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.
43              
44             bioperl-l@bioperl.org - General discussion
45             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46              
47             =head2 Support
48              
49             Please direct usage questions or support issues to the mailing list:
50              
51             I
52              
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.
57              
58             =head2 Reporting Bugs
59              
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 via the
62             web:
63              
64             https://github.com/bioperl/bioperl-live/issues
65              
66             =head1 AUTHOR - Jason Stajich
67              
68             Email jason@bioperl.org
69              
70             =head1 APPENDIX
71              
72             The rest of the documentation details each of the object methods.
73             Internal methods are usually preceded with a _
74              
75             =cut
76              
77             # Let the code begin...
78              
79             package Bio::MapIO::mapmaker;
80 1     1   3 use strict;
  1         1  
  1         23  
81              
82 1     1   280 use Bio::Map::SimpleMap;
  1         1  
  1         22  
83 1     1   254 use Bio::Map::LinkagePosition;
  1         2  
  1         24  
84 1     1   281 use Bio::Map::Marker;
  1         1  
  1         24  
85              
86 1     1   4 use base qw(Bio::MapIO);
  1         1  
  1         278  
87              
88             =head2 next_map
89              
90             Title : next_map
91             Usage : my $map = $factory->next_map;
92             Function: Get one or more map objects from the Mapmaker input
93             Returns : Bio::Map::MapI
94             Args : none
95              
96             See L
97              
98             =cut
99              
100             sub next_map{
101 2     2 1 2 my ($self) = @_;
102 2         12 my $map = Bio::Map::SimpleMap->new(-name => '',
103             -units => 'cM',
104             -type => 'Genetic');
105              
106             # Mapmaker input can be free-form, like the result of a copy-paste
107             # from a terminal, with no particular format before or after the
108             # map data. The $in_map variable is a flag that's set to 1 when
109             # we're reading map data lines and set back to 0 when we're finished.
110 2         3 my ($in_map,$runningDistance);
111              
112 2         9 while ( defined ($_ = $self->_readline()) ) {
113 53 100       89 if ( /^\s+Markers\s+Distance/ ) {
114 2         1 $in_map = 1;
115 2         4 next;
116             }
117 51 100       71 next unless $in_map;
118            
119 31         96 s/ +/\t/;
120 31         61 my ($number,$name,$distance) = split;
121 31 100       87 $runningDistance += $distance unless ($distance =~ /-+/);
122 31 100 100     93 $runningDistance = '0.0' if ($runningDistance == 0 || $distance =~ /-+/);
123              
124 31         96 my $pos = Bio::Map::LinkagePosition->new(-order => $number,
125             -map => $map,
126             -value => $runningDistance );
127 31         89 my $marker = Bio::Map::Marker->new(-name => $name,
128             -position => $pos );
129            
130 31 100       114 if ($distance =~ /-+/) { # last marker
131 2         2 $in_map = 0;
132 2         5 return $map;
133             }
134             }
135             }
136              
137             =head2 write_map
138              
139             Title : write_map
140             Usage : $factory->write_map($map);
141             Function: Write a map out through the factory
142             Returns : none
143             Args : Bio::Map::MapI
144              
145             =cut
146              
147             sub write_map{
148 0     0 1   my ($self,@args) = @_;
149 0           $self->throw_not_implemented();
150             }
151              
152             1;