Exemplo n.º 1
0
def get_library_contents(gi, path):
    """
    Return the contents of a data library

    Returns a list of LibraryFolder and LibraryDataset
    instances representing the contents of the specified
    Galaxy data library.

    FIXME: should filter on full path (currently
    lists everything)

    Arguments:
      gi (GalaxyInstance): bioblend GalaxyInstance
      path (str): path of the data library to fetch
        the contents of

    Returns:
      list: list of folders and datasets.

    """
    logging.debug("Path '%s'" % path)
    lib_client = galaxy.libraries.LibraryClient(gi)
    library_name, folder_path = split_library_path(path)
    logging.debug("library_name '%s'" % library_name)
    library_id = library_id_from_name(gi, library_name)
    if library_id is None:
        print "No library '%s'" % library_name
        return
    # Get library contents
    contents = []
    for item in lib_client.show_library(library_id, contents=True):
        if item['type'] == 'folder':
            contents.append(LibraryFolder(item))
        else:
            contents.append(LibraryDataset(item))
    return contents
def get_library_contents(gi,path):
    """
    Return the contents of a data library

    Returns a list of LibraryFolder and LibraryDataset
    instances representing the contents of the specified
    Galaxy data library.

    FIXME: should filter on full path (currently
    lists everything)

    Arguments:
      gi (GalaxyInstance): bioblend GalaxyInstance
      path (str): path of the data library to fetch
        the contents of

    Returns:
      list: list of folders and datasets.

    """
    logging.debug("Path '%s'" % path)
    lib_client = galaxy.libraries.LibraryClient(gi)
    library_name,folder_path = split_library_path(path)
    logging.debug("library_name '%s'" % library_name)
    library_id = library_id_from_name(gi,library_name)
    if library_id is None:
        print "No library '%s'" % library_name
        return
    # Get library contents
    contents = []
    for item in lib_client.show_library(library_id,contents=True):
        if item['type'] == 'folder':
            contents.append(LibraryFolder(item))
        else:
            contents.append(LibraryDataset(item))
    return contents
Exemplo n.º 3
0
 def test_library_and_multiple_folders_trailing_slash(self):
     self.assertEqual(
         split_library_path('Test Library 2/Run 11/Fastqs/'),
         ('Test Library 2','/Run 11/Fastqs'))
Exemplo n.º 4
0
 def test_library_and_folder_trailing_slash(self):
     self.assertEqual(split_library_path('Test Library 2/Run 11/'),
                      ('Test Library 2','/Run 11'))
Exemplo n.º 5
0
 def test_library_and_folder(self):
     self.assertEqual(split_library_path('Test Library 2/Run 11'),
                      ('Test Library 2','/Run 11'))
Exemplo n.º 6
0
 def test_library_name_with_spaces(self):
     self.assertEqual(split_library_path('Test Library 2'),
                      ('Test Library 2','/'))
Exemplo n.º 7
0
 def test_library_name_trailing_slash(self):
     self.assertEqual(split_library_path('TestLibrary/'),
                      ('TestLibrary','/'))
Exemplo n.º 8
0
 def test_library_name_only(self):
     self.assertEqual(split_library_path('TestLibrary'),
                      ('TestLibrary','/'))
Exemplo n.º 9
0
 def test_library_and_multiple_folders_trailing_slash(self):
     self.assertEqual(split_library_path('Test Library 2/Run 11/Fastqs/'),
                      ('Test Library 2', '/Run 11/Fastqs'))
Exemplo n.º 10
0
 def test_library_and_folder_trailing_slash(self):
     self.assertEqual(split_library_path('Test Library 2/Run 11/'),
                      ('Test Library 2', '/Run 11'))
Exemplo n.º 11
0
 def test_library_and_folder(self):
     self.assertEqual(split_library_path('Test Library 2/Run 11'),
                      ('Test Library 2', '/Run 11'))
Exemplo n.º 12
0
 def test_library_name_with_spaces(self):
     self.assertEqual(split_library_path('Test Library 2'),
                      ('Test Library 2', '/'))
Exemplo n.º 13
0
 def test_library_name_trailing_slash(self):
     self.assertEqual(split_library_path('TestLibrary/'),
                      ('TestLibrary', '/'))
Exemplo n.º 14
0
 def test_library_name_only(self):
     self.assertEqual(split_library_path('TestLibrary'),
                      ('TestLibrary', '/'))