Skip to content

Instantly share code, notes, and snippets.

@pditommaso
Last active June 15, 2018 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pditommaso/d20d8a56b790cdb656301eb95980fe0e to your computer and use it in GitHub Desktop.
Save pditommaso/d20d8a56b790cdb656301eb95980fe0e to your computer and use it in GitHub Desktop.
#!/usr/bin/env nextflow
Channel
.fromPath('hello.txt')
.map { [it, it.size()] }
.set { input_ch }
process foo {
memory { sz < 1_000_000 ? 2.GB : 8.GB }
input:
set file(x), val(sz) from input_ch
"""
you_command --input $x
"""
}
@rsuchecki
Copy link

You mentioned that:

Tho, I'm not loving it because it requires to fetch the file size separately. Needs to improved it to directly get it from the process.

— Paolo Di Tommaso (@PaoloDiTommaso) June 7, 2018

This works as well, would that be any better or did you have something else in mind to be able to do it from the config side?

#!/usr/bin/env nextflow 

input_ch = Channel.fromPath('hello.txt')

process foo {
  memory {x.size() < 1_000_000 ? 2.GB : 8.GB}
  input:
    file(x) from input_ch
  script:
  """
  you_command --input $x
  """
}

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