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

Should "-" work as an output file? #4

Open
j0ma opened this issue Oct 28, 2022 · 2 comments
Open

Should "-" work as an output file? #4

j0ma opened this issue Oct 28, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@j0ma
Copy link
Contributor

j0ma commented Oct 28, 2022

Right now, using - in place of an output file fails, at least when using it with seqscore count.

Starting with just references.bio:

> ls -a
.  ..  references.bio

Running this:

for outfile in "counts.tsv" "-"
do 
    seqscore count --labels BIO references.bio $outfile
done

produces two files that are the same:

> ls -a
-  .  ..  counts.tsv  references.bio

> sha256sum "./-" counts.tsv
5fba369692a43addad802d8c02592f1fcfdd0230c0129a11524199eba170d839  ./-
5fba369692a43addad802d8c02592f1fcfdd0230c0129a11524199eba170d839  counts.tsv

as opposed to - redirecting to stdout. Is this intentional? Is there a reason to not support -?

FWIW, I believe this can be fixed by adding a type=click.Path(...)-style annotation on L182 here.

@ConstantineLignos ConstantineLignos added the enhancement New feature or request label Aug 9, 2023
@ConstantineLignos
Copy link
Member

@j0ma and I talked about this in person when the issue was opened, but I never memorialized it here. In short, this is a desirable feature, but it's not simple to add. We have to handle the file encoding properly, and also some functions operate on paths only, so special logic would have to be added in for '-'. But it's worth doing for output files for scoring, count, etc. for sure.

@ConstantineLignos ConstantineLignos self-assigned this Aug 9, 2023
@j0ma
Copy link
Contributor Author

j0ma commented Dec 12, 2023

OK I thought of this issue first thing this morning for some reason. Would it be enough to handle the encoding + file opening using a combination of click.Path(..., allow_dash=True) and click.open_file? There's also click.echo that can be a substitute for printing to a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants