File Coverage

Bio/Map/Contig.pm
Criterion Covered Total %
statement 34 67 50.7
branch 13 52 25.0
condition 2 12 16.6
subroutine 12 19 63.1
pod 13 13 100.0
total 74 163 45.4


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Map::Contig
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Sendu Bala
7             #
8             # Copyright Gaurav Gupta
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::Map::Contig - A MapI implementation handling the contigs of a
17             Physical Map (such as FPC)
18              
19             =head1 SYNOPSIS
20              
21             # get the contig object of $contig from the Bio::Map::Physical
22             my $ctgobj = $physical->get_contigobj($contig);
23              
24             # acquire all the markers that lie in this contig
25             foreach my $marker ($ctgobj->each_markerid()) {
26             print " +++$marker\n";
27             }
28              
29             # find the group of this contig
30             print "Group: ",$ctgobj->group(),"\n";
31              
32             # find the range of this contig
33             print "RANGE: start:",$ctgobj->range()->start(),"\tend: ",
34             $ctgobj->range()->end(),"\n";
35              
36             # find the position of this contig in $group (chromosome)
37             print "Position in Group $group"," = ",$ctgobj->position($group),"\n";
38              
39              
40             =head1 DESCRIPTION
41              
42             This is an implementation of Bio::Map::MapI. It handles the
43             essential storage of name, species, type, and units as well as in
44             memory representation of the elements of a map.
45              
46             Bio::Map::Contig has been tailored to work for FPC physical maps, but
47             could probably be used for others as well (with the appropriate MapIO
48             module).
49              
50             =head1 FEEDBACK
51              
52             =head2 Mailing Lists
53              
54             User feedback is an integral part of the evolution of this and other
55             Bioperl modules. Send your comments and suggestions preferably to
56             the Bioperl mailing list. Your participation is much appreciated.
57              
58             bioperl-l@bioperl.org - General discussion
59             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
60              
61             =head2 Support
62              
63             Please direct usage questions or support issues to the mailing list:
64              
65             I
66              
67             rather than to the module maintainer directly. Many experienced and
68             reponsive experts will be able look at the problem and quickly
69             address it. Please include a thorough description of the problem
70             with code and data examples if at all possible.
71              
72             =head2 Reporting Bugs
73              
74             Report bugs to the Bioperl bug tracking system to help us keep track
75             of the bugs and their resolution. Bug reports can be submitted via the
76             web:
77              
78             https://github.com/bioperl/bioperl-live/issues
79              
80             =head1 AUTHOR - Gaurav Gupta
81              
82             Email gaurav@genome.arizona.edu
83              
84             =head1 CONTRIBUTORS
85              
86             Sendu Bala bix@sendu.me.uk
87              
88             =head1 PROJECT LEADERS
89              
90             Jamie Hatfield jamie@genome.arizona.edu
91             Dr. Cari Soderlund cari@genome.arizona.edu
92              
93             =head1 PROJECT DESCRIPTION
94              
95             The project was done in Arizona Genomics Computational Laboratory (AGCoL)
96             at University of Arizona.
97              
98             This work was funded by USDA-IFAFS grant #11180 titled "Web Resources for
99             the Computation and Display of Physical Mapping Data".
100              
101             For more information on this project, please refer:
102             http://www.genome.arizona.edu
103              
104             =head1 APPENDIX
105              
106             The rest of the documentation details each of the object methods.
107             Internal methods are usually preceded with a _
108              
109             =cut
110              
111             # Let the code begin...
112              
113             package Bio::Map::Contig;
114 2     2   12 use vars qw($MAPCOUNT);
  2         4  
  2         80  
115 2     2   10 use strict;
  2         2  
  2         42  
116              
117             # Object preamble - inherits from Bio::Root::Root
118              
119 2     2   465 use Bio::Range;
  2         5  
  2         62  
120              
121 2     2   14 use base qw(Bio::Map::SimpleMap);
  2         6  
  2         318  
122 2     2   1204 BEGIN { $MAPCOUNT = 1; }
123              
124             =head2 new
125              
126             Title : new
127             Usage : my $clone = Bio::Map::Contig->new
128             (
129             -name => $name,
130             -chr_remark => $cremark,
131             -user_remark => $uremark,
132             -trace_remark => $tremark,
133             -group => $group,
134             -subgroup=> $subgroup,
135             -anchor => $anchor,
136             -markers => \%markers,
137             -clones => \%clones,
138             -position => $pos
139             -range => Bio::Range->new(-start =>$s,-end=>$e),
140             );
141              
142             Function: Initialize a new Bio::Map::Contig object
143             Most people will not use this directly but get Markers
144             through L
145             Returns : L object
146             Args : ( -name => name string,
147             -chr_remark => chr remark string,
148             -user_remark => userremark string,
149             -trace_remark => tremark string,
150             -group => group string,
151             -subgroup=> subgroup string,
152             -anchor => boolean if this is anchored or not,
153             -markers => hashref of contained markers,
154             -clones => hashref of contained clones,
155             -position => position
156             -range => L
157              
158             =cut
159              
160             sub new {
161 0     0 1 0 my ($class,@args) = @_;
162 0         0 my $self = $class->SUPER::new(@args);
163              
164 0         0 my ($name,$cremark,$uremark,$tremark,
165             $group,$subgroup, $anchor,$markers, $clones,
166             $position,$range) = $self->_rearrange([qw(NAME CHR_REMARK USER_REMARK
167             TRACE_REMARK GROUP SUBGROUP
168             ANCHOR MARKERS CLONES
169             POSITION RANGE)],@args);
170              
171 0 0       0 $self->name($name) if defined $name;
172 0 0       0 $self->chr_remark($cremark) if defined $cremark;
173 0 0       0 $self->user_remark($uremark) if defined $uremark;
174 0 0       0 $self->trace_remark($tremark) if defined $tremark;
175 0 0       0 $self->group($group) if defined $group;
176 0 0       0 $self->subgroup($group) if defined $subgroup;
177 0 0       0 $self->anchor($anchor) if defined $anchor;
178              
179 0 0       0 $self->set_markers($markers) if defined $markers;
180 0 0       0 $self->set_clones($clones) if defined $clones;
181 0 0       0 $self->range($range) if defined $range;
182 0 0       0 $self->position($position) if defined $position;
183              
184 0         0 return $self;
185             }
186              
187             =head2 Modifier methods
188              
189             All methods present in L are implemented by this class.
190             Most of the methods are inherited from SimpleMap. The following methods
191             have been modified to reflect the needs of physical maps.
192              
193             =head2 chr_remark
194              
195             Title : chr_remark
196             Usage : my $chrremark = $contigobj->chr_remark();
197             Function: Get/set the group remark for this contig
198             Returns : scalar representing the current group_remark of this contig
199             Args : none to get, OR string to set
200              
201             =cut
202              
203             sub chr_remark {
204 11     11 1 44 my ($self) = shift;
205 11 50       19 $self->{'_cremark'} = shift if @_;
206 11 100       39 return defined $self->{'_cremark'} ? $self->{'_cremark'} : '';
207             }
208              
209             =head2 user_remark
210              
211             Title : user_remark
212             Usage : my $userremark = $contigobj->user_remark();
213             Function: Get/set the user remark for this contig
214             Returns : scalar representing the current user_remark of this contig
215             Args : none to get, OR string to set
216              
217             =cut
218              
219             sub user_remark {
220 11     11 1 33 my ($self) = shift;
221 11 50       14 $self->{'_uremark'} = shift if @_;
222 11 100       22 return defined $self->{'_uremark'} ? $self->{'_uremark'} : '';
223             }
224              
225             =head2 trace_remark
226              
227             Title : trace_remark
228             Usage : my $traceremark = $contigobj->trace_remark();
229             Function: Get/set the trace remark for this contig
230             Returns : scalar representing the current trace_remark of this contig
231             Args : none to get, OR string to set
232              
233             =cut
234              
235             sub trace_remark {
236 11     11 1 26 my ($self) = shift;
237 11 50       16 $self->{'_tremark'} = shift if @_;
238 11 100       19 return defined $self->{'_tremark'} ? $self->{'_tremark'} : '';
239             }
240              
241             =head2 range
242              
243             Title : range
244             Usage : my $range = $contigobj->range();
245             Function: Get/set the range for this Contig
246             Returns : Bio::Range representing the current range of this contig,
247             start and end of the contig can be thus found using:
248             my $start = $contigobj->range()->start();
249             my $end = $contigobj->range()->end();
250             Args : none to get, OR Bio::Range to set
251              
252             =cut
253              
254             sub range {
255 20     20 1 51 my ($self) = shift;
256 20 50       24 return $self->{'_range'} = shift if @_;
257 20         32 return $self->{'_range'};
258             }
259              
260             =head2 position
261              
262             Title : position
263             Usage : $ctgpos = $contigobj->position();
264             Function: Get/set the position of the contig in the group
265             Returns : scalar representing the position of the contig in the group
266             Args : none to get, OR string to set
267              
268             =cut
269              
270             sub position {
271 3     3 1 9 my ($self) = shift;
272 3 50       6 $self->{'_position'} = shift if @_;
273 3   50     12 return $self->{'_position'} || 0;
274             }
275              
276             =head2 anchor
277              
278             Title : anchor
279             Usage : $ctganchor = $contig->anchor();
280             Function: Get/set the anchor value for this Contig (True | False)
281             Returns : scalar representing the anchor (1 | 0) for this contig
282             Args : none to get, OR string to set
283              
284             =cut
285              
286             sub anchor {
287 11     11 1 37 my ($self) = shift;
288 11 50       15 return $self->{'_anchor'} = shift if @_;
289 11         14 return $self->{'_anchor'};
290             }
291              
292             =head2 group
293              
294             Title : group
295             Usage : $groupno = $contigobj->group();
296             Function: Get/set the group number for this contig.
297             This is a generic term, used for Linkage-Groups as well as for
298             Chromosomes.
299             Returns : scalar representing the group number of this contig
300             Args : none
301              
302             =cut
303              
304             sub group {
305 3     3 1 9 my ($self) = shift;
306 3 50       9 $self->{'_group'} = shift if @_;
307 3   50     11 return $self->{'_group'} || 0;
308             }
309              
310             =head2 subgroup
311              
312             Title : subgroup
313             Usage : $subgroup = $contig->subgroup();
314             Function: Get/set the subgroup for this contig. This is a generic term:
315             subgroup here could represent subgroup of a Chromosome or of a
316             Linkage Group. The user must take care of which subgroup he/she is
317             querying for.
318             Returns : A scalar representing the subgroup of this contig
319             Args : none
320              
321             =cut
322              
323             sub subgroup {
324 0     0 1   my ($self) = @_;
325 0 0         return $self->{'_subgroup'} = shift if @_;
326 0   0       return $self->{'_subgroup'} || 0;
327             }
328              
329             =head2 each_cloneid
330              
331             Title : each_cloneid
332             Usage : my @clones = $map->each_cloneid();
333             Function: retrieves all the clone ids in a map unordered
334             Returns : list of strings (ids)
335             Args : none
336              
337             *** This only supplies the ids set with the set_clones method ***
338             *** It has nothing to do with actual Bio::Map::MappableI objects ***
339              
340             =cut
341              
342             sub each_cloneid {
343 0     0 1   my ($self) = @_;
344 0           return $self->_each_element('clones');
345             }
346              
347             =head2 each_markerid
348              
349             Title : each_markerid
350             Usage : my @markers = $map->each_markerid();
351             Function: retrieves all the marker ids in a map unordered
352             Returns : list of strings (ids)
353             Args : none
354              
355             *** This only supplies the ids set with the set_markers method ***
356             *** It has nothing to do with actual Bio::Map::MarkerI objects ***
357              
358             =cut
359              
360             sub each_markerid {
361 0     0 1   my ($self) = @_;
362 0           return $self->_each_element('markers');
363             }
364              
365             sub _each_element {
366 0     0     my ($self, $type) = @_;
367 0 0         $type = 'clones' if (!defined($type));
368 0           $type = lc("_$type");
369 0 0         return keys %{$self->{$type} || {}};
  0            
370             }
371              
372             =head2 set_clones
373              
374             Title : set_clones
375             Usage : $marker->set_clones(\%clones)
376             Function: Set the clones hashref
377             Returns : None
378             Args : Hashref of clone ids
379              
380             *** This only sets a hash of ids ***
381             *** It has nothing to do with actual Bio::Map::MappableI objects ***
382              
383             =cut
384              
385             sub set_clones {
386 0     0 1   my ($self,$clones) = @_;
387 0 0 0       if( defined $clones && ref($clones) =~ /HASH/ ) {
388 0           $self->{'_clones'} = $clones;
389             }
390             }
391              
392             =head2 set_markers
393              
394             Title : markers
395             Usage : $obj->set_markers($newval)
396             Function: Set list of Markers (hashref)
397             Returns : None
398             Args : Hashref of marker ids
399              
400             *** This only sets a hash of ids ***
401             *** It has nothing to do with actual Bio::Map::MarkerI objects ***
402              
403             =cut
404              
405             sub set_markers {
406 0     0 1   my ($self,$markers) = @_;
407 0 0 0       if( defined $markers && ref($markers) =~ /HASH/ ) {
408 0           $self->{'_markers'} = $markers;
409             }
410             }
411              
412             1;