Skip to content
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 Sort Column Order by heading tool. #1233

Merged
merged 4 commits into from
Apr 12, 2017

Conversation

blankenberg
Copy link
Member

No description provided.

Copy link
Member

@bgruening bgruening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blankenberg looks good, a few comments inline.
Btw. do you know this tool: https://github.com/bgruening/galaxytools/blob/master/tools/text_processing/column_arrange_by_header/columnArrange.xml
Will this also solve your use-case?

<exit_code range=":-1" />
</stdio>
<command><![CDATA[
python '$__tool_directory__/column_order_header_sort.py' '${input_tabular}' '${output_tabular}' '${input_tabular.unsanitized.metadata.delimiter}' '${key_column}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have this with line breaks between the parameters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.


header = None
with open( input_filename, 'r' ) as fh:
header = fh.readline().strip( '\r\n' )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to strip \r\n and not \n?

Copy link
Member Author

@blankenberg blankenberg Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more complete and does not assume POSIX line endings, although this is probably moot in python3.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone was confused, this will strip any and all \r and \n (not just the Windows style combination of \r\n.

e.g.

>>> "abcde".strip("edf")
'abc'

So +1 on stripping both line endings, unless you want to open the file in universal new lines mode instead?

</command>
<inputs>
<param name="input_tabular" type="data" format="tabular" multiple="False" optional="False" label="Tabular file"/>
<param name="key_column" type="data_column" data_ref="input_tabular" value="0" optional="True" label="Identifier column"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a help here and in the tool-help section what this parameter is doing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a great idea, thanks, updated help.

@blankenberg
Copy link
Member Author

@blankenberg looks good, a few comments inline.
Btw. do you know this tool: https://github.com/bgruening/galaxytools/blob/master/tools/text_processing/column_arrange_by_header/columnArrange.xml
Will this also solve your use-case?

This would require manually entering, and knowing, all of the possible column names. This doesn't scale and won't work when e.g. pushing a file that contains sample names for column headers through a workflow.

@bgruening bgruening merged commit d562cc6 into galaxyproject:master Apr 12, 2017
@bgruening
Copy link
Member

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants