Update: July 26, 2019
This section of the forum is now closed; we are working on a new support model for WDL that we will share here shortly. For Cromwell-specific issues, see the Cromwell docs and post questions on Github.

No coercion defined from '"/file/path" of type 'File?' to 'File'

Hello wdl team,

I use optional parameters that accept input depending on a boolean value. One of the optional parameters is of type file and here is how I am using it:

workflow metagenomics {
     Boolean fastq
     Boolean fasta
     Boolean pe
     Boolean se
     ...
     File? left_fq
     File? right_fq
     File? unpaired_reads_se
     File? unpaired_reads_fasta
if (fastq) {
   if (pe){
 call classifier_pe {
     input:
          ...
          Left_fq=left_fq,
          Right_fq=right_fq
                    }   
          }   

}
...
I get the following error when I try to run it:

No coercion defined from '"/path/SRR073747_2.fastq"' of type 'File?' to 'File'.

java.lang.IllegalArgumentException: No coercion defined from '"/path/SRR073747_2.fastq"' of type 'File?' to 'File'.

What am I doing wrong here? Appreciate your help!

Answers

  • ChrisLChrisL Cambridge, MAMember, Broadie, Dev admin

    The problem here is that the File input is optional, but the task you're calling always requires a File to be supplied (i.e. not optionally). Cromwell doesn't allow this because (especially in long workflows) you could be a long way through the workflow before you hit the problem of a required File input not being provided and the workflow failing when Cromwell could have warned about that happening upfront.

    If you give me some info on what the rest of the workflow looks like, I could perhaps help you come up with a more idiomatic workflow that should work for you.

    In the mean time you can force the coercion by using the select_first function with only a single-element array input e.g.

    File? input
    File forced_input = select_first( [ input ] ) # Fails the workflow if input is not supplied
    
Sign In or Register to comment.