-
Notifications
You must be signed in to change notification settings - Fork 983
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
Implement Collection Operation to Relabelling Identifiers #3603
Merged
bgruening
merged 5 commits into
galaxyproject:dev
from
jmchilton:collection_op_relabel_from_file
Apr 20, 2017
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b6a9dc
Start work on a relabelling collection operation.
jmchilton d21c14f
Add possibility to rename collection items from a tabular file
mvdbeek 338130a
Fix failing test case in relable_from_file based on comment from @mvd…
jmchilton 09bcdd9
Various improvements to relabel from file collection operation.
jmchilton 2288a88
Fix relabel_from_file collection operation error handling if duplicat…
jmchilton 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
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,149 @@ | ||
<tool id="__RELABEL_FROM_FILE__" | ||
name="Relabel List Identifiers" | ||
version="1.0.0" | ||
tool_type="relabel_from_file"> | ||
<description>from contents of a file</description> | ||
<type class="RelabelFromFileTool" module="galaxy.tools" /> | ||
<action module="galaxy.tools.actions.model_operations" | ||
class="ModelOperationToolAction"/> | ||
<inputs> | ||
<param type="data_collection" name="input" label="Input Collection" help="A list whose identifiers will be relabelled."/> | ||
<conditional name="how"> | ||
<param type="select" name="how_select" label="How should the new labels be specified?"> | ||
<option value="txt">Using lines in a simple text file.</option> | ||
<option value="tabular">Map original identifiers to new ones using a two column table.</option> | ||
</param> | ||
<when value="txt"> | ||
<param type="data" name="labels" format="txt" label="New Identifiers" /> | ||
<param name="strict" type="boolean" label="Ensure strict mapping" help="If selected, the target file must contain exactly the correct number of lines." truevalue="true" falsevalue="false" /> | ||
</when> | ||
<when value="tabular"> | ||
<param type="data" name="labels" format="tabular" label="New Identifiers" /> | ||
<param name="strict" type="boolean" label="Ensure strict mapping" help="If selected, the target file must contain exactly the correct number of lines and each input identifier must match exactly one element of the input collection." truevalue="true" falsevalue="false" /> | ||
</when> | ||
</conditional> | ||
</inputs> | ||
<outputs> | ||
<collection name="output" format_source="input" type_source="input" label="${on_string} (relabelled)" > | ||
</collection> | ||
</outputs> | ||
<tests> | ||
<test> | ||
<param name="input"> | ||
<collection type="list:paired"> | ||
<element name="i1"> | ||
<collection type="paired"> | ||
<element name="forward" value="simple_line.txt" /> | ||
<element name="reverse" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</element> | ||
</collection> | ||
</param> | ||
<param name="how_select" value="txt" /> | ||
<param name="labels" value="new_labels_1.txt" ftype="txt" /> | ||
<output_collection name="output" type="list:paired"> | ||
<element name="new_i1"> | ||
<element name="forward"> | ||
<assert_contents> | ||
<has_text_matching expression="^This is a line of text.\n$" /> | ||
</assert_contents> | ||
</element> | ||
<element name="reverse"> | ||
<assert_contents> | ||
<has_text_matching expression="^This is a different line of text.\n$" /> | ||
</assert_contents> | ||
</element> | ||
</element> | ||
</output_collection> | ||
</test> | ||
<test> | ||
<param name="input"> | ||
<collection type="list:paired"> | ||
<element name="i1"> | ||
<collection type="paired"> | ||
<element name="forward" value="simple_line.txt" /> | ||
<element name="reverse" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</element> | ||
</collection> | ||
</param> | ||
<param name="how_select" value="tabular" /> | ||
<param name="labels" value="new_labels_2.txt" ftype="tabular" /> | ||
<output_collection name="output" type="list:paired"> | ||
<element name="new_i1"> | ||
<element name="forward"> | ||
<assert_contents> | ||
<has_text_matching expression="^This is a line of text.\n$" /> | ||
</assert_contents> | ||
</element> | ||
<element name="reverse"> | ||
<assert_contents> | ||
<has_text_matching expression="^This is a different line of text.\n$" /> | ||
</assert_contents> | ||
</element> | ||
</element> | ||
</output_collection> | ||
</test> | ||
<!-- test strict --> | ||
<test expect_failure="true"> | ||
<param name="input"> | ||
<collection type="list:paired"> | ||
<element name="wrongi"> | ||
<collection type="paired"> | ||
<element name="forward" value="simple_line.txt" /> | ||
<element name="reverse" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</element> | ||
</collection> | ||
</param> | ||
<param name="how_select" value="tabular" /> | ||
<param name="labels" value="new_labels_2.txt" ftype="tabular" /> | ||
</test> | ||
<test expect_failure="true"> | ||
<param name="input"> | ||
<collection type="list"> | ||
<element name="i1" value="simple_line.txt" /> | ||
<element name="i3" value="simple_line_alternative.txt" /> | ||
</collection> | ||
</param> | ||
<param name="how_select" value="txt" /> | ||
<param name="labels" value="new_labels_1.txt" ftype="txt" /> | ||
</test> | ||
<!-- test label bad characters --> | ||
<test expect_failure="true"> | ||
<param name="input"> | ||
<collection type="list"> | ||
<element name="i1" value="simple_line.txt" /> | ||
</collection> | ||
</param> | ||
<param name="how_select" value="txt" /> | ||
<param name="labels" value="new_labels_bad_1.txt" ftype="txt" /> | ||
</test> | ||
<!-- test label bad because of duplicates --> | ||
<test expect_failure="true"> | ||
<param name="input"> | ||
<collection type="list"> | ||
<element name="i1" value="simple_line.txt" /> | ||
<element name="i2" value="simple_line.txt" /> | ||
</collection> | ||
</param> | ||
<param name="how_select" value="txt" /> | ||
<param name="labels" value="new_labels_bad_2.txt" ftype="txt" /> | ||
</test> | ||
</tests> | ||
<help> | ||
This tool will take an input list and a text file with new identifiers | ||
and build a new list with the same datasets but these new identifiers. | ||
The order and number of entries in the text file must match the order | ||
of the items you want to rename in your dataset collection. | ||
|
||
Alternatively a tabular file may be supplied, where the first column | ||
if the current identifier that should be renamed, and the second column | ||
contains the new label. This file may contain less entries than items | ||
in the collection. In that case only matching list identifiers will be | ||
relabeled. | ||
|
||
This tool will create new history datasets from 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
new_i1 |
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 @@ | ||
i1 new_i1 |
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 @@ | ||
new_i; rm -rf |
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,2 @@ | ||
newi1 | ||
newi1 |
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
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.
Maybe we should use
strip('\r\n')
here? See the discussion here: galaxyproject/tools-iuc#1233 (comment)