Propagated leftover changes from v1.6.x
[bioperl-live.git] / Bio / Map / FPCMarker.pm
blob54eb5013a5f87898cc2720b52f8563f3742307d1
2 # BioPerl module for Bio::Map::fpcmarker
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Gaurav Gupta <gaurav@genome.arizona.edu>
8 # Copyright Gaurav Gupta
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Map::FPCMarker - An central map object representing a marker
18 =head1 SYNOPSIS
20 # get the marker object of $marker from the Bio::Map::FPCMarker
21 my $markerobj = $physical->get_markerobj($marker);
23 # acquire all the clones that hit this marker
24 foreach my $clone ($markerobj->each_cloneid()) {
25 print " +++$clone\n";
28 # find the position of this marker in $contig
29 print "Position in contig $contig"," = ",$markerobj->position($contig),
30 "\n";
32 # find the group of the marker
33 print "Group : ",$markerobj->group();
36 See L<Bio::Map::Position> and L<Bio::Map::PositionI> for more information.
38 =head1 DESCRIPTION
40 This object handles the notion of a marker.
41 This object is intended to be used by a map parser like fpc.pm.
43 =head1 FEEDBACK
45 =head2 Mailing Lists
47 User feedback is an integral part of the evolution of this and other
48 Bioperl modules. Send your comments and suggestions preferably to
49 the Bioperl mailing list. Your participation is much appreciated.
51 bioperl-l@bioperl.org - General discussion
52 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
54 =head2 Support
56 Please direct usage questions or support issues to the mailing list:
58 I<bioperl-l@bioperl.org>
60 rather than to the module maintainer directly. Many experienced and
61 reponsive experts will be able look at the problem and quickly
62 address it. Please include a thorough description of the problem
63 with code and data examples if at all possible.
65 =head2 Reporting Bugs
67 Report bugs to the Bioperl bug tracking system to help us keep track
68 of the bugs and their resolution. Bug reports can be submitted via the
69 web:
71 https://redmine.open-bio.org/projects/bioperl/
73 =head1 AUTHOR - Gaurav Gupta
75 Email gaurav@genome.arizona.edu
77 =head1 CONTRIBUTORS
79 Sendu Bala bix@sendu.me.uk
81 =head1 PROJECT LEADERS
83 Jamie Hatfield jamie@genome.arizona.edu
84 Dr. Cari Soderlund cari@genome.arizona.edu
86 =head1 PROJECT DESCRIPTION
88 The project was done in Arizona Genomics Computational Laboratory (AGCoL)
89 at University of Arizona.
91 This work was funded by USDA-IFAFS grant #11180 titled "Web Resources for
92 the Computation and Display of Physical Mapping Data".
94 For more information on this project, please refer:
95 http://www.genome.arizona.edu
97 =head1 APPENDIX
99 The rest of the documentation details each of the object methods.
100 Internal methods are usually preceded with a _
102 =cut
104 # Let the code begin...
106 package Bio::Map::FPCMarker;
107 use strict;
108 use Bio::Map::Position;
109 use Time::Local;
111 use base qw(Bio::Root::Root Bio::Map::MappableI);
113 =head2 new
115 Title : new
116 Usage : my $clone = Bio::Map::FPCMarker->new
118 -name => $marker,
119 -type => $type,
120 -global => $global,
121 -frame => $frame,
122 -group => $group,
123 -subgroup=> $subgroup,
124 -anchor => $anchor,
125 -clones => \%clones,
126 -contigs => \%contigs,
127 -position => \%markerpos,
128 -remark => $remark
131 Function: Initialize a new Bio::Map::FPCMarker object
132 Most people will not use this directly but get Markers
133 through L<Bio::MapIO::fpc>
134 Returns : L<Bio::Map::FPCMarker> object
135 Args : -name => marker name string,
136 -type => type string,
137 -global => global position for marker,
138 -frame => boolean if marker is framework or placement,
139 -group => group number for marker,
140 -subgroup => subgroup number of marker,
141 -anchor => boolean if marker is anchored,
142 -clones => all the clone elements in map (hashref),
143 -contigs => all the contig elements (hasref),
144 -position => mapping of marker names to map position (hasref),
145 -remark => remarks, separated by newlines
147 =cut
149 sub new {
150 my ($class,@args) = @_;
151 my $self= $class->SUPER::new(@args);
153 my ($name,$type,$global,$frame,$group,
154 $subgroup, $anchor, $clones,$contigs,
155 $positions, $remark) = $self->_rearrange([qw(NAME TYPE GLOBAL FRAME
156 GROUP SUBGROUP ANCHOR
157 CLONES CONTIGS POSITIONS REMARK)],@args);
159 $self->name($name) if defined $name;
160 $self->type($type) if defined $type;
161 $self->global($global) if defined $global;
162 $self->group($group) if defined $group;
163 $self->subgroup($group) if defined $subgroup;
164 $self->anchor($anchor) if defined $anchor;
165 $self->remark($remark) if defined $remark;
167 $self->set_clones($clones) if defined $clones;
168 $self->set_contigs($contigs) if defined $contigs;
169 $self->set_positions($positions) if defined $positions;
171 return $self;
174 =head1 Access Methods
176 These methods let you get and set the member variables
178 =head2 name
180 Title : name
181 Usage : my $name = $markerobj->name();
182 Function: Get/set the name for this marker
183 Returns : scalar representing the current name of this marker
184 Args : none to get, OR string to set
186 =cut
188 sub name {
189 my ($self) = shift;
190 return $self->{'_name'} = shift if @_;
191 return $self->{'_name'};
194 =head2 type
196 Title : type
197 Usage : my $type = $markerobj->type();
198 Function: Get/set the type for this marker
199 Returns : scalar representing the current type of this marker
200 Args : none to get, OR string to set
202 =cut
204 sub type {
205 my ($self) = shift;
206 return $self->{'_type'} = shift if @_;
207 return $self->{'_type'};
210 =head2 global
212 Title : global
213 Usage : my $type = $markerobj->global();
214 Function: Get/set the global position for this marker
215 Returns : scalar representing the current global position of this marker
216 Args : none to get, OR string to set
218 =cut
220 sub global {
221 my ($self) = shift;
222 return $self->{'_global'} = shift if @_;
223 return $self->{'_global'};
226 =head2 anchor
228 Title : anchor
229 Usage : my $anchor = $markerobj->anchor();
230 Function: indicate if the Marker is anchored or not (True | False)
231 Returns : scalar representing the anchor (1 | 0) for this marker
232 Args : none to get, OR 1|0 to set
234 =cut
236 sub anchor {
237 my ($self) = shift;
238 return $self->{'_anchor'} = shift if @_;
239 return $self->{'_anchor'};
242 =head2 framework
244 Title : framework
245 Usage : $frame = $markerobj->framework();
246 Function: indicate if the Marker is framework or placement (1 | 0)
247 Returns : scalar representing if the marker is framework
248 (1 if framework, 0 if placement)
249 Args : none to get, OR 1|0 to set
251 =cut
253 sub framework {
254 my ($self) = shift;
255 return $self->{'_frame'} = shift if @_;
256 return $self->{'_frame'};
259 =head2 group
261 Title : group
262 Usage : $grpno = $markerobj->group();
263 Function: Get/set the group number for this marker. This is a generic term,
264 used for Linkage-Groups as well as for Chromosomes.
265 Returns : scalar representing the group number of this marker
266 Args : none to get, OR string to set
268 =cut
270 sub group {
271 my ($self) = shift;
272 $self->{'_group'} = shift if @_;
273 return $self->{'_group'} || 0;
276 =head2 subgroup
278 Title : subgroup
279 Usage : $subgroup = $marker->subgroup();
280 Function: Get/set the subgroup for this marker. This is a generic term:
281 subgroup here could represent subgroup of a Chromosome or of a
282 Linkage Group. The user must take care of which subgroup he/she is
283 querying for.
284 Returns : scalar representing the subgroup of this marker
285 Args : none to get, OR string to set
287 =cut
289 sub subgroup {
290 my ($self) = shift;
291 $self->{'_subgroup'} = shift if @_;
292 return $self->{'_subgroup'} || 0;
295 =head2 position
297 Title : position
298 Usage : $markerpos = $markerobj->position($ctg);
299 Function: get the position of the marker in the contig
300 Returns : scalar representing the position of the markernumber of
301 the contig
302 Args : $ctg is necessary to look for the position of the marker
303 in that contig.
305 *** This has nothing to do with an actual Bio::Map::PositionI object ***
307 =cut
309 sub position {
310 my ($self,$ctg) = @_;
311 return 0 unless defined $ctg;
313 return 0 unless( defined $self->{'_position'} &&
314 defined $self->{'_position'}{$ctg});
315 return $self->{'_position'}{$ctg};
318 =head2 remark
320 Title : remark
321 Usage : $markerremark = $markerobj->remark();
322 Function: get the remarks for this marker
323 Returns : scalar of newline-separated markers
324 Args : none
326 =cut
328 sub remark {
329 my ($self) = shift;
330 return $self->{'_remark'} = shift if @_;
331 return $self->{'_remark'};
334 =head2 each_cloneid
336 Title : each_cloneid
337 Usage : my @clones = $map->each_cloneid();
338 Function: retrieves all the clone ids in a map unordered
339 Returns : list of strings (ids)
340 Args : none
342 *** This only supplies the ids set with the set_clones method ***
343 *** It has nothing to do with actual Bio::Map::MappableI objects ***
345 =cut
347 sub each_cloneid {
348 my ($self) = @_;
349 return $self->_each_element('clones');
352 =head2 each_contigid
354 Title : each_contigid
355 Usage : my @contigs = $map->each_contigid();
356 Function: retrieves all the contig ids in a map unordered
357 Returns : list of strings (ids)
358 Args : none
360 *** This only supplies the ids set with the set_contigs method ***
361 *** It has nothing to do with actual Bio::Map::MapI objects ***
363 =cut
365 sub each_contigid {
366 my ($self) = @_;
367 return $self->_each_element('contigs');
370 sub _each_element{
371 my ($self, $type) = @_;
373 $type = 'clones' unless defined $type;
374 $type = lc("_$type");
376 return keys %{$self->{$type} || {}};
379 =head2 set_clones
381 Title : set_clones
382 Usage : $marker->set_clones(\%clones)
383 Function: Set the clone ids hashref
384 Returns : None
385 Args : Hashref of clone ids
387 *** This only sets a hash of ids ***
388 *** It has nothing to do with actual Bio::Map::MappableI objects ***
390 =cut
392 sub set_clones{
393 my ($self,$clones) = @_;
394 if( defined $clones && ref($clones) =~ /HASH/ ) {
395 $self->{'_clones'} = $clones;
399 =head2 set_contigs
401 Title : set_contigs
402 Usage : $marker->set_contigs(\%contigs)
403 Function: Set the contig ids hashref
404 Returns : None
405 Args : Hashref of contig ids
407 *** This only sets a hash of ids ***
408 *** It has nothing to do with actual Bio::Map::MapI objects ***
410 =cut
412 sub set_contigs{
413 my ($self,$contigs) = @_;
414 if( defined $contigs && ref($contigs) =~ /HASH/ ) {
415 $self->{'_contigs'} = $contigs;
419 =head2 set_positions
421 Title : set_positions
422 Usage : $marker->set_positions(\%markerpos)
423 Function: Set the positions hashref
424 Returns : None
425 Args : Hashref of marker positions
427 *** This only sets a hash of numbers ***
428 *** It has nothing to do with actual Bio::Map::PositionI objects ***
430 =cut
432 sub set_positions{
433 my ($self,$pos) = @_;
434 if( defined $pos && ref($pos) =~ /HASH/ ) {
435 $self->{'_positions'} = $pos;