Package intermine :: Package lists :: Module listmanager :: Class ListManager
[hide private]
[frames] | no frames]

Class ListManager

source code

object --+
         |
        ListManager

A Class for Managing List Content and Operations

This class provides methods to manage list contents and operations.

This class may be called itself, but all the useful methods it has are also available on the Service object, which delegates to this class, while other methods are more coneniently accessed through the list objects themselves.

NB: The methods for creating lists can conflict in threaded applications, if two threads are each allocated the same unused list name. You are strongly advised to use locks to synchronise any list creation requests (create_list, or intersect, union, subtract, diff) unless you are choosing your own names each time and are confident that these will not conflict.

Instance Methods [hide private]
 
__init__(self, service)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
refresh_lists(self)
Update the list information with the latest details from the server
source code
 
get_list(self, name)
Return a list from the service by name, if it exists
source code
 
l(self, name)
Alias for get_list
source code
 
get_all_lists(self)
Get all the lists on a webservice
source code
 
get_all_list_names(self)
Get all the names of the lists in a particular webservice
source code
 
get_list_count(self)
Return the number of lists accessible at the given webservice.
source code
 
get_unused_list_name(self)
This method returns a new name that does not conflict with any currently existing list name.
source code
 
_get_listable_query(self, queryable) source code
 
_create_list_from_queryable(self, queryable, name, description, tags) source code
 
create_list(self, content, list_type='', name=None, description=None, tags=[], add=[])
Create a new list in the webservice ===================================
source code
 
parse_list_upload_response(self, response)
Intepret the response from the webserver to a list request, and return the List it describes
source code
 
delete_lists(self, lists)
Delete the given lists from the webserver
source code
 
remove_tags(self, to_remove_from, tags)
Returns the current tags of this list.
source code
 
add_tags(self, to_tag, tags)
Returns the current tags of this list.
source code
 
get_tags(self, im_list)
Returns the current tags of this list.
source code
 
_body_to_json(self, body) source code
 
__enter__(self) source code
 
__exit__(self, exc_type, exc_val, traceback) source code
 
delete_temporary_lists(self)
Delete all the lists considered temporary (those created without names)
source code
 
intersect(self, lists, name=None, description=None, tags=[])
Calculate the intersection of a given set of lists, and return the list representing the result
source code
 
union(self, lists, name=None, description=None, tags=[])
Calculate the union of a given set of lists, and return the list representing the result
source code
 
xor(self, lists, name=None, description=None, tags=[])
Calculate the symmetric difference of a given set of lists, and return the list representing the result
source code
 
subtract(self, lefts, rights, name=None, description=None, tags=[])
Calculate the subtraction of rights from lefts, and return the list representing the result
source code
 
_do_operation(self, path, operation, lists, name, description, tags) source code
 
make_list_names(self, lists)
Turn a list of things into a list of list names
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
safe_dict(d)
Recursively clone json structure with UTF-8 dictionary keys
source code
Class Variables [hide private]
  DEFAULT_LIST_NAME = 'my_list_'
  DEFAULT_DESCRIPTION = 'List created with Python client library'
  INTERSECTION_PATH = '/lists/intersect/json'
  UNION_PATH = '/lists/union/json'
  DIFFERENCE_PATH = '/lists/diff/json'
  SUBTRACTION_PATH = '/lists/subtract/json'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, service)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

get_list_count(self)

source code 

Return the number of lists accessible at the given webservice. This number will vary depending on who you are authenticated as.

get_unused_list_name(self)

source code 

Get an unused list name

This method returns a new name that does not conflict with any currently existing list name.

The list name is only guaranteed to be unused at the time of allocation.

create_list(self, content, list_type='', name=None, description=None, tags=[], add=[])

source code 

Create a new list in the webservice
===================================

If no name is given, the list will be considered to be a temporary
list, and will be automatically deleted when the program ends. To prevent
this happening, give the list a name, either on creation, or by renaming it.

This method is not thread safe for anonymous lists - it will need synchronisation
with locks if you intend to create lists with multiple threads in parallel.

@param content: The source of the identifiers for this list. This can be:
                  * A string with white-space separated terms.
                  * The name of a file that contains the terms.
                  * A file-handle like thing (something with a 'read' method)
                  * An iterable of identifiers
                  * A query with a single column.
                  * Another list.
@param list_type: The type of objects to include in the list. This parameter is not
                  required if the content parameter implicitly includes the type
                  (as queries and lists do).
@param name: The name for the new list. If none is provided one will be generated, and the
             list will be deleted when the list manager exits context.
@param description: A description for the list (free text, default = None)
@param tags: A set of strings to use as tags (default = [])
@param add: The issues groups that can be treated as matches. This should be a
            collection of strings naming issue groups that would otherwise be ignored, but
            in this case will be added to the list. The available groups are:
              * DUPLICATE - More than one match was found.
              * WILDCARD - A wildcard match was made.
              * TYPE_CONVERTED - A match was found, but in another type (eg. found a protein
                                 and we could convert it to a gene).
              * OTHER - other issue types
              * :all - All issues should be considered acceptable.
            This only makes sense with text uploads - it is not required (or used) when
            the content is a list or a query.

@rtype: intermine.lists.List