3 # bioperl module for Bio::Coordinate::Result
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
9 # Copyright Heikki Lehvaslaiho
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Coordinate::Result - Results from coordinate transformation
21 use Bio::Coordinate::Result;
23 #get results from a Bio::Coordinate::MapperI
24 $matched = $result->each_match;
28 The results from Bio::Coordinate::MapperI are kept in an object which
29 itself is a split location, See L<Bio::Location::Split>. The results
30 are either Matches or Gaps. See L<Bio::Coordinate::Result::Match> and
31 L<Bio::Coordinate::Result::Gap>.
33 If only one Match is returned, there is a convenience method of
34 retrieving it or accessing its methods. Same holds true for a Gap.
40 User feedback is an integral part of the evolution of this and other
41 Bioperl modules. Send your comments and suggestions preferably to the
42 Bioperl mailing lists Your participation is much appreciated.
44 bioperl-l@bioperl.org - General discussion
45 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
49 Please direct usage questions or support issues to the mailing list:
51 L<bioperl-l@bioperl.org>
53 rather than to the module maintainer directly. Many experienced and
54 reponsive experts will be able look at the problem and quickly
55 address it. Please include a thorough description of the problem
56 with code and data examples if at all possible.
60 report bugs to the Bioperl bug tracking system to help us keep track
61 the bugs and their resolution. Bug reports can be submitted via the
64 http://bugzilla.open-bio.org/
66 =head1 AUTHOR - Heikki Lehvaslaiho
68 Email: heikki-at-bioperl-dot-org
72 The rest of the documentation details each of the object
73 methods. Internal methods are usually preceded with a _
78 # Let the code begin...
80 package Bio
::Coordinate
::Result
;
84 use base
qw(Bio::Location::Split Bio::Coordinate::ResultI);
89 Title : add_sub_Location
90 Usage : $obj->add_sub_Location($variant)
93 Pushes one Bio::LocationI into the list of variants.
96 Returns : 1 when succeeds
97 Args : Location object
101 sub add_sub_Location
{
102 my ($self,$value) = @_;
104 $self->warn("provding an empty value for location\n");
107 $self->throw("Is not a Bio::LocationI but [$value]")
108 unless $value->isa('Bio::LocationI');
110 $self->{'_match'} = $value
111 if $value->isa('Bio::Coordinate::Result::Match');
113 $self->{'_gap'} = $value
114 if $value->isa('Bio::Coordinate::Result::Gap');
116 $self->SUPER::add_sub_Location
($value);
123 Usage : $obj->add_result($result)
124 Function: Adds the contents of one Bio::Coordinate::Result
126 Returns : 1 when succeeds
132 my ($self,$value) = @_;
134 $self->throw("Is not a Bio::Coordinate::Result but [$value]")
135 unless $value->isa('Bio::Coordinate::Result');
137 map { $self->add_sub_Location($_) } $value->each_Location;
143 Usage : my $seqid = $location->seq_id();
144 Function: Get/Set seq_id that location refers to
146 We override this here in order to propagate to all sublocations
147 which are not remote (provided this root is not remote either)
150 Args : [optional] seq_id value to set
156 my ($self, $seqid) = @_;
158 my @ls = $self->each_Location;
160 return $ls[0]->seq_id;
167 =head2 Convenience methods
169 These methods are shortcuts to Match and Gap locations.
176 Usage : $obj->each_gap();
179 Returns a list of Bio::Coordianate::Result::Gap objects.
181 Returns : list of gaps
190 foreach my $gap ($self->each_Location) {
191 push @gaps, $gap if $gap->isa('Bio::Coordinate::Result::Gap');
201 Usage : $obj->each_match();
204 Returns a list of Bio::Coordinate::Result::Match objects.
206 Returns : list of Matchs
215 foreach my $match ($self->each_Location) {
216 push @matches, $match if $match->isa('Bio::Coordinate::Result::Match');
224 Usage : $match_object = $obj->match(); #or
225 $gstart = $obj->gap->start;
226 Function: Read only method for retrieving or accessing the match object.
227 Returns : one Bio::Coordinate::Result::Match
235 $self->warn("More than one match in results")
236 if $self->each_match > 1 and $self->verbose > 0;
237 unless (defined $self->{'_match'} ) {
238 my @m = $self->each_match;
239 $self->{'_match'} = $m[-1];
241 return $self->{'_match'};
247 Usage : $gap_object = $obj->gap(); #or
248 $gstart = $obj->gap->start;
249 Function: Read only method for retrieving or accessing the gap object.
250 Returns : one Bio::Coordinate::Result::Gap
258 $self->warn("More than one gap in results")
259 if $self->each_gap > 1 and $self->verbose > 0;
260 unless (defined $self->{'_gap'} ) {
261 my @m = $self->each_gap;
262 $self->{'_gap'} = $m[-1];
264 return $self->{'_gap'};
271 Usage : $gap_count = $obj->purge_gaps;
272 Function: remove all gaps from the Result
273 Returns : count of removed gaps
283 foreach my $loc ($self->each_Location) {
284 if ($loc->isa('Bio::Coordinate::Result::Match')) {
290 @
{$self->{'_sublocations'}} = ();
291 delete $self->{'_gap'} ;
292 push @
{$self->{'_sublocations'}}, @matches;