NAME

Webservice::InterMine::Cookbook::Lists::Recipe1 - Uploading Lists

SYNOPSIS

use Webservice::InterMine 'www.flymine.org/query', "SOMETOKEN";

my $service = Webservice::InterMine->get_service;
my $list = $service->new_list(content => $filename, type => 'Gene', name=> 'My-New-List');

# Have a look at the contents of the new list.
$list->show();

my $other_list = $service->list('Other List');

# Make a new list by combining two or more
my $combined_list = $list + $combined_list;
$combined_list->rename("Combination");

# Make a new list which is a clone of another list
my $copy = $service->new_list($list, name => "Copy of my list");

DESCRIPTION

InterMine web applications offer a facility termed 'lists', which are typed collections of data from the database, essentially collections of objects. You can see them as saved result-sets, or little tables you can alter by adding and subtracting.

Note, you must authenticate with the webservice in order to use this facility.

Lists can be created in two broad ways: either by matching items from the database against a set of identifiers, or by defining a result set with a query.

Creating Lists from Sets of identifiers

The identifiers can be located in:

A file
An array-ref
A string

However, the mechanism for using them is the same:

$list = $service->new_list(content => $content, type => $class_name);

Where the content is a filename, array-ref of identifiers, or a string to parse for identifiers. The above shows the minimal use case, here creating a list that will be deleted when the program exists. If a name is provided, it will persist and be visible in your web-app's history when you next care to look:

$list = $service->new_list(content => $content, type => $class_name, name => 'My great list');

Creating Lists from Queries

This is basically the same with exactly the same syntax as the other forms of list construction, the only difference is the need to define a query first:

my $query = $service->new_query(class => 'Gene')->where('pathways.name' => '*embryonic*');
$list = $service->new_list(content => $query, type => $class_name, name => 'My great list');

Note that for this purpose there is no need to define a view - the root class of the query is used to determine the list type and every unique item of that type in the result set will be included in the resulting list.

Copying Lists

Lists can be copied within the same service by simply passing the list to copy from as the first parameter to new_list. This makes a new list (with a default name if none is supplied) with the same content as the original.

Combining Lists

Lists can be combined in several ways (see Recipe2 for more operations). One of these is to join two or more lists together. This can be done in a number of ways:

my $new_list = $listA + $listB; # Addition as union
$new_list = $listA | $listB;    # Union as this or that
$new_list = $listA + $query;    # OK to combine lists and queries.
$new_list = $service->join_lists([$listA, $listB, $query], "Combination") # Use the service

The main benefit of using the service method is being able to supply a name at creation time, rather than using the rename method, as well as being able to supply as many lists and queries as you wish.

The syntax is much the same for the other operations, more details of which can be found in Recipe2.

Retrieving Results

Lists may be treated much like queries, and this is explored in more depth in Recipe3. Methods that work on queries and lists include:

$list->show();
$list->show_first();
$list->print_results();
while (<$list>) { 
  # Iteration
}
$list->results_iterator;

CONCLUSION

The syntax for creating lists is the same for all the different content types, and many of the same operations that can be performed on queries can be performed on Lists as well.

AUTHOR

Alex Kalderimis dev@intermine.org

BUGS

Please report any bugs or feature requests to dev@intermine.org.

SUPPORT

You can find information about InterMine at:

COPYRIGHT AND LICENSE

Copyright 2006 - 2011 FlyMine, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.