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
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'))
def test_library_and_folder_trailing_slash(self): self.assertEqual(split_library_path('Test Library 2/Run 11/'), ('Test Library 2','/Run 11'))
def test_library_and_folder(self): self.assertEqual(split_library_path('Test Library 2/Run 11'), ('Test Library 2','/Run 11'))
def test_library_name_with_spaces(self): self.assertEqual(split_library_path('Test Library 2'), ('Test Library 2','/'))
def test_library_name_trailing_slash(self): self.assertEqual(split_library_path('TestLibrary/'), ('TestLibrary','/'))
def test_library_name_only(self): self.assertEqual(split_library_path('TestLibrary'), ('TestLibrary','/'))
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'))
def test_library_and_folder_trailing_slash(self): self.assertEqual(split_library_path('Test Library 2/Run 11/'), ('Test Library 2', '/Run 11'))
def test_library_and_folder(self): self.assertEqual(split_library_path('Test Library 2/Run 11'), ('Test Library 2', '/Run 11'))
def test_library_name_with_spaces(self): self.assertEqual(split_library_path('Test Library 2'), ('Test Library 2', '/'))
def test_library_name_trailing_slash(self): self.assertEqual(split_library_path('TestLibrary/'), ('TestLibrary', '/'))
def test_library_name_only(self): self.assertEqual(split_library_path('TestLibrary'), ('TestLibrary', '/'))