Skip to content
Advertisement

Why can’t Nextflow handle this awk phrase?

Background: Using a csv as input, I want to combine the first two columns into a new one (separated by an underscore) and add that new column to the end of a new csv.

Input:

JavaScript

Desired output:

JavaScript

The below awk phrase works from the command line:

JavaScript

However, when placed within a nextflow script (below) it gives an error.

JavaScript

Here is the error:

JavaScript

I’m not sure what is causing this, and any help would be appreciated.

Thanks!

Edit:

Yes it seems this was not the source of the error (sorry!). I’m trying to use splitCsv on the resulting csv and this appears to be what’s causing the error. Like so:

JavaScript

I expect my issue is it’s not acceptable to use .fromPath on a channel, but I can’t figure out how else to do it.


Edit 2:

So this was a stupid mistake. I simply needed to add the .splitCsv option directly after the input line where I invoked the channel. Hardly elegant, but appears to be working great now.

JavaScript

Advertisement

Answer

I was unable to reproduce the error you’re seeing with your example code and Nextflow version. In fact, I get the expected output. This shouldn’t be much of a surprise though, because you have correctly escaped the special dollar variables in your AWK command. The cause of the error is likely somewhere else in your code.

If escaping the special characters gets tedious, another way is to use a shell block instead:

It is an alternative to the Script definition with an important difference, it uses the exclamation mark ! character as the variable placeholder for Nextflow variables in place of the usual dollar character.

The example becomes:

JavaScript

Results:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement