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 option "checkIfExists" to Channel.fromPath method #666

Closed
ewels opened this issue Apr 25, 2018 · 8 comments
Closed

Add option "checkIfExists" to Channel.fromPath method #666

ewels opened this issue Apr 25, 2018 · 8 comments
Labels
Milestone

Comments

@ewels
Copy link
Member

ewels commented Apr 25, 2018

It would be great if the .fromPath() channel generator could have a new option checkIfExists which, well, checks if it exists. Working with full file paths as well as globs.

See https://gitter.im/nextflow-io/nextflow?at=5ae0a290b01085166cbdb928 for discussion.

Phil

@ewels
Copy link
Member Author

ewels commented Apr 25, 2018

@pditommaso
Copy link
Member

SUPER-LOL 😂😂😂

@stevekm
Copy link
Contributor

stevekm commented Apr 26, 2018

might also be able to do a custom filter step for this?

@pditommaso
Copy link
Member

What do you mean for custom filter step?

@stevekm
Copy link
Contributor

stevekm commented Apr 27, 2018

Like this:

Channel.from([
    ['bad1', file('input/bad1.vcf')],
    ['good1', file('input/good1.vcf')],
    ['foo', file('input/foo.vcf')]
    ])
    .filter { sampleID, sample_vcf ->
        def file_exists = sample_vcf.exists()
        if (! file_exists) println ">>> WARNING: File ${sample_vcf} does not exist and will not be included"
        file_exists
    }
    .set { demo_exists }

@pditommaso
Copy link
Member

pditommaso commented Apr 28, 2018

It looks the above comment is off-topic.

@pditommaso
Copy link
Member

Implementing this evil feature :)

I was just thuinking the checkIfExists is a bit verbose, what about shoudExist or mustExist, something else ?

@pditommaso pditommaso changed the title Channel.fromPath - new option "checkIfExists" Add option "checkIfExists" to Channel.fromPath method Sep 8, 2018
pditommaso added a commit that referenced this issue Sep 8, 2018
This commit adds a `checkIfExists` boolean option to Channel.fromPath method. When the option is specified with true value and the specified 
path does not exist in the file system an exception is thrown.

The same option has been added to the `file` helper method for 
consistency.
@pditommaso
Copy link
Member

OK, I went for checkIfExists that's the most redable. Available for test with version 0.32.0u2-SNAPSHOT.

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

No branches or pull requests

3 participants