bug 2549; fixed small bug in Bio::Taxon which doesn't catch -common_name
[bioperl-live.git] / Bio / Map / Clone.pm
blobfb177e28177315d701e73b26ea3dba7b0fb13b1d
1 # $Id$
3 # BioPerl module for Bio::Map::clone
5 # Cared for by Sendu Bala <bix@sendu.me.uk>
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::Clone - An central map object representing a clone
17 =head1 SYNOPSIS
19 # get the clone object of $clone from the Bio::Map::Clone
20 my $cloneobj = $physical->get_cloneobj($clone);
22 # acquire all the markers that hit this clone
23 foreach my $marker ($cloneobj->each_markerid()) {
24 print " +++$marker\n";
27 See L<Bio::Map::Position> and L<Bio::Map::PositionI> for more information.
29 =head1 DESCRIPTION
31 This object handles the notion of a clone. This clone will
32 have a name and a position in a map.
34 This object is intended to be used by a map parser like fpc.pm.
36 =head1 FEEDBACK
38 =head2 Mailing Lists
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.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
47 =head2 Reporting Bugs
49 Report bugs to the Bioperl bug tracking system to help us keep track
50 of the bugs and their resolution. Bug reports can be submitted via the
51 web:
53 http://bugzilla.open-bio.org/
55 =head1 AUTHOR - Gaurav Gupta
57 Email gaurav@genome.arizona.edu
59 =head1 CONTRIBUTORS
61 Sendu Bala bix@sendu.me.uk
63 =head1 PROJECT LEADERS
65 Jamie Hatfield jamie@genome.arizona.edu
66 Dr. Cari Soderlund cari@genome.arizona.edu
68 =head1 PROJECT DESCRIPTION
70 The project was done in Arizona Genomics Computational Laboratory (AGCoL)
71 at University of Arizona.
73 This work was funded by USDA-IFAFS grant #11180 titled "Web Resources for
74 the Computation and Display of Physical Mapping Data".
76 For more information on this project, please refer:
77 http://www.genome.arizona.edu
79 =head1 APPENDIX
81 The rest of the documentation details each of the object methods.
82 Internal methods are usually preceded with a _
84 =cut
86 # Let the code begin...
88 package Bio::Map::Clone;
89 use strict;
90 use Bio::Map::Position;
92 use base qw(Bio::Root::Root Bio::Map::MappableI);
94 =head2 new
96 Title : new
97 Usage : my $clone = Bio::Map::Clone->new
99 -name => $clone,
100 -markers => \@markers,
101 -contig => $contig,
102 -type => $type,
103 -bands => $bands,
104 -gel => $gel,
105 -group => $group,
106 -remark => $remark,
107 -fpnumber=> $fp_number,
108 -sequencetype => $seq_type,
109 -sequencestatus=> $seq_status,
110 -fpcremark => $fpc_remark,
111 -matche => \@ematch,
112 -matcha => \@amatch,
113 -matchp => \@pmatch,
114 -range => Bio::Range->new(-start => $startrange,
115 -end => $endrange)
117 Function: Initialize a new Bio::Map::Clone object
118 Most people will not use this directly but get Clones
119 through L<Bio::MapIO::fpc>
120 Returns : L<Bio::Map::Clone> object
121 Args : -name => marker name string,
122 -markers => array ref of markers,
123 -contig => contig name string,
124 -type => type string,
125 -bands => band string,
126 -gel => gel string,
127 -group => group name string,
128 -remark => remark string,
129 -fpnumber=> FP number string,
130 -sequencetype => seq type string,
131 -sequencestatus=> seq status string,
132 -fpcremark => FPC remark,
133 -matche => array ref,
134 -matcha => array ref,
135 -matchp => array ref,
136 -range => L<Bio::Range> object,
138 =cut
140 sub new {
141 my ($class,@args) = @_;
142 my $self= $class->SUPER::new(@args);
144 my ($name,$markers,$contig,$type,$bands,$gel,$group,
145 $remark,$fpnumber,$seqtype,$seqstatus,$fpcremark,
146 $matche,$matcha,$matchp,
147 $range) = $self->_rearrange([qw(NAME MARKERS CONTIG TYPE
148 BANDS GEL GROUP REMARK FPNUMBER
149 SEQUENCETYPE SEQUENCESTATUS
150 FPCREMARK MATCHE MATCHA MATCHP
151 RANGE)],@args);
153 $self->name($name) if defined $name;
154 $self->markers($markers) if defined $markers;
155 $self->contigid($contig) if defined $contig;
156 $self->type($type) if defined $type;
157 $self->bands($bands) if defined $bands;
158 $self->gel($gel) if defined $gel;
159 $self->group($group) if defined $group;
160 $self->remark($remark) if defined $remark;
161 $self->fp_number($fpnumber) if defined $fpnumber;
162 $self->sequence_type($seqtype) if defined $seqtype;
163 $self->sequence_status($seqstatus) if defined $seqstatus;
164 $self->fpc_remark($fpcremark) if defined $fpcremark;
165 $self->range($range) if defined $range;
167 $self->set_match('approx', $matcha) if defined $matcha;
168 $self->set_match('pseudo', $matchp) if defined $matchp;
169 $self->set_match('exact', $matche) if defined $matche;
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 = $cloneobj->name();
182 Function: Get/set the name for this Clone
183 Returns : scalar representing the current name of this clone
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 = $cloneobj->type();
198 Function: Get/set the type for this clone
199 Returns : scalar representing the current type of this clone
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 range
212 Title : range
213 Usage : my $range = $cloneobj->range();
214 Function: Get/set the range of the contig that this clone covers
215 Returns : Bio::Range representing the current range of this contig,
216 start and end of the contig can be thus found using:
217 my $start = $contigobj->range()->start();
218 my $end = $contigobj->range()->end();
219 Args : none to get, OR Bio::Range to set
221 =cut
223 sub range {
224 my ($self) = shift;
225 return $self->{'_range'} = shift if @_;
226 return $self->{'_range'};
229 =head2 match
231 Title : match
232 Usage : @eclone = $cloneobj->match('exact');
233 @aclone = $cloneobj->match('approximate');
234 @pclone = $cloneobj->match('pseudo');
235 Function: get all matching clones
236 Returns : list
237 Args : scalar representing the type of clone to be
238 queried.
240 =cut
242 sub match {
243 my ($self,$type) = @_;
245 $type = "_match" . lc(substr($type, 0, 1));
246 return @{$self->{$type} || []};
249 =head2 each_match
251 Title : each_match
252 Function: Synonym of the match() method.
254 =cut
256 *each_match = \&match;
258 =head2 set_match
260 Title : set_match
261 Usage : $clone->set_match($type,$values);
262 Function: Set the Matches per type
263 Returns : None
264 Args : type (one of 'exact' 'approx' 'pseudo')
265 array ref of match values
267 =cut
269 sub set_match{
270 my ($self,$type,$val) = @_;
271 $type = "_match" . lc(substr($type, 0, 1));
272 $self->{$type} = $val;
275 =head2 gel
277 Title : gel
278 Usage : $clonegel = $cloneobj->gel();
279 Function: Get/set the gel number for this clone
280 Returns : scalar representing the gel number of this clone
281 Args : none to get, OR string to set
283 =cut
285 sub gel {
286 my ($self) = shift;
287 return $self->{'_gel'} = shift if @_;
288 return $self->{'_gel'};
291 =head2 remark
293 Title : remark
294 Usage : $cloneremark = $cloneobj->remark();
295 Function: Get/set the remark for this clone
296 Returns : scalar representing the current remark of this clone
297 Args : none to get, OR string to set
299 =cut
301 sub remark {
302 my ($self) = shift;
303 return $self->{'_remark'} = shift if @_;
304 return $self->{'_remark'};
307 =head2 fp_number
309 Title : fp_number
310 Usage : $clonefpnumber = $cloneobj->fp_number();
311 Function: Get/set the fp number for this clone
312 Returns : scalar representing the fp number of this clone
313 Args : none to get, OR string to set
315 =cut
317 sub fp_number {
318 my ($self) = shift;
319 return $self->{'_fpnumber'} = shift if @_;
320 return $self->{'_fpnumber'};
323 =head2 sequence_type
325 Title : sequence_type
326 Usage : $cloneseqtype = $cloneobj->sequence_type();
327 Function: Get/set the sequence type for this clone
328 Returns : scalar representing the sequence type of this clone
329 Args : none to get, OR string to set
331 =cut
333 sub sequence_type {
334 my ($self) = shift;
335 return $self->{'_sequencetype'} = shift if @_;
336 return $self->{'_sequencetype'};
339 =head2 sequence_status
341 Title : sequence_status
342 Usage : $cloneseqstatus = $cloneobj->sequence_status();
343 Function: Get/set the sequence status for this clone
344 Returns : scalar representing the sequence status of this clone
345 Args : none to get, OR string to set
347 =cut
349 sub sequence_status {
350 my ($self) = shift;
351 return $self->{'_sequencestatus'} = shift if @_;
352 return $self->{'_sequencestatus'};
355 =head2 fpc_remark
357 Title : fpc_remark
358 Usage : $clonefpcremark = $cloneobj->fpc_remark();
359 Function: Get/set the fpc remark for this clone
360 Returns : scalar representing the fpc remark of this clone
361 Args : none to get, OR string to set
363 =cut
365 sub fpc_remark {
366 my ($self) = shift;
367 return $self->{'_fpcremark'} = shift if @_;
368 return $self->{'_fpcremark'};
371 =head2 bands
373 Title : bands
374 Usage : @clonebands = $cloneobj->bands();
375 Function: Get/set the bands for this clone
376 Returns : liat representing the band of this clone, if
377 readcor = 1 while creating the MapIO object and the
378 .cor exists
379 Args : none to get, OR string to set
381 =cut
383 sub bands {
384 my ($self) = shift;
385 return $self->{'_bands'} = shift if @_;
386 return $self->{'_bands'};
389 =head2 group
391 Title : group
392 Usage : $cloneobj->group($chrno);
393 Function: Get/set the group number for this clone.
394 This is a generic term, used for Linkage-Groups as well as for
395 Chromosomes.
396 Returns : scalar representing the group number of this clone
397 Args : none to get, OR string to set
399 =cut
401 sub group {
402 my ($self) = shift;
403 return $self->{'_group'} = shift if @_;
404 return $self->{'_group'};
407 =head2 contigid
409 Title : contigid
410 Usage : my $ctg = $cloneobj->contigid();
411 Function: Get/set the contig this clone belongs to
412 Returns : scalar representing the contig
413 Args : none to get, OR string to set
415 =cut
417 sub contigid {
418 my ($self) = shift;
419 $self->{'_contig'} = shift if @_;
420 return $self->{'_contig'} || 0;
423 =head2 each_markerid
425 Title : each_markerid
426 Usage : @markers = $cloneobj->each_markerid();
427 Function: retrieves all the elements in a map unordered
428 Returns : list of strings (ids)
429 Args : none
431 *** This only supplies the ids set with the set_markers method ***
432 *** It has nothing to do with actual Bio::Map::MarkerI objects ***
434 =cut
436 sub each_markerid {
437 my ($self,$value) = @_;
438 return @{$self->{"_markers"}};
441 =head2 set_markers
443 Title : markers
444 Usage : $obj->set_markers($newval)
445 Function: Set list of Marker ids (arrayref)
446 Returns : None
447 Args : arrayref of strings (ids)
449 *** This only sets a list of ids ***
450 *** It has nothing to do with actual Bio::Map::MarkerI objects ***
452 =cut
454 sub set_markers {
455 my ($self,$markers) = @_;
456 if( defined $markers && ref($markers) =~ /ARRAY/ ) {
457 $self->{'_markers'} = $markers;