Bio::DB::EUtilities
ElinkData
Summary
Bio::DB::EUtilities::ElinkData
Package variables
No package variables defined.
Inherit
Synopsis
*** Give standard usage here
Description
*** Describe the object here
Methods
Methods description
Title : elink_dbfrom Usage : $dbfrom = $linkset->elink_dbfrom; Function: gets/sets dbfrom value Returns : originating database Args : originating database |
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 |
Title : elink_command Usage : $cmd = $linkset->elink_command; Function: gets/sets cmd used for elink query Returns : string (cmd parameter) Args : string (cmd parameter) |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Title : set_scoredb Usage : $linkset->set_scoredb('protein'); Function: sets the database to retrieve scores from Returns : None Args : database name |
Title : rewind_linkdbs Usage : $linkset->rewind_linkdbs; Function: resets the iterator for next_database Returns : None Args : None |
Title : rewind_scoredbs Usage : $linkset->rewind_scoredbs; Function: resets the iterator, current database for next_scoredb Returns : None Args : None |
Methods code
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;} |
sub _add_set
{ my ($self, $ls) = @_;
if (!$ls) {
$self->throw('No linkset data!');
}
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;
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;
if ($score) {
$self->{'_scores'}->{$dbto}->{$id} = $score;
if (!($self->{'_has_scores'})) {
push @{ $self->{'_has_scores'} }, $dbto;
}
}
}
my $linkset = {
'LinkName' => $linkname,
'DbTo' => $dbto,
'Id' =>\@ ids,
};
push @{ $self->{'_linksetdb'}}, $linkset;
}
return 1;
} |
sub elink_dbfrom
{ my $self = shift;
return $self->{'_elink_dbfrom'} = shift if @_;
return $self->{'_elink_dbfrom'};} |
sub elink_queryids
{ my $self = shift;
return $self->{'_elink_queryids'} = shift if @_;
return @{ $self->{'_elink_queryids'} } if wantarray;
return $self->{'_elink_queryids'};} |
sub elink_command
{ my $self = shift;
return $self->{'_elink_command'} = shift if @_;
return $self->{'_elink_command'};} |
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; 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");} |
sub next_linkdb
{ my $self = shift;
my $index = $self->_next_db_index;
return if ($index > scalar($self->{'_databases'}));
return $self->{'_databases'}->[$index] ;} |
sub get_all_linkdbs
{ my $self = shift;
return @{ $self->{'_databases'} } if wantarray;
return $self->{'_databases'};} |
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;} |
sub get_all_scoredbs
{ my $self = shift;
return @{ $self->{'_has_scores'} } if wantarray;
return $self->{'_has_scores'}->[0];} |
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};
}} |
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} };
}} |
sub set_scoredb
{ my ($self, $key) = shift;
$self->{'_scoredb'} if $key;} |
sub rewind_linkdbs
{ my $self = shift;
$self->{'_dbindex'} = 0;} |
sub rewind_scoredbs
{ my $self = shift;
$self->{'_scoreindex'} = 0;
$self->{'_scoredb'} = '';} |
sub _next_db_index
{ my $self = shift;
return $self->{'_dbindex'}++;} |
| _next_scoredb_index | description | prev | next | Top |
sub _next_scoredb_index
{ my $self = shift;
return $self->{'_scoreindex'}++;} |
General documentation
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
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/
Email cjfields at uiuc dot edu
The rest of the documentation details each of the
object methods. Internal methods are usually
preceded with a _