forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement paired_or_unpaired collections...
- Loading branch information
Showing
11 changed files
with
326 additions
and
3 deletions.
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
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
45 changes: 45 additions & 0 deletions
45
lib/galaxy/model/dataset_collections/types/paired_or_unpaired.py
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,45 @@ | ||
from galaxy.exceptions import RequestParameterInvalidException | ||
from galaxy.model import ( | ||
DatasetCollectionElement, | ||
HistoryDatasetAssociation, | ||
) | ||
from . import BaseDatasetCollectionType | ||
from .paired import ( | ||
FORWARD_IDENTIFIER, | ||
REVERSE_IDENTIFIER, | ||
) | ||
|
||
SINGLETON_IDENTIFIER = "unpaired" | ||
|
||
|
||
class PairedOrUnpairedDatasetCollectionType(BaseDatasetCollectionType): | ||
""" | ||
""" | ||
|
||
collection_type = "paired_or_unpaired" | ||
|
||
def generate_elements(self, dataset_instances, **kwds): | ||
num_datasets = len(dataset_instances) | ||
if num_datasets > 2 or num_datasets < 1: | ||
raise RequestParameterInvalidException(f"Incorrect number of datasets - 1 or 2 datasets is required to create a paired_or_unpaired collection") | ||
|
||
if num_datasets == 2: | ||
if forward_dataset := self._ensure_dataset_with_identifier(dataset_instances, FORWARD_IDENTIFIER): | ||
left_association = DatasetCollectionElement( | ||
element=forward_dataset, | ||
element_identifier=FORWARD_IDENTIFIER, | ||
) | ||
yield left_association | ||
if reverse_dataset := self._ensure_dataset_with_identifier(dataset_instances, REVERSE_IDENTIFIER): | ||
right_association = DatasetCollectionElement( | ||
element=reverse_dataset, | ||
element_identifier=REVERSE_IDENTIFIER, | ||
) | ||
yield right_association | ||
else: | ||
if single_datasets := self._ensure_dataset_with_identifier(dataset_instances, SINGLETON_IDENTIFIER): | ||
single_association = DatasetCollectionElement( | ||
element=single_datasets, | ||
element_identifier=SINGLETON_IDENTIFIER, | ||
) | ||
yield single_association |
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
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,132 @@ | ||
<tool id="__SPLIT_PAIRED_AND_UNPAIRED__" | ||
name="Split Paired and Unpaired" | ||
version="1.0.0" | ||
tool_type="split_paired_and_unpaired"> | ||
<description></description> | ||
<type class="SplitPairedAndUnpairedTool" module="galaxy.tools" /> | ||
<action module="galaxy.tools.actions.model_operations" | ||
class="ModelOperationToolAction"/> | ||
<edam_operations> | ||
<edam_operation>operation_2409</edam_operation> | ||
</edam_operations> | ||
<inputs> | ||
<param name="input" type="data_collection" label="Input Collection" collection_type="list:paired,list,list:paired_or_unpaired" /> | ||
</inputs> | ||
<outputs> | ||
<collection name="output_unpaired" format_source="input" type="list" label="${on_string} (unpaired)" > | ||
</collection> | ||
<collection name="output_paired" format_source="input" type="list:paired" label="${on_string} (paired)" > | ||
</collection> | ||
</outputs> | ||
<tests> | ||
<test> | ||
<param name="input"> | ||
<collection type="list"> | ||
<element name="el1" value="simple_line.txt" /> | ||
<element name="el2" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</param> | ||
<output_collection name="output_unpaired" type="list" count="2"> | ||
<element name="el1" ftype="txt"> | ||
<assert_contents> | ||
<has_line line="This is a line of text." /> | ||
</assert_contents> | ||
</element> | ||
<element name="el2" ftype="txt"> | ||
<assert_contents> | ||
<has_line line="This is a different line of text." /> | ||
</assert_contents> | ||
</element> | ||
</output_collection> | ||
<output_collection name="output_paired" type="list:paired" count="0"> | ||
</output_collection> | ||
</test> | ||
<test> | ||
<param name="input"> | ||
<collection type="list:paired"> | ||
<element name="el1"> | ||
<collection type="paired"> | ||
<element name="forward" value="simple_line.txt" /> | ||
<element name="reverse" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</element> | ||
</collection> | ||
</param> | ||
<output_collection name="output_unpaired" type="list" count="0"> | ||
</output_collection> | ||
<output_collection name="output_paired" type="list:paired" count="1"> | ||
<element name="el1"> | ||
<element name="forward"> | ||
<assert_contents> | ||
<has_line line="This is a line of text." /> | ||
</assert_contents> | ||
</element> | ||
<element name="reverse"> | ||
<assert_contents> | ||
<has_line line="This is a different line of text." /> | ||
</assert_contents> | ||
</element> | ||
</element> | ||
</output_collection> | ||
</test> | ||
<test> | ||
<param name="input"> | ||
<collection type="list:paired_or_unpaired"> | ||
<element name="el1"> | ||
<collection type="paired"> | ||
<element name="forward" value="simple_line.txt" /> | ||
<element name="reverse" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</element> | ||
<element name="el2" value="simple_line.txt"> | ||
</element> | ||
<element name="el3" value="simple_line_alternative.txt"> | ||
</element> | ||
</collection> | ||
</param> | ||
<output_collection name="output_unpaired" type="list" count="2"> | ||
<element name="el2" ftype="txt"> | ||
<assert_contents> | ||
<has_line line="This is a line of text." /> | ||
</assert_contents> | ||
</element> | ||
<element name="el3" ftype="txt"> | ||
<assert_contents> | ||
<has_line line="This is a different line of text." /> | ||
</assert_contents> | ||
</element> | ||
</output_collection> | ||
<output_collection name="output_paired" type="list:paired" count="1"> | ||
<element name="el1"> | ||
<element name="forward"> | ||
<assert_contents> | ||
<has_line line="This is a line of text." /> | ||
</assert_contents> | ||
</element> | ||
<element name="reverse"> | ||
<assert_contents> | ||
<has_line line="This is a different line of text." /> | ||
</assert_contents> | ||
</element> | ||
</element> | ||
</output_collection> | ||
</test> | ||
</tests> | ||
<help><![CDATA[ | ||
======== | ||
Synopsis | ||
======== | ||
=========== | ||
Description | ||
=========== | ||
.. class:: infomark | ||
This tool will create new history datasets for your collection but your quota usage will not increase. | ||
]]></help> | ||
</tool> |
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
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,51 @@ | ||
<tool id="collection_paired_or_unpaired" name="collection_paired_or_unpaired" version="0.1.0"> | ||
<command> | ||
#if $f1.has_single_item: | ||
cat $f1.unpaired >> $out1; | ||
echo "Single item" | ||
#else | ||
cat $f1.forward $f1['reverse'] >> $out1; | ||
echo "Paired items" | ||
#end if | ||
</command> | ||
<inputs> | ||
<param name="f1" type="data_collection" collection_type="paired_or_unpaired" label="Input" /> | ||
</inputs> | ||
<outputs> | ||
<data format="txt" name="out1" /> | ||
</outputs> | ||
<tests> | ||
<test> | ||
<param name="f1"> | ||
<collection type="paired_or_unpaired" name="collection name"> | ||
<element name="forward" value="simple_line.txt" /> | ||
<element name="reverse" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</param> | ||
<output name="out1"> | ||
<assert_contents> | ||
<has_line line="This is a line of text." /> | ||
<has_line line="This is a different line of text." /> | ||
</assert_contents> | ||
</output> | ||
<assert_stdout> | ||
<has_line line="Paired items" /> | ||
</assert_stdout> | ||
</test> | ||
<test> | ||
<param name="f1"> | ||
<collection type="paired_or_unpaired" name="collection name"> | ||
<element name="single" value="simple_line.txt" /> | ||
</collection> | ||
</param> | ||
<output name="out1"> | ||
<assert_contents> | ||
<has_line line="This is a line of text." /> | ||
</assert_contents> | ||
</output> | ||
<assert_stdout> | ||
<has_line line="Single item" /> | ||
</assert_stdout> | ||
</test> | ||
</tests> | ||
</tool> |
Oops, something went wrong.