[bug 2714]
[bioperl-live.git] / Bio / Map / FPCMarker.pm
blob6b6df98cc429a2e9e3d7de02c136248ae7f90bee
1 # $Id$
3 # BioPerl module for Bio::Map::fpcmarker
5 # Cared for by Gaurav Gupta <gaurav@genome.arizona.edu>
7 # Copyright Gaurav Gupta
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::Map::FPCMarker - An central map object representing a marker
17 =head1 SYNOPSIS
19 # get the marker object of $marker from the Bio::Map::FPCMarker
20 my $markerobj = $physical->get_markerobj($marker);
22 # acquire all the clones that hit this marker
23 foreach my $clone ($markerobj->each_cloneid()) {
24 print " +++$clone\n";
27 # find the position of this marker in $contig
28 print "Position in contig $contig"," = ",$markerobj->position($contig),
29 "\n";
31 # find the group of the marker
32 print "Group : ",$markerobj->group();
35 See L<Bio::Map::Position> and L<Bio::Map::PositionI> for more information.
37 =head1 DESCRIPTION
39 This object handles the notion of a marker.
40 This object is intended to be used by a map parser like fpc.pm.
42 =head1 FEEDBACK
44 =head2 Mailing Lists
46 User feedback is an integral part of the evolution of this and other
47 Bioperl modules. Send your comments and suggestions preferably to
48 the Bioperl mailing list. Your participation is much appreciated.
50 bioperl-l@bioperl.org - General discussion
51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
53 =head2 Reporting Bugs
55 Report bugs to the Bioperl bug tracking system to help us keep track
56 of the bugs and their resolution. Bug reports can be submitted via the
57 web:
59 http://bugzilla.open-bio.org/
61 =head1 AUTHOR - Gaurav Gupta
63 Email gaurav@genome.arizona.edu
65 =head1 CONTRIBUTORS
67 Sendu Bala bix@sendu.me.uk
69 =head1 PROJECT LEADERS
71 Jamie Hatfield jamie@genome.arizona.edu
72 Dr. Cari Soderlund cari@genome.arizona.edu
74 =head1 PROJECT DESCRIPTION
76 The project was done in Arizona Genomics Computational Laboratory (AGCoL)
77 at University of Arizona.
79 This work was funded by USDA-IFAFS grant #11180 titled "Web Resources for
80 the Computation and Display of Physical Mapping Data".
82 For more information on this project, please refer:
83 http://www.genome.arizona.edu
85 =head1 APPENDIX
87 The rest of the documentation details each of the object methods.
88 Internal methods are usually preceded with a _
90 =cut
92 # Let the code begin...
94 package Bio::Map::FPCMarker;
95 use strict;
96 use Bio::Map::Position;
97 use Time::Local;
99 use base qw(Bio::Root::Root Bio::Map::MappableI);
101 =head2 new
103 Title : new
104 Usage : my $clone = Bio::Map::FPCMarker->new
106 -name => $marker,
107 -type => $type,
108 -global => $global,
109 -frame => $frame,
110 -group => $group,
111 -subgroup=> $subgroup,
112 -anchor => $anchor,
113 -clones => \%clones,
114 -contigs => \%contigs,
115 -position => \%markerpos,
116 -remark => $remark
119 Function: Initialize a new Bio::Map::FPCMarker object
120 Most people will not use this directly but get Markers
121 through L<Bio::MapIO::fpc>
122 Returns : L<Bio::Map::FPCMarker> object
123 Args : -name => marker name string,
124 -type => type string,
125 -global => global position for marker,
126 -frame => boolean if marker is framework or placement,
127 -group => group number for marker,
128 -subgroup => subgroup number of marker,
129 -anchor => boolean if marker is anchored,
130 -clones => all the clone elements in map (hashref),
131 -contigs => all the contig elements (hasref),
132 -position => mapping of marker names to map position (hasref),
133 -remark => remarks, separated by newlines
135 =cut
137 sub new {
138 my ($class,@args) = @_;
139 my $self= $class->SUPER::new(@args);
141 my ($name,$type,$global,$frame,$group,
142 $subgroup, $anchor, $clones,$contigs,
143 $positions, $remark) = $self->_rearrange([qw(NAME TYPE GLOBAL FRAME
144 GROUP SUBGROUP ANCHOR
145 CLONES CONTIGS POSITIONS REMARK)],@args);
147 $self->name($name) if defined $name;
148 $self->type($type) if defined $type;
149 $self->global($global) if defined $global;
150 $self->group($group) if defined $group;
151 $self->subgroup($group) if defined $subgroup;
152 $self->anchor($anchor) if defined $anchor;
153 $self->remark($remark) if defined $remark;
155 $self->set_clones($clones) if defined $clones;
156 $self->set_contigs($contigs) if defined $contigs;
157 $self->set_positions($positions) if defined $positions;
159 return $self;
162 =head1 Access Methods
164 These methods let you get and set the member variables
166 =head2 name
168 Title : name
169 Usage : my $name = $markerobj->name();
170 Function: Get/set the name for this marker
171 Returns : scalar representing the current name of this marker
172 Args : none to get, OR string to set
174 =cut
176 sub name {
177 my ($self) = shift;
178 return $self->{'_name'} = shift if @_;
179 return $self->{'_name'};
182 =head2 type
184 Title : type
185 Usage : my $type = $markerobj->type();
186 Function: Get/set the type for this marker
187 Returns : scalar representing the current type of this marker
188 Args : none to get, OR string to set
190 =cut
192 sub type {
193 my ($self) = shift;
194 return $self->{'_type'} = shift if @_;
195 return $self->{'_type'};
198 =head2 global
200 Title : global
201 Usage : my $type = $markerobj->global();
202 Function: Get/set the global position for this marker
203 Returns : scalar representing the current global position of this marker
204 Args : none to get, OR string to set
206 =cut
208 sub global {
209 my ($self) = shift;
210 return $self->{'_global'} = shift if @_;
211 return $self->{'_global'};
214 =head2 anchor
216 Title : anchor
217 Usage : my $anchor = $markerobj->anchor();
218 Function: indicate if the Marker is anchored or not (True | False)
219 Returns : scalar representing the anchor (1 | 0) for this marker
220 Args : none to get, OR 1|0 to set
222 =cut
224 sub anchor {
225 my ($self) = shift;
226 return $self->{'_anchor'} = shift if @_;
227 return $self->{'_anchor'};
230 =head2 framework
232 Title : framework
233 Usage : $frame = $markerobj->framework();
234 Function: indicate if the Marker is framework or placement (1 | 0)
235 Returns : scalar representing if the marker is framework
236 (1 if framework, 0 if placement)
237 Args : none to get, OR 1|0 to set
239 =cut
241 sub framework {
242 my ($self) = shift;
243 return $self->{'_frame'} = shift if @_;
244 return $self->{'_frame'};
247 =head2 group
249 Title : group
250 Usage : $grpno = $markerobj->group();
251 Function: Get/set the group number for this marker. This is a generic term,
252 used for Linkage-Groups as well as for Chromosomes.
253 Returns : scalar representing the group number of this marker
254 Args : none to get, OR string to set
256 =cut
258 sub group {
259 my ($self) = shift;
260 $self->{'_group'} = shift if @_;
261 return $self->{'_group'} || 0;
264 =head2 subgroup
266 Title : subgroup
267 Usage : $subgroup = $marker->subgroup();
268 Function: Get/set the subgroup for this marker. This is a generic term:
269 subgroup here could represent subgroup of a Chromosome or of a
270 Linkage Group. The user must take care of which subgroup he/she is
271 querying for.
272 Returns : scalar representing the subgroup of this marker
273 Args : none to get, OR string to set
275 =cut
277 sub subgroup {
278 my ($self) = shift;
279 $self->{'_subgroup'} = shift if @_;
280 return $self->{'_subgroup'} || 0;
283 =head2 position
285 Title : position
286 Usage : $markerpos = $markerobj->position($ctg);
287 Function: get the position of the marker in the contig
288 Returns : scalar representing the position of the markernumber of
289 the contig
290 Args : $ctg is necessary to look for the position of the marker
291 in that contig.
293 *** This has nothing to do with an actual Bio::Map::PositionI object ***
295 =cut
297 sub position {
298 my ($self,$ctg) = @_;
299 return 0 unless defined $ctg;
301 return 0 unless( defined $self->{'_position'} &&
302 defined $self->{'_position'}{$ctg});
303 return $self->{'_position'}{$ctg};
306 =head2 remark
308 Title : remark
309 Usage : $markerremark = $markerobj->remark();
310 Function: get the remarks for this marker
311 Returns : scalar of newline-separated markers
312 Args : none
314 =cut
316 sub remark {
317 my ($self) = shift;
318 return $self->{'_remark'} = shift if @_;
319 return $self->{'_remark'};
322 =head2 each_cloneid
324 Title : each_cloneid
325 Usage : my @clones = $map->each_cloneid();
326 Function: retrieves all the clone ids in a map unordered
327 Returns : list of strings (ids)
328 Args : none
330 *** This only supplies the ids set with the set_clones method ***
331 *** It has nothing to do with actual Bio::Map::MappableI objects ***
333 =cut
335 sub each_cloneid {
336 my ($self) = @_;
337 return $self->_each_element('clones');
340 =head2 each_contigid
342 Title : each_contigid
343 Usage : my @contigs = $map->each_contigid();
344 Function: retrieves all the contig ids in a map unordered
345 Returns : list of strings (ids)
346 Args : none
348 *** This only supplies the ids set with the set_contigs method ***
349 *** It has nothing to do with actual Bio::Map::MapI objects ***
351 =cut
353 sub each_contigid {
354 my ($self) = @_;
355 return $self->_each_element('contigs');
358 sub _each_element{
359 my ($self, $type) = @_;
361 $type = 'clones' unless defined $type;
362 $type = lc("_$type");
364 return keys %{$self->{$type} || {}};
367 =head2 set_clones
369 Title : set_clones
370 Usage : $marker->set_clones(\%clones)
371 Function: Set the clone ids hashref
372 Returns : None
373 Args : Hashref of clone ids
375 *** This only sets a hash of ids ***
376 *** It has nothing to do with actual Bio::Map::MappableI objects ***
378 =cut
380 sub set_clones{
381 my ($self,$clones) = @_;
382 if( defined $clones && ref($clones) =~ /HASH/ ) {
383 $self->{'_clones'} = $clones;
387 =head2 set_contigs
389 Title : set_contigs
390 Usage : $marker->set_contigs(\%contigs)
391 Function: Set the contig ids hashref
392 Returns : None
393 Args : Hashref of contig ids
395 *** This only sets a hash of ids ***
396 *** It has nothing to do with actual Bio::Map::MapI objects ***
398 =cut
400 sub set_contigs{
401 my ($self,$contigs) = @_;
402 if( defined $contigs && ref($contigs) =~ /HASH/ ) {
403 $self->{'_contigs'} = $contigs;
407 =head2 set_positions
409 Title : set_positions
410 Usage : $marker->set_positions(\%markerpos)
411 Function: Set the positions hashref
412 Returns : None
413 Args : Hashref of marker positions
415 *** This only sets a hash of numbers ***
416 *** It has nothing to do with actual Bio::Map::PositionI objects ***
418 =cut
420 sub set_positions{
421 my ($self,$pos) = @_;
422 if( defined $pos && ref($pos) =~ /HASH/ ) {
423 $self->{'_positions'} = $pos;