FTLocationFactory.pm: Fixed a long-standing issue at "from_string()"
[bioperl-live.git] / Bio / DB / TFBS.pm
blob2309c5158f08dadc08b45d7efd12f26a8a29f2c4
1 # $Id: TFBS.pm,v 1.11 2006/08/12 11:00:03 sendu Exp $
3 # BioPerl module for Bio::DB::TFBS
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::DB::TFBS - Access to a Transcription Factor Binding Site database
19 =head1 SYNOPSIS
21 use Bio::DB::TFBS;
23 my $db = Bio::DB::TFBS->new(-source => 'transfac');
24 my ($factor_id) = $db->get_factor_ids('PPAR-gamma1');
25 my ($matrix_id) = $db->get_matrix_ids('PPAR-gamma1');
27 # get a Bio::Map::TranscriptionFactor with all the positions of a given factor
28 my $factor = $db->get_factor(-factor_id => $factor_id);
30 # get a Bio::Map::GeneMap containing all the factors that bind near a given gene
31 my $gene_map = $db->get_gene_map(-gene_name => 'AQP 7');
33 # get a PSM (Bio::Matrix::PSM) of a given matrix
34 my $psm = $db->get_matrix(-matrix_id => $matrix_id);
36 # get the aligned sequences (Bio::SimpleAlign) that were used to build a given
37 # matrix
38 my $align = $db->get_alignment(-matrix_id => $matrix_id);
40 # get a specific instance sequence (Bio::LocatableSeq)
41 my $seq = $db->get_seq($id);
43 =head1 DESCRIPTION
45 This is a front end module for access to a Transcription Factor Binding Site
46 database.
48 =head1 FEEDBACK
50 =head2 Mailing Lists
52 User feedback is an integral part of the evolution of this and other
53 Bioperl modules. Send your comments and suggestions preferably to
54 the Bioperl mailing list. Your participation is much appreciated.
56 bioperl-l@bioperl.org - General discussion
57 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
59 =head2 Support
61 Please direct usage questions or support issues to the mailing list:
63 I<bioperl-l@bioperl.org>
65 rather than to the module maintainer directly. Many experienced and
66 reponsive experts will be able look at the problem and quickly
67 address it. Please include a thorough description of the problem
68 with code and data examples if at all possible.
70 =head2 Reporting Bugs
72 Report bugs to the Bioperl bug tracking system to help us keep track
73 of the bugs and their resolution. Bug reports can be submitted via
74 the web:
76 https://github.com/bioperl/bioperl-live/issues
78 =head1 AUTHOR - Sendu Bala
80 Email bix@sendu.me.uk
82 =head1 CONTRIBUTORS
84 Based on Bio::DB::Taxonomy by Jason Stajich
86 =head1 APPENDIX
88 The rest of the documentation details each of the object methods.
89 Internal methods are usually preceded with a _
91 =cut
93 # Let the code begin...
95 package Bio::DB::TFBS;
96 use strict;
98 use Bio::Root::Root;
100 use base qw(Bio::Root::Root);
102 our $DefaultSource = 'transfac';
104 =head2 new
106 Title : new
107 Usage : my $obj = Bio::DB::TFBS->new(-source => 'transfac');
108 Function: Builds a new Bio::DB::TFBS object.
109 Returns : an instance of Bio::DB::TFBS
110 Args : -source => which database source: currently only 'transfac_pro'
112 =cut
114 sub new {
115 my ($class, @args) = @_;
117 if ($class =~ /Bio::DB::TFBS::(\S+)/) {
118 my ($self) = $class->SUPER::new(@args);
119 $self->_initialize(@args);
120 return $self;
122 else {
123 my %param = @args;
124 @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
125 my $source = $param{'-source'} || $DefaultSource;
127 $source = "\L$source"; # normalize capitalization to lower case
129 # normalize capitalization
130 return unless( $class->_load_tax_module($source) );
131 return "Bio::DB::TFBS::$source"->new(@args);
135 # empty for now
136 sub _initialize { }
138 =head2 _load_tax_module
140 Title : _load_tax_module
141 Usage : *INTERNAL Bio::DB::TFBS stuff*
142 Function: Loads up (like use) a module at run time on demand
144 =cut
146 sub _load_tax_module {
147 my ($self, $source) = @_;
148 my $module = "Bio::DB::TFBS::" . $source;
149 my $ok;
151 eval { $ok = $self->_load_module($module) };
152 if ( $@ ) {
153 print STDERR $@;
154 print STDERR <<END;
155 $self: $source cannot be found
156 Exception $@
157 For more information about the Bio::DB::TFBS system please see
158 the Bio::DB::TFBS docs. This includes ways of checking for
159 formats at compile time, not run time.
163 return $ok;