sync w/ main trunk
[bioperl-live.git] / Bio / Map / Clone.pm
blobbd2e2fb22af754be80e9bd83359e6447bd9695bf
1 # $Id$
3 # BioPerl module for Bio::Map::clone
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Sendu Bala <bix@sendu.me.uk>
9 # Copyright Gaurav Gupta
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::Map::Clone - An central map object representing a clone
19 =head1 SYNOPSIS
21 # get the clone object of $clone from the Bio::Map::Clone
22 my $cloneobj = $physical->get_cloneobj($clone);
24 # acquire all the markers that hit this clone
25 foreach my $marker ($cloneobj->each_markerid()) {
26 print " +++$marker\n";
29 See L<Bio::Map::Position> and L<Bio::Map::PositionI> for more information.
31 =head1 DESCRIPTION
33 This object handles the notion of a clone. This clone will
34 have a name and a position in a map.
36 This object is intended to be used by a map parser like fpc.pm.
38 =head1 FEEDBACK
40 =head2 Mailing Lists
42 User feedback is an integral part of the evolution of this and other
43 Bioperl modules. Send your comments and suggestions preferably to
44 the Bioperl mailing list. Your participation is much appreciated.
46 bioperl-l@bioperl.org - General discussion
47 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 =head2 Support
51 Please direct usage questions or support issues to the mailing list:
53 L<bioperl-l@bioperl.org>
55 rather than to the module maintainer directly. Many experienced and
56 reponsive experts will be able look at the problem and quickly
57 address it. Please include a thorough description of the problem
58 with code and data examples if at all possible.
60 =head2 Reporting Bugs
62 Report bugs to the Bioperl bug tracking system to help us keep track
63 of the bugs and their resolution. Bug reports can be submitted via the
64 web:
66 http://bugzilla.open-bio.org/
68 =head1 AUTHOR - Gaurav Gupta
70 Email gaurav@genome.arizona.edu
72 =head1 CONTRIBUTORS
74 Sendu Bala bix@sendu.me.uk
76 =head1 PROJECT LEADERS
78 Jamie Hatfield jamie@genome.arizona.edu
79 Dr. Cari Soderlund cari@genome.arizona.edu
81 =head1 PROJECT DESCRIPTION
83 The project was done in Arizona Genomics Computational Laboratory (AGCoL)
84 at University of Arizona.
86 This work was funded by USDA-IFAFS grant #11180 titled "Web Resources for
87 the Computation and Display of Physical Mapping Data".
89 For more information on this project, please refer:
90 http://www.genome.arizona.edu
92 =head1 APPENDIX
94 The rest of the documentation details each of the object methods.
95 Internal methods are usually preceded with a _
97 =cut
99 # Let the code begin...
101 package Bio::Map::Clone;
102 use strict;
103 use Bio::Map::Position;
105 use base qw(Bio::Root::Root Bio::Map::MappableI);
107 =head2 new
109 Title : new
110 Usage : my $clone = Bio::Map::Clone->new
112 -name => $clone,
113 -markers => \@markers,
114 -contig => $contig,
115 -type => $type,
116 -bands => $bands,
117 -gel => $gel,
118 -group => $group,
119 -remark => $remark,
120 -fpnumber=> $fp_number,
121 -sequencetype => $seq_type,
122 -sequencestatus=> $seq_status,
123 -fpcremark => $fpc_remark,
124 -matche => \@ematch,
125 -matcha => \@amatch,
126 -matchp => \@pmatch,
127 -range => Bio::Range->new(-start => $startrange,
128 -end => $endrange)
130 Function: Initialize a new Bio::Map::Clone object
131 Most people will not use this directly but get Clones
132 through L<Bio::MapIO::fpc>
133 Returns : L<Bio::Map::Clone> object
134 Args : -name => marker name string,
135 -markers => array ref of markers,
136 -contig => contig name string,
137 -type => type string,
138 -bands => band string,
139 -gel => gel string,
140 -group => group name string,
141 -remark => remark string,
142 -fpnumber=> FP number string,
143 -sequencetype => seq type string,
144 -sequencestatus=> seq status string,
145 -fpcremark => FPC remark,
146 -matche => array ref,
147 -matcha => array ref,
148 -matchp => array ref,
149 -range => L<Bio::Range> object,
151 =cut
153 sub new {
154 my ($class,@args) = @_;
155 my $self= $class->SUPER::new(@args);
157 my ($name,$markers,$contig,$type,$bands,$gel,$group,
158 $remark,$fpnumber,$seqtype,$seqstatus,$fpcremark,
159 $matche,$matcha,$matchp,
160 $range) = $self->_rearrange([qw(NAME MARKERS CONTIG TYPE
161 BANDS GEL GROUP REMARK FPNUMBER
162 SEQUENCETYPE SEQUENCESTATUS
163 FPCREMARK MATCHE MATCHA MATCHP
164 RANGE)],@args);
166 $self->name($name) if defined $name;
167 $self->markers($markers) if defined $markers;
168 $self->contigid($contig) if defined $contig;
169 $self->type($type) if defined $type;
170 $self->bands($bands) if defined $bands;
171 $self->gel($gel) if defined $gel;
172 $self->group($group) if defined $group;
173 $self->remark($remark) if defined $remark;
174 $self->fp_number($fpnumber) if defined $fpnumber;
175 $self->sequence_type($seqtype) if defined $seqtype;
176 $self->sequence_status($seqstatus) if defined $seqstatus;
177 $self->fpc_remark($fpcremark) if defined $fpcremark;
178 $self->range($range) if defined $range;
180 $self->set_match('approx', $matcha) if defined $matcha;
181 $self->set_match('pseudo', $matchp) if defined $matchp;
182 $self->set_match('exact', $matche) if defined $matche;
184 return $self;
187 =head1 Access Methods
189 These methods let you get and set the member variables
191 =head2 name
193 Title : name
194 Usage : my $name = $cloneobj->name();
195 Function: Get/set the name for this Clone
196 Returns : scalar representing the current name of this clone
197 Args : none to get, OR string to set
199 =cut
201 sub name {
202 my ($self) = shift;
203 return $self->{'_name'} = shift if @_;
204 return $self->{'_name'};
207 =head2 type
209 Title : type
210 Usage : my $type = $cloneobj->type();
211 Function: Get/set the type for this clone
212 Returns : scalar representing the current type of this clone
213 Args : none to get, OR string to set
215 =cut
217 sub type {
218 my ($self) = shift;
219 return $self->{'_type'} = shift if @_;
220 return $self->{'_type'};
223 =head2 range
225 Title : range
226 Usage : my $range = $cloneobj->range();
227 Function: Get/set the range of the contig that this clone covers
228 Returns : Bio::Range representing the current range of this contig,
229 start and end of the contig can be thus found using:
230 my $start = $contigobj->range()->start();
231 my $end = $contigobj->range()->end();
232 Args : none to get, OR Bio::Range to set
234 =cut
236 sub range {
237 my ($self) = shift;
238 return $self->{'_range'} = shift if @_;
239 return $self->{'_range'};
242 =head2 match
244 Title : match
245 Usage : @eclone = $cloneobj->match('exact');
246 @aclone = $cloneobj->match('approximate');
247 @pclone = $cloneobj->match('pseudo');
248 Function: get all matching clones
249 Returns : list
250 Args : scalar representing the type of clone to be
251 queried.
253 =cut
255 sub match {
256 my ($self,$type) = @_;
258 $type = "_match" . lc(substr($type, 0, 1));
259 return @{$self->{$type} || []};
262 =head2 each_match
264 Title : each_match
265 Function: Synonym of the match() method.
267 =cut
269 *each_match = \&match;
271 =head2 set_match
273 Title : set_match
274 Usage : $clone->set_match($type,$values);
275 Function: Set the Matches per type
276 Returns : None
277 Args : type (one of 'exact' 'approx' 'pseudo')
278 array ref of match values
280 =cut
282 sub set_match{
283 my ($self,$type,$val) = @_;
284 $type = "_match" . lc(substr($type, 0, 1));
285 $self->{$type} = $val;
288 =head2 gel
290 Title : gel
291 Usage : $clonegel = $cloneobj->gel();
292 Function: Get/set the gel number for this clone
293 Returns : scalar representing the gel number of this clone
294 Args : none to get, OR string to set
296 =cut
298 sub gel {
299 my ($self) = shift;
300 return $self->{'_gel'} = shift if @_;
301 return $self->{'_gel'};
304 =head2 remark
306 Title : remark
307 Usage : $cloneremark = $cloneobj->remark();
308 Function: Get/set the remark for this clone
309 Returns : scalar representing the current remark of this clone
310 Args : none to get, OR string to set
312 =cut
314 sub remark {
315 my ($self) = shift;
316 return $self->{'_remark'} = shift if @_;
317 return $self->{'_remark'};
320 =head2 fp_number
322 Title : fp_number
323 Usage : $clonefpnumber = $cloneobj->fp_number();
324 Function: Get/set the fp number for this clone
325 Returns : scalar representing the fp number of this clone
326 Args : none to get, OR string to set
328 =cut
330 sub fp_number {
331 my ($self) = shift;
332 return $self->{'_fpnumber'} = shift if @_;
333 return $self->{'_fpnumber'};
336 =head2 sequence_type
338 Title : sequence_type
339 Usage : $cloneseqtype = $cloneobj->sequence_type();
340 Function: Get/set the sequence type for this clone
341 Returns : scalar representing the sequence type of this clone
342 Args : none to get, OR string to set
344 =cut
346 sub sequence_type {
347 my ($self) = shift;
348 return $self->{'_sequencetype'} = shift if @_;
349 return $self->{'_sequencetype'};
352 =head2 sequence_status
354 Title : sequence_status
355 Usage : $cloneseqstatus = $cloneobj->sequence_status();
356 Function: Get/set the sequence status for this clone
357 Returns : scalar representing the sequence status of this clone
358 Args : none to get, OR string to set
360 =cut
362 sub sequence_status {
363 my ($self) = shift;
364 return $self->{'_sequencestatus'} = shift if @_;
365 return $self->{'_sequencestatus'};
368 =head2 fpc_remark
370 Title : fpc_remark
371 Usage : $clonefpcremark = $cloneobj->fpc_remark();
372 Function: Get/set the fpc remark for this clone
373 Returns : scalar representing the fpc remark of this clone
374 Args : none to get, OR string to set
376 =cut
378 sub fpc_remark {
379 my ($self) = shift;
380 return $self->{'_fpcremark'} = shift if @_;
381 return $self->{'_fpcremark'};
384 =head2 bands
386 Title : bands
387 Usage : @clonebands = $cloneobj->bands();
388 Function: Get/set the bands for this clone
389 Returns : liat representing the band of this clone, if
390 readcor = 1 while creating the MapIO object and the
391 .cor exists
392 Args : none to get, OR string to set
394 =cut
396 sub bands {
397 my ($self) = shift;
398 return $self->{'_bands'} = shift if @_;
399 return $self->{'_bands'};
402 =head2 group
404 Title : group
405 Usage : $cloneobj->group($chrno);
406 Function: Get/set the group number for this clone.
407 This is a generic term, used for Linkage-Groups as well as for
408 Chromosomes.
409 Returns : scalar representing the group number of this clone
410 Args : none to get, OR string to set
412 =cut
414 sub group {
415 my ($self) = shift;
416 return $self->{'_group'} = shift if @_;
417 return $self->{'_group'};
420 =head2 contigid
422 Title : contigid
423 Usage : my $ctg = $cloneobj->contigid();
424 Function: Get/set the contig this clone belongs to
425 Returns : scalar representing the contig
426 Args : none to get, OR string to set
428 =cut
430 sub contigid {
431 my ($self) = shift;
432 $self->{'_contig'} = shift if @_;
433 return $self->{'_contig'} || 0;
436 =head2 each_markerid
438 Title : each_markerid
439 Usage : @markers = $cloneobj->each_markerid();
440 Function: retrieves all the elements in a map unordered
441 Returns : list of strings (ids)
442 Args : none
444 *** This only supplies the ids set with the set_markers method ***
445 *** It has nothing to do with actual Bio::Map::MarkerI objects ***
447 =cut
449 sub each_markerid {
450 my ($self,$value) = @_;
451 return @{$self->{"_markers"}};
454 =head2 set_markers
456 Title : markers
457 Usage : $obj->set_markers($newval)
458 Function: Set list of Marker ids (arrayref)
459 Returns : None
460 Args : arrayref of strings (ids)
462 *** This only sets a list of ids ***
463 *** It has nothing to do with actual Bio::Map::MarkerI objects ***
465 =cut
467 sub set_markers {
468 my ($self,$markers) = @_;
469 if( defined $markers && ref($markers) =~ /ARRAY/ ) {
470 $self->{'_markers'} = $markers;