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

Allow fromFilePairs to handle non globbing file patterns #946

Closed
ODiogoSilva opened this issue Nov 23, 2018 · 3 comments
Closed

Allow fromFilePairs to handle non globbing file patterns #946

ODiogoSilva opened this issue Nov 23, 2018 · 3 comments
Milestone

Comments

@ODiogoSilva
Copy link
Contributor

A common pattern to support having both single or paired-end reads onto the same channel definition is to do something like:

Channel.fromFilePairs( params.reads, size: params.singleEnd ? 1 : 2 )

This works fine for when params.reads is a glob pattern, but if you provide only a single file with an absolute path like:

--singleEnd --reads "/absolute/path/to/single/fastq.gz"

Nextflow throws an error:

ERROR ~ No signature of method: nextflow.Channel$_fromFilePairs0_closure6.call() is applicable for argument types: (sun.nio.fs.UnixPath) values: [/home/diogo/test/teste1]
Possible solutions: any(), any(), any(groovy.lang.Closure), each(groovy.lang.Closure), tap(groovy.lang.Closure), any(groovy.lang.Closure)

 -- Check '.nextflow.log' file for details

An immediate solution would be to add a wildcard to the provided path, but would it be possible for the fromFilePairs channel to also accept UnixPath arguments?

@pditommaso
Copy link
Member

Not sure why this is happening. I think the main reason is that it's not founding the any wildcard character.

@maxibor
Copy link

maxibor commented Jan 7, 2019

Same issue here.
NF channel code:

Channel
    .fromFilePairs( params.reads, size: params.singleEnd ? 1 : 2 )
    .ifEmpty { exit 1, "Cannot find any reads matching: ${params.reads}\n" }
    .into { reads_to_trim; reads_fastqc }

Params file

params {
    singleEnd = true
    reads = "/path/to/singleEnd.fq"
}

Yields:

Launching `main.nf` [high_northcutt] - revision: bcb793296b
true
class java.lang.Boolean
ERROR ~ No signature of method: nextflow.Channel$_fromFilePairs0_closure6.call() is applicable for argument types: (sun.nio.fs.UnixPath) values: [/path/to/singleEnd.fq]
Possible solutions: any(), any(), each(groovy.lang.Closure), any(groovy.lang.Closure), each(groovy.lang.Closure), any(groovy.lang.Closure)

 -- Check '.nextflow.log' file for details
ERROR ~ Cannot find any reads matching: /path/to/singleEnd.fq

However, if I set the params to the following, it works:

params {
    singleEnd = true
    reads = "/path/to/singleEnd.*"
}

Nextflow version: nextflow version 0.31.1.4886
Java version: openjdk version "1.8.0_152-release"
System version: Ubuntu 14.04.5 LTS

@pditommaso pditommaso changed the title fromFilePairs channel to accept UnixPath argument Allow fromFilePairs to handle non globbing file patterns Jan 8, 2019
pditommaso added a commit that referenced this issue Jan 8, 2019
This commit implements the support for non blobbing pattern for
Channel.fromFilePairs method. This means that it is possible to
specify a file path without any wildcard as matching pattern, eg.

Channel.fromFilePairs('/some/path/file-name.txt')

It returns the pair: ['file-name', ['/some/path/file-name.txt']]

Bonus: when the specified pattern does not contain any wildcard
character it defaults automatically to *single* pair, therefore
it’s not necessary to specify `size: 1` to handle this scenario.
@pditommaso pditommaso added this to the v19.04.0 milestone Jan 8, 2019
@pditommaso
Copy link
Member

pditommaso commented Jan 8, 2019

This commit implements the support for non globbing pattern for
Channel.fromFilePairs method. This means that it is possible to
specify a file path without any wildcard as matching pattern, eg.

Channel.fromFilePairs('/some/path/file-name.txt') 

It returns the pair:

['file-name', ['/some/path/file-name.txt']]

Bonus: when the specified pattern does not contain any wildcard
character it defaults automatically to single pair, therefore
it’s not necessary to specify size: 1 to handle this scenario.

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

No branches or pull requests

3 participants