Re: Yeastmine Perl API access

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

Re: Yeastmine Perl API access

Alex Kalderimis-2
The good news is that this had nothing to do with you - There has been
some reasonably rapid development here, and YeastMine's webservices
are a little old now, which meant that the client code broke as it was
expecting different output. I have fixed this and uploaded the fix to
CPAN as 0.9809 - it should filter through to the mirrors in a couple
of hours. I tested it with your code, or rather the slightly modified
version below:

  #!/usr/bin/perl
  use strict;
  use warnings;
  use feature ':5.10';
 
  use Webservice::InterMine 0.9809 'yeastmine.yeastgenome.org/yeastmine';
 
  my $query = Webservice::InterMine->new_query;
 
  # views
  $query->add_view(qw/
          Gene.primaryIdentifier
          Gene.featureType
  /);

  # I just added this because otherwise you just get a lot of undef featureTypes back... Feel free to remove
  $query->add_constraint("featureType", "IS NOT NULL");
 
  # BIG PROBLEM (hopefully not any more! :) )
  # retrieve as hash ref (well, ResultRows actually, but you use them as hashrefs!
  for (my $i = $query->iterator(size => 100); my $row = <$i>;) {
    printf "ID: %s, FT: %s\n", $row->{primaryIdentifier}, $row->{featureType};
  }
 
  # And you can use them as arrayrefs too!
  for (my $i = $query->iterator(size => 100); my $row = <$i>;) {
    printf "ID: %s, FT: %s\n", @$row;
  }

  __END__

Also check out the documentation online at CPAN (http://search.cpan.org/perldoc?Webservice::InterMine),
and our tutorials:
  * http://search.cpan.org/perldoc?Webservice::InterMine::Cookbook
  * http://www.intermine.org/wiki/WebservicesTutorial

Thanks for reporting this error and helping improve our code.

Alex

On Mon, Aug 08, 2011 at 04:26:29PM +0100, Kai Kruse wrote:

> Dear Alex,
>
> Sven Sewitz kindly gave me your email address - I am a PhD student in the
> work group of Madan Babu. Currently I am realising the benefit of using the
> yeastmine API in my own work and was hoping you could help me with a
> (seemingly) simple query to the yeastmine database.
>
> When running the sample script that I have attached I obtain the following
> error multiple times:
>
> Use of uninitialized value $_[0] in concatenation (.) or string at native
> delegation method Webservice::InterMine::Parser::JSON::add_to_header
> (append) of attribute header (defined at
> /lmb/home/kkruse/perl5/perlbrew/perls/perl-5.15.1/lib/site_perl/5.15.1/Webservice/InterMine/Parser/JSON.pm
> line 64) line 10.
>
> The error occurs after a call to
> $query->results
> However, not after calling
> $query->results(as => 'string')
>
>
> Do you know what I am doing wrong? A similar query does not give me any
> problems in flymine.
>
> Thanks a lot for your time, I am looking forward to your reply!
>
> Best regards,
> Kai Kruse



_______________________________________________
dev mailing list
[hidden email]
http://mail.intermine.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Yeastmine Perl API access

Kai Kruse
Wow, thank you, Alex!

That was insanely quick and immensely helpful. I will try this as soon as it hits the CPAN mirrors!

Thank you so much, you have just saved my day!

Kai

On Mon, Aug 8, 2011 at 6:18 PM, Alex Kalderimis <[hidden email]> wrote:
The good news is that this had nothing to do with you - There has been
some reasonably rapid development here, and YeastMine's webservices
are a little old now, which meant that the client code broke as it was
expecting different output. I have fixed this and uploaded the fix to
CPAN as 0.9809 - it should filter through to the mirrors in a couple
of hours. I tested it with your code, or rather the slightly modified
version below:

 #!/usr/bin/perl
 use strict;
 use warnings;
 use feature ':5.10';

 use Webservice::InterMine 0.9809 'yeastmine.yeastgenome.org/yeastmine';

 my $query = Webservice::InterMine->new_query;

 # views
 $query->add_view(qw/
         Gene.primaryIdentifier
         Gene.featureType
 /);

 # I just added this because otherwise you just get a lot of undef featureTypes back... Feel free to remove
 $query->add_constraint("featureType", "IS NOT NULL");

 # BIG PROBLEM (hopefully not any more! :) )
 # retrieve as hash ref (well, ResultRows actually, but you use them as hashrefs!
 for (my $i = $query->iterator(size => 100); my $row = <$i>;) {
   printf "ID: %s, FT: %s\n", $row->{primaryIdentifier}, $row->{featureType};
 }

 # And you can use them as arrayrefs too!
 for (my $i = $query->iterator(size => 100); my $row = <$i>;) {
   printf "ID: %s, FT: %s\n", @$row;
 }

 __END__

Also check out the documentation online at CPAN (http://search.cpan.org/perldoc?Webservice::InterMine),
and our tutorials:
 * http://search.cpan.org/perldoc?Webservice::InterMine::Cookbook
 * http://www.intermine.org/wiki/WebservicesTutorial

Thanks for reporting this error and helping improve our code.

Alex

On Mon, Aug 08, 2011 at 04:26:29PM +0100, Kai Kruse wrote:
> Dear Alex,
>
> Sven Sewitz kindly gave me your email address - I am a PhD student in the
> work group of Madan Babu. Currently I am realising the benefit of using the
> yeastmine API in my own work and was hoping you could help me with a
> (seemingly) simple query to the yeastmine database.
>
> When running the sample script that I have attached I obtain the following
> error multiple times:
>
> Use of uninitialized value $_[0] in concatenation (.) or string at native
> delegation method Webservice::InterMine::Parser::JSON::add_to_header
> (append) of attribute header (defined at
> /lmb/home/kkruse/perl5/perlbrew/perls/perl-5.15.1/lib/site_perl/5.15.1/Webservice/InterMine/Parser/JSON.pm
> line 64) line 10.
>
> The error occurs after a call to
> $query->results
> However, not after calling
> $query->results(as => 'string')
>
>
> Do you know what I am doing wrong? A similar query does not give me any
> problems in flymine.
>
> Thanks a lot for your time, I am looking forward to your reply!
>
> Best regards,
> Kai Kruse




_______________________________________________
dev mailing list
[hidden email]
http://mail.intermine.org/cgi-bin/mailman/listinfo/dev