Bio::DB::EUtilities ElinkData
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::DB::EUtilities::ElinkData
Package variables
No package variables defined.
Inherit
Bio::Root::Root
Synopsis
*** Give standard usage here
Description
*** Describe the object here
Methods
new
No description
Code
_add_set
No description
Code
elink_dbfromDescriptionCode
elink_queryidsDescriptionCode
elink_commandDescriptionCode
get_LinkIds_by_dbDescriptionCode
next_linkdbDescriptionCode
get_all_linkdbsDescriptionCode
next_scoredbDescriptionCode
get_all_scoredbsDescriptionCode
get_scoreDescriptionCode
get_score_hashDescriptionCode
set_scoredbDescriptionCode
rewind_linkdbsDescriptionCode
rewind_scoredbsDescriptionCode
_next_db_index
No description
Code
_next_scoredb_index
No description
Code
Methods description
elink_dbfromcode    nextTop
 Title   : elink_dbfrom
Usage : $dbfrom = $linkset->elink_dbfrom;
Function: gets/sets dbfrom value
Returns : originating database
Args : originating database
elink_queryidscodeprevnextTop
 Title   : elink_queryids
Usage : @ids = $linkset->elink_queryids;
Function: gets/sets original query ID values (ref to array)
Returns : array or array ref of IDs (based on wantarray)
Args : array ref of IDs
elink_commandcodeprevnextTop
 Title   : elink_command
Usage : $cmd = $linkset->elink_command;
Function: gets/sets cmd used for elink query
Returns : string (cmd parameter)
Args : string (cmd parameter)
get_LinkIds_by_dbcodeprevnextTop
 Title   : get_LinkIds_by_db
Usage : @ids = $linkset->get_LinkIds_by_db('protein');
Function: retrieves primary ID list based on the database for the object
Returns : array or array ref of IDs (based on wantarray)
Args : None
next_linkdbcodeprevnextTop
 Title   : next_linkdb
