Implementing a custom java class in nextflow files.
1
0
Entering edit mode
23 months ago

Hi all,

I would like to implement a custom java/groovy code in nextflow to help me document/parse the NF arguments params. Something like

class ArgumentFactory {
private static final ArgumentFactory INSTANCE = new ArgumentFactory();
public static ArgumentFactory getInstance() { return INSTANCE;}
(...)
}

and in another NF file

ArgumentFactory.getInstance().
        name("reference").
        description("path to the indexed FASTA reference").
        put(params)

and in another NF file

if(params.help) {
   ArgumentFactory.getInstance().printUsage();
    }

How can I do this in 'pure' NF ? I know I could write a java library and use it using the -lib parameter, but I'd like to do this in pure NF.

EDIT: here is an implementation:

groovy nf java nextflow • 1.7k views
ADD COMMENT
2
Entering edit mode
23 months ago
Maxime ▴ 20

I think we're doing some similar stuff in nf-core to check for args within the json schema and also to validate params and other things. You might want to look into it.

All our custom groovy stuff is in lib/: https://github.com/nf-core/tools/tree/master/nf_core/pipeline-template/lib

ADD COMMENT
0
Entering edit mode

thank you Maxime, is it possible to write the code in NF files (!= .groovy) ?

Or if it's groovy file, should they be compiled before running nextflow or will they be compiled at runtime ? I would like to avoid a pre-compile step.

ADD REPLY
1
Entering edit mode

I don't think there's any issue to write groovy code in .nf files. Not sure at all about the when the compilation will happen though...

ADD REPLY
0
Entering edit mode

I added an example above. The code compiles but I cannot use the class MyTest within the other NF file test.nf (even if if try to include it...)

ADD REPLY

Login before adding your answer.

Traffic: 2201 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6