Add tests for memory leaks and weaken for Issue #81
[bioperl-live.git] / Bio / Map / Prediction.pm
blob24e1fe2f56a4d7b84ec941891d90435e3681a438
1 # $Id: Prediction.pm,v 1.10 2006/09/28 14:09:40 sendu Exp $
3 # BioPerl module for Bio::Map::Prediction
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Sendu Bala <bix@sendu.me.uk>
9 # Copyright Sendu Bala
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::Prediction - An object representing the predictions of something
18 that can have multiple locations in several maps.
20 =head1 SYNOPSIS
22 use Bio::Map::Prediction;
23 use Bio::Map::Position;
25 # normally you would get predictions from a run wrapper like
26 # Bio::Tools::Run::Meme, but here we create some manually:
27 my $pred1 = Bio::Map::Prediction->new(-source => 'meme');
28 Bio::Map::Position->new(-element => $prediction1,
29 -map => Bio::Map::GeneMap->get(-gene => 'gene1',
30 -species => 'species1'),
31 -start => 950,
32 -end => 960);
33 Bio::Map::Position->new(-element => $prediction1,
34 -map => Bio::Map::GeneMap->get(-gene => 'gene1',
35 -species => 'species2'),
36 -start => 1950,
37 -end => 1960);
38 Bio::Map::Position->new(-element => $prediction1,
39 -map => Bio::Map::GeneMap->get(-gene => 'gene2',
40 -species => 'species1'),
41 -start => 955,
42 -end => 965);
43 Bio::Map::Position->new(-element => $prediction1,
44 -map => Bio::Map::GeneMap->get(-gene => 'gene2',
45 -species => 'species2'),
46 -start => 1955,
47 -end => 1965);
49 my $pred2 = Bio::Map::Prediction->new(-source => 'gerp');
50 Bio::Map::Position->new(-element => $prediction2,
51 -map => Bio::Map::GeneMap->get(-gene => 'gene1',
52 -species => 'species1'),
53 -start => 950,
54 -end => 960);
55 # etc.
57 # find the places where predictions agree
58 use Bio::Map::GeneRelative;
59 my $rel = Bio::Map::GeneRelative->new(-gene => 0);
60 my $di = Bio::Map::Mappable->disconnected_intersections([$pred1, $pred2],
61 -min_mappables_percent => 100,
62 -min_map_percent => 100,
63 -relative => $rel);
64 my @positions = $di->get_positions;
66 =head1 DESCRIPTION
68 For example, used to model transcription factor binding site predictions, which
69 can have multiple locations in several maps.
71 =head1 FEEDBACK
73 =head2 Mailing Lists
75 User feedback is an integral part of the evolution of this and other
76 Bioperl modules. Send your comments and suggestions preferably to the
77 Bioperl mailing list. Your participation is much appreciated.
79 bioperl-l@bioperl.org - General discussion
80 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
82 =head2 Support
84 Please direct usage questions or support issues to the mailing list:
86 I<bioperl-l@bioperl.org>
88 rather than to the module maintainer directly. Many experienced and
89 reponsive experts will be able look at the problem and quickly
90 address it. Please include a thorough description of the problem
91 with code and data examples if at all possible.
93 =head2 Reporting Bugs
95 Report bugs to the Bioperl bug tracking system to help us keep track
96 of the bugs and their resolution. Bug reports can be submitted via the
97 web:
99 https://github.com/bioperl/bioperl-live/issues
101 =head1 AUTHOR - Sendu Bala
103 Email bix@sendu.me.uk
105 =head1 APPENDIX
107 The rest of the documentation details each of the object methods.
108 Internal methods are usually preceded with a _
110 =cut
112 # Let the code begin...
114 package Bio::Map::Prediction;
115 use strict;
117 use base qw(Bio::Map::Mappable);
119 =head2 new
121 Title : new
122 Usage : my $prediction = Bio::Map::Prediction->new();
123 Function: Builds a new Bio::Map::Prediction object
124 Returns : Bio::Map::Prediction
125 Args : -name => string : name of the mappable element
126 -id => string : id of the mappable element
127 -source => string : name of the prediction program
129 =cut
131 sub new {
132 my ($class, @args) = @_;
133 my $self = $class->SUPER::new(@args);
135 my ($source) = $self->_rearrange([qw(SOURCE)], @args);
136 $self->source($source) if $source;
138 return $self;
141 =head2 source
143 Title : name
144 Usage : $mappable->name($new_name);
145 my $name = $mappable->name();
146 Function: Get/Set the name for this Mappable
147 Returns : A scalar representing the current name of this Mappable
148 Args : none to get
149 string to set
151 =cut
153 sub source {
154 my $self = shift;
155 if (@_) { $self->{_source} = shift }
156 return $self->{_source} || '';