[Bioperl-l] can't retrieve description using Bio::DB::EntrezGene

Carnë Draug carandraug+dev at gmail.com
Fri Jul 15 02:48:03 UTC 2011


On 14 July 2011 08:54, jmi k <bi_my_heart at hotmail.com> wrote:
>
> Hi,
> I'm trying to retrieve the description of a gene's file using Bio::DB::EntrezGene.  Here is the relevant code from my program:
> use Bio::DB::EntrezGene;use Bio::ASN1::EntrezGene; # I think I have to include this
> I've found a similar discussion at http://old.nabble.com/Bio::DB::EntrezGene-or-Bio::DB::Query::GenBank-to-obtain-sequence-metadata-without-sequence-td25816381.html but I don't understand why they can't use Bio::DB::EntrezGene directly.
> Thanks in advance!
> Regards,Jamie

Hi Jamie,

Your code works fine for me. Please always paste ALL of your code, not
only the part where you think the error is. It's doesn't take long to
do so, you get the answer to your problem faster and everyone wastes
less time in the end. If it's a long piece of code use pastebin
http://pastebin.com/ Also, please paste it properly formatted, not all
in one line.

Despite the fact that works, you're doing some unnecessary things such
as creating a Bio::Seq object that you then write over it with the
get_seq_by_id method. This should already return the sequence object,
no need to create it first.

Anyway, here's how to do it with Bio::DB::EUtilities (it's not the
answer to your question but if you're having trouble with EntrezGene
and don't mind which module to use to get the job done...)

use Bio::DB::EUtilities;
my $eutil = Bio::DB::EUtilities->new(
                                      -eutil => 'esummary',
                                      -db    => 'gene',
                                      -id    => $ref_to_array_with_uids
                                     );

while (my $docsum = $eutil->next_DocSum) {
  my ($description) = $docsum->get_contents_by_name('Description');
  my ($summary) = $docsum->get_contents_by_name('Summary');
  say $description;
  say $summary;
}

You can also use the methods to_string on $docsum to get a nice view
of it and what contents you have retrieved. The get_Item_by_name
method is also handy.

Also, replace say with print and a newline if you're not using an up
to date version of perl or upgrade your versoin of perl ;)

Carnë




More information about the Bioperl-l mailing list