0

As per the Nextflow documentation I put my awk scripts in the bin/ folder. Some scripts share the same functions so I wrote a file with only awk functions that I usually include using:

@include "relative/path/to/lib.awk"

But because the script runs in the nextflow work directory the relative path doesn't work anymore. I tried to put the library file in bin/ too but it didn't work as well.

How should I proceed? I don't want to copy/paste functions in the scripts, I also don't want to hardcode an absolute path.

3
  • can you use workflow.projectDir/path/to/awk ? Commented Nov 15, 2019 at 12:42
  • thanks for the tip, I didn't know about workflow.projectDir Commented Nov 15, 2019 at 19:22
  • glad to be of help Commented Nov 18, 2019 at 12:59

1 Answer 1

1

Thank you @Pallie for the tip about workflow.projectDir. The documentation about this variable is here (I thought I looked everywhere, it was not clear I could do that), this answer also helped: https://stackoverflow.com/a/28463193/2849598.

awk can load library files in AWKPATH, I have my file in lib/ so, for the nextflow process:

process my_process {
  input:
  path input from input_channel

  output:
  path "output.txt"

  script:
  """
  export AWKPATH="$workflow.projectDir/lib"
  script.awk ${input} > output.txt
  """
}

and at the top of my script I call the library file like such

@include "my_functions.awk"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.