Bio::DB GDB
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::DB::GDB - Database object interface to GDB HTTP query
Package variables
Privates (from "my" definitions)
($len) = ( $text =~ /(\d+\.\d+)/)
$lasttag = ''
$resp = $self->_request(GET $markerurl)
( $tag ) = @_
($name,$primer) = split(/\s+/,$l)
Included modules
Bio::Root::Root
HTML::Parser
HTTP::Request::Common
LWP::UserAgent
Inherit
Bio::Root::Root
Synopsis
    $gdb = new Bio::DB::GDB;

    $info = $gdb->get_info(-type=>'marker',
			     -id=>'D1S243'); # Marker name

   print "genbank id is ", $info->{'gdbid'},
    "\nprimers are (fwd, rev) ", join(",", @{$info->{'primers'}}), 
    "\nproduct length is ", $info->{'length'}, "\n";
Description
This class allows connections to the Genome Database (GDB) and queries
to retrieve any database objects. See http://www.gdb.org/ or any
mirror for details.
Methods
new
No description
Code
uaDescriptionCode
get_paramsDescriptionCode
get_infoDescriptionCode
get_requestDescriptionCode
_request
No description
Code
_gdb_search_tag_start
No description
Code
Methods description
uacode    nextTop
 Title   : ua
 Usage   : my $ua = $self->ua or 
           $self->ua($ua)
 Function: Get/Set a LWP::UserAgent for use
 Returns : reference to LWP::UserAgent Object
 Args    : $ua - must be a LWP::UserAgent
get_paramscodeprevnextTop
 Title   : get_params
 Usage   : my %params = $self->get_params($mode)
 Function: Returns key,value pairs to be passed to query
            for mode ('marker', 'gene')
 Returns : a key,value pair hash
 Args    : 'marker' or 'gene' mode for retrieval
get_infocodeprevnextTop
 Title   : get_info
 Usage   : my $info = $self->get_info(-type => 'marker',
				      -id   => 'D1S234'); 
 Function: Returns key,value pairs specific
 Returns : a key,value pair hash
 Args    : -type => 'marker' or 'gene' mode for retrieval
           -id   => unique id to query for
get_requestcodeprevnextTop
 Title   : get_request
 Usage   : my $url = $self->get_request
 Function: HTTP::Request
 Returns : 
 Args    : %qualifiers = a hash of qualifiers (ids, format, etc)
Methods code
newdescriptionprevnextTop
sub new {
    my($class,@args) = @_;
    my $self = $class->SUPER::new(@args);
    
    my $ua = new LWP::UserAgent;
    $ua->agent(ref($self) ."/$MODVERSION");
    $self->ua($ua);    

    return $self;
}
uadescriptionprevnextTop
sub ua {
    my ($self, $ua) = @_;
    if( defined $ua && $ua->isa("LWP::UserAgent") ) {
	$self->{_ua} = $ua;
    }
    return $self->{_ua};
}
get_paramsdescriptionprevnextTop
sub get_params {
    my ($self, $mode) = @_;
    return %{$PARAMSTRING{$mode}};
}
get_infodescriptionprevnextTop
sub get_info {
    my ($self, @args) = @_;
    my ( $type, $id) = $self->_rearrange([qw(TYPE ID)], @args);
    if( !defined $type ) {
	$self->throw("Must specify a type you are querying for");
    } elsif( !defined $id ) {
	$self->throw("Must specify a id to query for");
    }
    my %params = $self->get_params($type);

    $params{'displayName'} = $id;

    if( $type eq 'marker' ) {
	# do more specific stuff?
} elsif( $type eq 'gene' ) { # do more specific stuff?
} my $url = $self->get_request(%params); my ($resp) = $self->_request($url); if( ! defined $resp || ! ref($resp) ) { $self->warn("Did not get any data for url ". $url->uri); return undef; } my $content = $resp->content; if( $content =~ /ERROR/ || length($resp->content) == 0 ) { $self->warn("Error getting for url " . $url->uri . "!\n"); return undef; } my (@primers, $length, $markerurl, $realname); my $state = 0; my $title = 0; my $p; $p = new HTML::Parser( api_version => 3, start_h => [ sub { return if( $title == 2 || $state == 3); my($tag,$attr,$text) = @_; return if( !defined $tag); if( $tag eq 'table' ) { $state = 1; } elsif( $tag eq 'title' ) { $title = 1; } elsif( $state == 2 && $tag eq 'a' && $attr->{'href'} ) { $state = 3; if( $text =~ m(href="?(http://.+)"?\s*>) ) { $markerurl = $1; } } }, "tagname, attr, text" ],
}
get_requestdescriptionprevnextTop
sub get_request {
    my ($self, %params) = @_;
    if( ! %params ) {
	$self->throw("must provide parameters with which to query");
    }
    my $url = $BASEADDRESS;    
    my $querystr = '?' . join("&", map { "$_=$params{$_}" } keys %params);
    return GET $url . $querystr;
}
_requestdescriptionprevnextTop
sub _request {
    my ($self, $url,$tmpfile) = @_;
    my ($resp);
    if( defined $tmpfile && $tmpfile ne '' ) { 
	$resp =  $self->ua->request($url, $tmpfile);
    } else { $resp =  $self->ua->request($url); } 

    if( $resp->is_error  ) {
	$self->warn($resp->as_string() . "\nError getting for url " .
		     $url->uri . "!\n");
	return undef;
    }
    return $resp;
}
_gdb_search_tag_startdescriptionprevnextTop
sub _gdb_search_tag_start {
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the
evolution of this and other Bioperl modules. Send
your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation
is much appreciated.
  bioperl-l@bioperl.org              - General discussion
  http://bioperl.org/MailList.shtml  - About the mailing lists
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to
help us keep track the bugs and their resolution.
Bug reports can be submitted via email or the
web:
  bioperl-bugs@bio.perl.org
  http://bugzilla.bioperl.org/
AUTHOR - Jason StajichTop
Email jason@bioperl.org
APPENDIXTop
The rest of the documentation details each of the
object methods. Internal methods are usually
preceded with a _