Allowing a list of ids for -id of Bio::DB::EUtilities->new()?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Allowing a list of ids for -id of Bio::DB::EUtilities->new()?

Peng Yu
Hi,

To allow multiple ids, I have to manually concatenate ids in the form
of a string '19008417,19008416'. Would it be better to allow it take
the form of a list ('19008417', '19008416').


#!/usr/bin/env perl

use strict;
use warnings;
use Bio::DB::EUtilities;
use XML::Simple;
use Data::Dumper;

my $factory = Bio::DB::EUtilities->new(
  -eutil => 'efetch',
  -db => 'pubmed',
  -email => '[hidden email]',
  -id => '19008417,19008416',
  -retmode => 'xml',
);

#print $factory->get_Response->content;

my $string=$factory->get_Response->content;
print $string, "\n";
my $xml=new XML::Simple;
my $data = $xml->XMLin($string);
print Dumper($data);


--
Regards,
Peng
_______________________________________________
Bioperl-l mailing list
[hidden email]
http://mailman.open-bio.org/mailman/listinfo/bioperl-l
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Allowing a list of ids for -id of Bio::DB::EUtilities->new()?

Fields, Christopher J
It does allow multiples, note Russell’s example (note it has to be passed as a reference).  

my @ids     = qw(200039684 200039685);
my $factory = Bio::DB::EUtilities->new(-eutil  => 'elink',
                                      -email  => '[hidden email]',
                                      -db     => 'pubmed',
                                      -dbfrom => 'gds',
                                      -id     => \@ids);

The ‘single ID’ form is a convenience; the fact it works when you concatenate the IDs and pass them in as one string is happenstance, only b/c it’s doing that for you behind the scenes when you pass the IDs as a ref.

chris

> On Jun 16, 2015, at 8:36 PM, Peng Yu <[hidden email]> wrote:
>
> Hi,
>
> To allow multiple ids, I have to manually concatenate ids in the form
> of a string '19008417,19008416'. Would it be better to allow it take
> the form of a list ('19008417', '19008416').
>
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use Bio::DB::EUtilities;
> use XML::Simple;
> use Data::Dumper;
>
> my $factory = Bio::DB::EUtilities->new(
>  -eutil => 'efetch',
>  -db => 'pubmed',
>  -email => '[hidden email]',
>  -id => '19008417,19008416',
>  -retmode => 'xml',
> );
>
> #print $factory->get_Response->content;
>
> my $string=$factory->get_Response->content;
> print $string, "\n";
> my $xml=new XML::Simple;
> my $data = $xml->XMLin($string);
> print Dumper($data);
>
>
> --
> Regards,
> Peng
> _______________________________________________
> Bioperl-l mailing list
> [hidden email]
> http://mailman.open-bio.org/mailman/listinfo/bioperl-l


_______________________________________________
Bioperl-l mailing list
[hidden email]
http://mailman.open-bio.org/mailman/listinfo/bioperl-l
Loading...