kircherlab / negative_training_sampler

MIT License
0 stars 1 forks source link

request: -o optional and into one file! #6

Closed visze closed 4 years ago

visze commented 4 years ago

for using the program in pipelines the naming convention of positive and negative is not practical.

It would be great that the output is in 1 (one) file like the input and the user can specify it directly like:

-o myOutputFile.bed

And the -o command should be made optional. Without -o the output goes to standard out and can be piped, compressed etc...

I know that you use the standard out for messages. But here you can use the warning channel or, when -log is given, write it into a log file.

finally it would be nice if the output can be bgzipped on the fly when the user adds -g. So then we have nice commands with identical results:

negative_training_sampler -log output.log -o output.bed.gz -g input.bed.gz reference.fa
negative_training_sampler -log output.log -g input.bed.gz reference.fa > output.bed.gz
negative_training_sampler -log output.log input.bed.gz reference.fa | bgzip -c > output.bed.gz

And a final final request :-)

using -i and -r for input and reference to make code much clearer without looking at the help what is in the first and second position of the command. And the you the order does not matter

negative_training_sampler -log output.log -o output.bed.gz -g -i input.bed.gz -r reference.fa
negative_training_sampler -log output.log  -g -i input.bed.gz -r reference.fa > output.bed.gz
negative_training_sampler -log output.log  -i input.bed.gz -r reference.fa | bgzip -c > output.bed.gz
sroener commented 4 years ago

Is there a python library that is able to reliably write bgzipped files?

visze commented 4 years ago

Have a look at manuels vcfpy:

https://github.com/bihealth/vcfpy/blob/master/vcfpy/bgzf.py

Shamelessly taken from Biopython :-)

Without -o

from . import bgzf
stream = bgzf.BgzfWriter(fileobj=stream)

with -o

from . import bgzf
if path.endswith(".gz"):
    stream = bgzf.BgzfWriter(filename=path)
else:
    f = open(path, "wt")