-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Dataset Collections to Object Oriented API #179
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6158eb5
Add ability to create dataset collections to galaxy.objects
alexjsmac 5a8b382
Small syntax fix for data collection attributes
alexjsmac f4a1264
Add delete dataset collection method and fix whitespace error
alexjsmac 784d013
Add test for running workflow with dataset collection as an input
alexjsmac 0327da6
Add blank line for flake8
alexjsmac 4778b3d
Dataset collection test requirements and remove import renaming
alexjsmac b77dcd9
Additional minor fixes
alexjsmac 9ed67b3
Renaming, remove stream_url(), and fix test but it's failing
alexjsmac 0b861e0
Fix typo
alexjsmac 747c5e2
Whitespace fix
alexjsmac 48b2564
Method call fixes
alexjsmac a23270c
Add dataset collections to the outputs of Workflow.run() .
nsoranzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import bioblend.galaxy.objects.wrappers as wrappers | ||
import bioblend.galaxy.objects.galaxy_instance as galaxy_instance | ||
from bioblend import ConnectionError | ||
from bioblend.galaxy import dataset_collections | ||
|
||
import test_util | ||
from test_util import unittest | ||
|
@@ -558,6 +559,15 @@ def __check_dataset(self, hda): | |
self.assertEqual(len(self.hist.dataset_ids), 1) | ||
self.assertEqual(self.hist.dataset_ids[0], hda.id) | ||
|
||
def __check_dataset_collection(self, hdca): | ||
self.assertIsInstance(hdca, wrappers.HistoryDatasetCollectionAssociation) | ||
self.assertIs(hdca.container, self.hist) | ||
self.assertEqual(len(self.hist.dataset_ids), 2) | ||
dataset1 = self.hist.get_dataset(self.hist.dataset_ids[0]) | ||
dataset2 = self.hist.get_dataset(self.hist.dataset_ids[1]) | ||
self.assertEqual(dataset1.id, hdca.elements[0]['object']['id']) | ||
self.assertEqual(dataset2.id, hdca.elements[1]['object']['id']) | ||
|
||
def test_import_dataset(self): | ||
lib = self.gi.libraries.create('test_%s' % uuid.uuid4().hex) | ||
lds = lib.upload_data(FOO_DATA) | ||
|
@@ -617,6 +627,31 @@ def test_update(self): | |
self.assertEqual(self.hist.annotation, new_annotation) | ||
self.assertEqual(self.hist.tags, new_tags) | ||
|
||
@test_util.skip_unless_galaxy('release_14.06') | ||
def test_create_dataset_collection(self): | ||
collection_description = self._create_collection_description() | ||
dataset_collection = self.hist.create_dataset_collection(collection_description) | ||
self.__check_dataset_collection(dataset_collection) | ||
|
||
@test_util.skip_unless_galaxy('release_14.06') | ||
def test_delete_dataset_collection(self): | ||
collection_description = self._create_collection_description() | ||
dataset_collection = self.hist.create_dataset_collection(collection_description) | ||
dataset_collection.delete() | ||
self.assertTrue(dataset_collection.deleted) | ||
|
||
def _create_collection_description(self): | ||
dataset1 = self.hist.paste_content(FOO_DATA) | ||
dataset2 = self.hist.paste_content(FOO_DATA_2) | ||
collection_description = dataset_collections.CollectionDescription( | ||
name="MyDatasetList", | ||
elements=[ | ||
dataset_collections.HistoryDatasetElement(name="sample1", id=dataset1.id), | ||
dataset_collections.HistoryDatasetElement(name="sample2", id=dataset2.id), | ||
] | ||
) | ||
return collection_description | ||
|
||
|
||
@test_util.skip_unless_galaxy() | ||
class TestHDAContents(GalaxyObjectsTestBase): | ||
|
@@ -705,6 +740,40 @@ def test_params(self): | |
self.__test(params=True) | ||
|
||
|
||
@test_util.skip_unless_galaxy() | ||
class TestRunDatasetCollectionWorkflow(GalaxyObjectsTestBase): | ||
|
||
def setUp(self): | ||
super(TestRunDatasetCollectionWorkflow, self).setUp() | ||
wf_file = os.path.join(THIS_DIR, 'data', 'dataset_collection_run.ga') | ||
with open(wf_file) as f: | ||
self.wf = self.gi.workflows.import_new(f.read()) | ||
self.hist_name = 'test_%s' % uuid.uuid4().hex | ||
self.hist = self.gi.histories.create(self.hist_name) | ||
|
||
def tearDown(self): | ||
self.wf.delete() | ||
|
||
@test_util.skip_unless_galaxy('release_14.06') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd move |
||
def test_run_workflow_with_dataset_collection(self): | ||
dataset1 = self.hist.paste_content('foo\nbar\n') | ||
dataset2 = self.hist.paste_content('foo2\nbar2\n') | ||
collection_description = dataset_collections.CollectionDescription( | ||
name="MyDatasetList", | ||
elements=[ | ||
dataset_collections.HistoryDatasetElement(name="sample1", id=dataset1.id), | ||
dataset_collections.HistoryDatasetElement(name="sample2", id=dataset2.id), | ||
] | ||
) | ||
dataset_collection = self.hist.create_dataset_collection(collection_description) | ||
input_map = {"Input Dataset Collection": dataset_collection} | ||
outputs, out_hist = self.wf.run(input_map, self.hist, wait=True) | ||
self.assertIsInstance(outputs[0], wrappers.HistoryDatasetCollectionAssociation) | ||
self.assertEqual(len(outputs), 1) | ||
self.assertEqual(out_hist.id, self.hist.id) | ||
out_hist.delete(purge=True) | ||
|
||
|
||
@test_util.skip_unless_galaxy() | ||
class TestJob(GalaxyObjectsTestBase): | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"a_galaxy_workflow": "true", | ||
"annotation": "", | ||
"format-version": "0.1", | ||
"name": "DC Run", | ||
"steps": { | ||
"0": { | ||
"annotation": "", | ||
"id": 0, | ||
"input_connections": {}, | ||
"inputs": [ | ||
{ | ||
"description": "", | ||
"name": "Input Dataset Collection" | ||
} | ||
], | ||
"label": null, | ||
"name": "Input dataset collection", | ||
"outputs": [], | ||
"position": { | ||
"left": 338, | ||
"top": 306 | ||
}, | ||
"tool_errors": null, | ||
"tool_id": null, | ||
"tool_state": "{\"collection_type\": \"list\", \"name\": \"Input Dataset Collection\"}", | ||
"tool_version": null, | ||
"type": "data_collection_input", | ||
"user_outputs": [], | ||
"uuid": "4a497708-240c-420e-9c7c-a2dc0200476e" | ||
}, | ||
"1": { | ||
"annotation": "", | ||
"id": 1, | ||
"input_connections": { | ||
"input": { | ||
"id": 0, | ||
"output_name": "output" | ||
} | ||
}, | ||
"inputs": [], | ||
"label": null, | ||
"name": "Sort", | ||
"outputs": [ | ||
{ | ||
"name": "out_file1", | ||
"type": "input" | ||
} | ||
], | ||
"position": { | ||
"left": 676, | ||
"top": 286 | ||
}, | ||
"post_job_actions": {}, | ||
"tool_errors": null, | ||
"tool_id": "sort1", | ||
"tool_state": "{\"__page__\": 0, \"style\": \"\\\"num\\\"\", \"column\": \"\\\"1\\\"\", \"__rerun_remap_job_id__\": null, \"order\": \"\\\"DESC\\\"\", \"input\": \"null\", \"column_set\": \"[]\"}", | ||
"tool_version": "1.0.3", | ||
"type": "tool", | ||
"user_outputs": [], | ||
"uuid": "3c33333f-08ce-43bf-bc09-fa0b5776845b" | ||
} | ||
}, | ||
"uuid": "fd34f048-e17a-4e06-85e8-ed391192d284" | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add one more blank line here, flake8 is complaining:
./tests/TestGalaxyObjects.py:653:1: E302 expected 2 blank lines, found 1