how to find out the set profile

339 views
Skip to first unread message

Marc Logghe

unread,
Nov 9, 2015, 8:49:18 AM11/9/15
to Nextflow
Hi,
Suppose you'd like to set the task.command depending on the chosen profile. What is the best way to find out the set profile (eg. is it 'standard' or something else).
One way would be to parse the command line found in workflow.commandLine. But I guess the command line has already been parsed, it is just a matter to find in which object the properties are stored.

Thanks and regards,
Marc

Paolo Di Tommaso

unread,
Nov 9, 2015, 9:09:59 AM11/9/15
to nextflow
Hi Marc, 

Currently the selected profile is not included in the workflow object. Anyway this looks a very useful idea. Would you like to open an feature request on the nextflow github repo for that?


A possible workaround is to define a process custom attribute depending the profile chosen. 


For example, you can use a nextflow.config file like the following 

profiles {
 
  standard {
    process.ext.flag = 'alpha'
  }

  cluster {
    process.ext.flag = 'beta'
  }



Then you will be able to access that flag as show below: 


process foo {

  exec: 
  println task.ext.flag

}



Hope this helps.

Cheers,
Paolo
 



--
You received this message because you are subscribed to the Google Groups "Nextflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nextflow+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/nextflow.
For more options, visit https://groups.google.com/d/optout.

Marc Logghe

unread,
Nov 9, 2015, 5:10:26 PM11/9/15
to Nextflow


Op maandag 9 november 2015 15:09:59 UTC+1 schreef Paolo Di Tommaso:
Hi Marc, 

Currently the selected profile is not included in the workflow object. Anyway this looks a very useful idea. Would you like to open an feature request on the nextflow github repo for that?


I will do that.
 
A possible workaround is to define a process custom attribute depending the profile chosen. 


For example, you can use a nextflow.config file like the following 

profiles {
 
  standard {
    process.ext.flag = 'alpha'
  }

  cluster {
    process.ext.flag = 'beta'
  }



Then you will be able to access that flag as show below: 


process foo {

  exec: 
  println task.ext.flag

}



Hope this helps.

This workaround helps allright. Thanks !
Regards,
Marc 

Marc Logghe

unread,
Nov 20, 2015, 5:17:09 AM11/20/15
to Nextflow
For the record.
In NextFlow 0.16.2 the profile option is available in the workflow.profile property (thanks Paolo). This allows a process to pick a profile specific template as follows:

In nextflow.config:

process {
  command
= {
   
"${workflow.profile}/${task.process}"
 
}
}


In the templates folder save scripts in subfolder that matches the profile name. So, you should at least keep your templates in templates/standard. The template name should have the same name as your process, eg. templates/standard/process1

Define the template in your pipeline as such:

process process1 {
  input
:
 
...

  output
:
 
...

  shell
:
 
template(task.command)
}


So, for a profile my_custom_profile, simply create the templates/my_custom_profile folder and save the profile specific templates in there. Create links to the standard ones in case they are not different.

Cheers,
Marc

Paolo Di Tommaso

unread,
Nov 20, 2015, 6:54:37 AM11/20/15
to nextflow
Hi Marc, 

Thanks for pointing this out. This is a very tricky (in the meaning of smart) use of Nextflow template and configuration features. 


Cheers,
Paolo



Marc Logghe

unread,
Nov 20, 2015, 7:18:17 AM11/20/15
to Nextflow
Credits should go to Emilio Palumbo; found the basic idea behind it in https://github.com/guigolab/grape-nf
;-)
Cheer,
ML

Op vrijdag 20 november 2015 12:54:37 UTC+1 schreef Paolo Di Tommaso:

Paolo Di Tommaso

unread,
Nov 20, 2015, 7:22:07 AM11/20/15
to nextflow
That's true. 

He shocked me when he drawn out this solution. He suggested him to write a blog post about that but he always refused ;)


Best, p 

Emilio

unread,
Nov 24, 2015, 5:00:25 AM11/24/15
to next...@googlegroups.com
Hi Marc,
thanks for the profile-specific-template example.

And thanks for the credits! I really wanted to have as much flexibility as possible and I was also kind of surprised when this idea came to my mind. I discussed it with Paolo and thanks to him we now have this amazing feature in Nextflow. 😉

Cheers,
Emilio
Reply all
Reply to author
Forward
0 new messages