Skip to content

Commit

Permalink
Rebase into paired/unpaired...
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Dec 31, 2024
1 parent 6a1af79 commit 2ea7e5b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
37 changes: 24 additions & 13 deletions lib/galaxy/model/dataset_collections/types/collection_semantics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@
tests:
- tool_runtime: "test_tool_execute.py::test_map_over_collection"

- example:
label: BASIC_MAPPING_PAIRED_OR_UNPAIRED_PAIRED
assumptions:
- "f, r are datasets"
- "tool = (i: dataset) => {o: dataset}"
- "C = CollectionInstance<paired_or_unpaired,[{forward=f, reverse=r}]>"
then:
- "tool(i=map_over(C)) ~> {o: collection<paired_or_unpaired,[forward=tool(i=f)[o], reverse=tool(i=r)[o]]}"
tests:
- tool_runtime: test_map_over_data_with_paired_or_unpaired_unpaired
- wf_editor: "accepts paired_or_unpaired data -> data connection"

- example:
label: BASIC_MAPPING_PAIRED_OR_UNPAIRED_UNPAIRED
assumptions:
- "u is a dataset"
- "tool = (i: dataset) => {o: dataset}"
- "C = CollectionInstance<paired_or_unpaired,[{unpaired=u}]>"
then:
- "tool(i=map_over(C)) ~> {o: collection<paired_or_unpaired,[unpaired=tool(i=u)[o]]}"
tests:
- tool_runtime: test_map_over_data_with_paired_or_unpaired_paired
- wf_editor: "accepts paired_or_unpaired data -> data connection"

- example:
label: BASIC_MAPPING_LIST
assumptions:
Expand Down Expand Up @@ -144,19 +168,6 @@
tests:
- wf_editor: "rejects paired input on multi-data input"

PAIRED_OR_UNPAIRED_1:

If tool(i: data) => {o: data}

tool(i: collection<paired_or_unpaired>) => {o: collection<paired_or_unpaired>}

Mapping a collection of type `paired_or_unpaired` over tool
input i, yields an implicit collection of type `paired_or_unpaired`
composed of the outputs o.

- toolruntime: test_map_over_data_with_paired_or_unpaired
- wfeditor: it("accepts paired_or_unpaired data -> data connection")

PAIRED_OR_UNPAIRED_2:

tool(i: collection<list:paired_or_unpaired>) => {o: collection<list:paired_or_unpaired>}
Expand Down
13 changes: 12 additions & 1 deletion lib/galaxy_test/api/test_tool_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def test_map_over_collection(


@requires_tool_id("cat|cat1")
def test_map_over_data_with_paired_or_unpaired(target_history: TargetHistory, required_tool: RequiredTool):
def test_map_over_data_with_paired_or_unpaired_unpaired(target_history: TargetHistory, required_tool: RequiredTool):
hdca = target_history.with_unpaired()
execute = required_tool.execute.with_inputs({"input1": {"batch": True, "values": [hdca.src_dict]}})
execute.assert_has_n_jobs(1).assert_creates_n_implicit_collections(1)
Expand All @@ -390,6 +390,17 @@ def test_map_over_data_with_paired_or_unpaired(target_history: TargetHistory, re
output_collection.assert_has_dataset_element("unpaired").with_contents_stripped("123")


@requires_tool_id("cat|cat1")
def test_map_over_data_with_paired_or_unpaired_paired(target_history: TargetHistory, required_tool: RequiredTool):
hdca = target_history.with_paired_or_unpaired_pair()
execute = required_tool.execute.with_inputs({"input1": {"batch": True, "values": [hdca.src_dict]}})
execute.assert_creates_n_implicit_collections(1)
output_collection = execute.assert_creates_implicit_collection(0)
output_collection.assert_collection_type_is("paired_or_unpaired")
output_collection.assert_has_dataset_element("forward").with_contents_stripped("123")
output_collection.assert_has_dataset_element("reverse").with_contents_stripped("123")


@requires_tool_id("cat|cat1")
def test_map_over_data_with_list_paired_or_unpaired(target_history: TargetHistory, required_tool: RequiredTool):
hdca = target_history.with_list_of_paired_and_unpaired()
Expand Down
10 changes: 10 additions & 0 deletions lib/galaxy_test/base/populators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3097,6 +3097,11 @@ def create_unpaired_in_history(self, history_id: str, wait: bool = False, **kwds
payload = self.__create_payload(history_id, contents=contents, collection_type="paired_or_unpaired", **kwds)
return self.__create(payload, wait=wait)

def create_paired_or_unpaired_pair_in_history(self, history_id: str, wait: bool = False, **kwds):
contents = [("forward", "123"), ("reverse", "456")]
payload = self.__create_payload(history_id, contents=contents, collection_type="paired_or_unpaired", **kwds)
return self.__create(payload, wait=wait)

def create_list_of_paired_and_unpaired_in_history(self, history_id: str, wait: bool = False, **kwds):
contents = [
{
Expand Down Expand Up @@ -3983,6 +3988,11 @@ def with_unpaired(self) -> "HasSrcDict":
self._dataset_collection_populator.create_unpaired_in_history(self._history_id, wait=True)
)

def with_paired_or_unpaired_pair(self) -> "HasSrcDict":
return self._fetch_response(
self._dataset_collection_populator.create_paired_or_unpaired_pair_in_history(self._history_id, wait=True)
)

def with_list_of_paired_and_unpaired(self) -> "HasSrcDict":
return self._fetch_response(
self._dataset_collection_populator.create_list_of_paired_and_unpaired_in_history(
Expand Down

0 comments on commit 2ea7e5b

Please sign in to comment.