Usage : while (my $db = $linkset->next_linkdb) {
Function: iterates through list of database names in internal queue
Returns : String (name of database)
Args : None
get_all_linkdbscodeprevnextTop
 Title   : get_all_linkdbs
Usage : @dbs = $linkset->get_all_linkdbs;
Function: returns all database names which contain IDs
Returns : array or array ref of databases (based on wantarray)
Args : None
next_scoredbcodeprevnextTop
 Title   : next_scoredb
Usage : while (my $db = $linkset->next_scoredb) {
Function: iterates through list of database with score values
Returns : String (name of database)
Args : None
get_all_scoredbscodeprevnextTop
 Title   : get_all_scoredbs
Usage : @dbs = $linkset->get_all_scoredbs;
Function: returns database names which contain scores
Returns : array or array ref of databases (based on wantarray)
Args : None
get_scorecodeprevnextTop
 Title   : get_score
Usage : $score = $linkset->get_score($id);
Function: returns score value for ID
Returns : score value
Args : ID
Note : if multiple databases are returned with scores (rare but possible),
: you must set the default score database using set_scoredb. If you
: use next_scoredb to iterate through the databases, this is done for you
get_score_hashcodeprevnextTop
 Title   : get_score_hash
Usage : %scores = $linkset->get_score_hash($database);
Function: returns ID(key)-score(value) hash based on database name
Returns : score value
Args : OPTIONAL : database name. If there is only one score hash, returns
: that hash, otherwise throws an exception
set_scoredbcodeprevnextTop
 Title   : set_scoredb
Usage : $linkset->set_scoredb('protein');
Function: sets the database to retrieve scores from
Returns : None
Args : database name
rewind_linkdbscodeprevnextTop
 Title   : rewind_linkdbs
Usage : $linkset->rewind_linkdbs;
Function: resets the iterator for next_database
Returns : None
Args : None
rewind_scoredbscodeprevnextTop
 Title   : rewind_scoredbs
Usage : $linkset->rewind_scoredbs;
Function: resets the iterator, current database for next_scoredb
Returns : None
Args : None
Methods code
newdescriptionprevnextTop
sub new {
    my ($class, @args) = @_;
    my $self = $class->SUPER::new(@args);
    my ($command) = $self->_rearrange([qw(COMMAND)], @args);
    $command    && $self->elink_command($command);
    $self->{'_dbindex'} = 0;
    $self->{'_scoreindex'} = 0;
    $self->{'_linkcount'} = 0;
    $self->{'_scoredb_key'} = '';
    $self->{'_databases'} = [];
    $self->{'_linksetdb'} = [];
    return $self;
}
_add_setdescriptionprevnextTop
sub _add_set {
    my ($self, $ls) = @_;
    if (!$ls) {
        $self->throw('No linkset data!');
    }
    # is there any data returned
return 0 unless exists $ls->{LinkSetDb}; my $dbfrom = $ls->{DbFrom}; $self->elink_dbfrom($dbfrom); my $query_ids = $ls->{IdList}->{Id}; if (!ref($query_ids)) { my $tempid = $query_ids; $query_ids = [$tempid]; } $self->elink_queryids($query_ids); my $ct = 0; # each linkset database
for my $ls_db (@{ $ls->{LinkSetDb} }) { $ct++; my $dbto = $ls_db->{DbTo} ; push @{ $self->{'_databases'}}, $dbto; my $linkname = $ls_db->{LinkName}; if (exists $ls_db->{Info} || exists $ls->{ERROR} || !exists $ls_db->{Link}) { my $err_msg = $ls_db->{Info} || $ls->{ERROR} || 'No Links!'; my $ids = (ref($query_ids) =~ /array/i) ? join q(,), @{$query_ids}: $query_ids; $self->warn("ELink Error for $dbto and ids $ids: $err_msg"); next; } my @ids; for my $id_ref (@{ $ls_db->{Link} } ) { my $id = $id_ref->{Id}; my $score = exists $id_ref->{Score} ? $id_ref->{Score} : undef; push @ids, $id; # set up in case there are multiple databases that return scores
if ($score) { $self->{'_scores'}->{$dbto}->{$id} = $score; if (!($self->{'_has_scores'})) { push @{ $self->{'_has_scores'} }, $dbto; } } } my $linkset = { 'LinkName' => $linkname, 'DbTo' => $dbto, 'Id' =>\@ ids, }; #$self->debug('Linkset:',Dumper($linkset));
push @{ $self->{'_linksetdb'}}, $linkset; } return 1; # good linkset
}
elink_dbfromdescriptionprevnextTop
sub elink_dbfrom {
    my $self = shift;
    return $self->{'_elink_dbfrom'} = shift if @_;
    return $self->{'_elink_dbfrom'};
}
elink_queryidsdescriptionprevnextTop
sub elink_queryids {
    my $self = shift;
    return $self->{'_elink_queryids'} = shift if @_;
    return @{ $self->{'_elink_queryids'} } if wantarray;
    return $self->{'_elink_queryids'};
}
elink_commanddescriptionprevnextTop
sub elink_command {
    my $self = shift;
    return $self->{'_elink_command'} = shift if @_;
    return $self->{'_elink_command'};
}
get_LinkIds_by_dbdescriptionprevnextTop
sub get_LinkIds_by_db {
    my $self = shift;
    my $db = shift if @_;
    $self->throw("Must use database to access IDs") if !$db;
    my $ct = scalar(@{ $self->{'_linksetdb'} });
    return [] if $ct == 0; # no linksets, blank anon array
for my $linkset (@{ $self->{'_linksetdb'}}) { my $dbto = $linkset->{DbTo}; if ($dbto eq $db) { return @{ $linkset->{Id} } if wantarray; return $linkset->{Id}; } } $self->warn("Couldn't find ids for database $db");
}
next_linkdbdescriptionprevnextTop
sub next_linkdb {
    my $self = shift;
    my $index = $self->_next_db_index;
    return if ($index > scalar($self->{'_databases'}));
    return $self->{'_databases'}->[$index] ;
}
get_all_linkdbsdescriptionprevnextTop
sub get_all_linkdbs {
    my $self = shift;
    return @{ $self->{'_databases'} } if wantarray;
    return $self->{'_databases'};
}
next_scoredbdescriptionprevnextTop
sub next_scoredb {
    my $self = shift;
    my $index = $self->_next_scoredb_index;
    return if ($index > scalar($self->{'_has_scores'}));
    my $db = $self->{'_has_scores'}->[$index];
    $self->set_scoredb($db);
    return $db;
}
get_all_scoredbsdescriptionprevnextTop
sub get_all_scoredbs {
    my $self = shift;
    return @{ $self->{'_has_scores'} } if wantarray;
    return $self->{'_has_scores'}->[0];
}
get_scoredescriptionprevnextTop
sub get_score {
    my $self = shift;
    my $id = shift if @_;
    if (!$self->get_all_scoredbs) {
        $self->warn("No scores!");
        return;
    }
    if (!$id) {
        $self->throw("Must use ID to access scores");
        return;
    }
    my $db = exists $self->{'_scoredb'} ? $self->{'_scoredb'} :
             $self->get_all_scoredbs;
    if ( exists $self->{'_scores'}->{$db}->{$id} ) {
        return $self->{'_scores'}->{$db}->{$id};
    }
}
get_score_hashdescriptionprevnextTop
sub get_score_hash {
    my $self = shift;
    $self->warn("No scores!") if !$self->has_scores;
    my $db = exists $self->{'_scoredb'} ? $self->{'_scoredb'} : $self->has_scores;
    if (exists $self->{'_scores'}->{$db}) {
        return %{ $self->{'_scores'}->{$db} };
    }
}
set_scoredbdescriptionprevnextTop
sub set_scoredb {
    my ($self, $key) = shift;
    $self->{'_scoredb'} if $key;
}
rewind_linkdbsdescriptionprevnextTop
sub rewind_linkdbs {
    my $self = shift;
    $self->{'_dbindex'} = 0;
}
rewind_scoredbsdescriptionprevnextTop
sub rewind_scoredbs {
    my $self = shift;
    $self->{'_scoreindex'} = 0;
    $self->{'_scoredb'} = '';
}
_next_db_indexdescriptionprevnextTop
sub _next_db_index {
    my $self = shift;
    return $self->{'_dbindex'}++;
}
_next_scoredb_indexdescriptionprevnextTop
sub _next_scoredb_index {
    my $self = shift;
    return $self->{'_scoreindex'}++;
}
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@lists.open-bio.org               - General discussion
http://www.bioperl.org/wiki/Mailing_lists - 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 the web.
  http://bugzilla.open-bio.org/
AUTHOR Top
Email cjfields at uiuc dot edu
APPENDIXTop
The rest of the documentation details each of the
object methods. Internal methods are usually
preceded with a _