collectFile(): and collect(): a way to return an error message if collection is finally empty #3732
-
Hi. Thanks for your excellent work ! Gael. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You could use // items to collect
ch_samples = Channel.empty()
ch_samples
| count
| subscribe { n ->
if ( n == 0 ) error "There are no items to collect"
}
ch_samples
| collect |
Beta Was this translation helpful? Give feedback.
-
Hi Ben.
Thanks a lot !
It works.
Best,
Gael.
De : Ben Sherman ***@***.***>
Envoyé : mercredi 8 mars 2023 16:04
À : nextflow-io/nextflow ***@***.***>
Cc : Gael MILLOT ***@***.***>; Author ***@***.***>
Objet : Re: [nextflow-io/nextflow] collectFile(): and collect(): a way to return an error message if collection is finally empty (Issue #3730)
You could use count and subscribe to check whether the incoming channel is empty before you call collect / collectFile. Here's an example:
// items to collect
ch_samples = Channel.empty()
ch_samples
| count
| subscribe { n ->
if ( n == 0 ) error "There are no items to collect"
}
ch_samples
| collect
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https:/github.com/nextflow-io/nextflow/issues/3730*issuecomment-1460297651__;Iw!!JFdNOqOXpB6UZW0!qmf77muDi5aRv9-2IIrHYwER407BQkD4v9hieMDXZMaxWmvamijqICKt8oaQPrSlcuYkxD3Uuo9kT1osoAuHa-spQtKr$>, or unsubscribe<https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AOVRK6UZ2LE44ANMS7IN5C3W3CNVZANCNFSM6AAAAAAVTYVX6A__;!!JFdNOqOXpB6UZW0!qmf77muDi5aRv9-2IIrHYwER407BQkD4v9hieMDXZMaxWmvamijqICKt8oaQPrSlcuYkxD3Uuo9kT1osoAuHa3B37R0N$>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
You could use
count
andsubscribe
to check whether the incoming channel is empty before you callcollect
/collectFile
. Here's an example: