Get basename and use in command section

AsmaAsma Member, Broadie

Hello WDL Team,

I have task below:

task DigitalExpressionUMI {
String dropseq_home
String java_memory
String filter_input
Int umi_edit_distance
String cell_tag_collapsed
String barcodes

command {
mkdir "UMI_DGE"
filter_basename=(basename ${filter_input})
PATH:${dropseq_home}
DigitalExpression \
-m ${java_memory} \
I=${filter_input} \
O=UMI_DGE/$filter_basename.umi.dge.txt.gz \
EDIT_DISTANCE=${umi_edit_distance} \
CELL_BARCODE_TAG=${cell_tag_collapsed} \
SUMMARY=UMI_DGE/$filter_basename.umi.dge.summary.txt \
CELL_BC_FILE=${barcodes}
}

output {
File Dge_Umi_Output="UMI_DGE/$filter_basename.umi.dge.txt.gz"
File Dge_Umi_Summary="UMI_DGE/$filter_basename.umi.dge.summary.txt"
}
}

I get an error saying:
java.lang.RuntimeException: Could not evaluate DigitalExpressionReads.Dge_Reads_Output = "reads_DGE/$filter_basename.reads.dge.txt.gz"

I have also tried the following expression and that fails as well:

File Dge_Umi_Output="UMI_DGE/${filter_basename}.umi.dge.txt.gz"
This fails as well. How do I refer to the basename of $filter_input?

Thank you,
Asma

Answers

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie

    Hi Asma, I think your main problem is this expression: filter_basename=(basename ${filter_input})

    I believe that should be filter_basename=basename(filter_input) and should be taken outside of the command block

  • AsmaAsma Member, Broadie

    I figured out the correct syntax of basename, it should be filter_basename=$(basename ${filter_input}). I was missing a "$" before basename. I am running a test to see if it works.

  • AsmaAsma Member, Broadie

    This is what the task looks like now:

    task DigitalExpressionUMI {
    String dropseq_home
    String java_memory
    String filter_input
    Int umi_edit_distance
    String cell_tag_collapsed
    String barcodes

    command {
    mkdir "UMI_DGE"
    filter_basename=$(basename ${filter_input})
    PATH:${dropseq_home}:$PATH
    DigitalExpression \
    -m ${java_memory} \
    I=${filter_input} \
    O=UMI_DGE/$filter_basename.umi.dge.txt.gz \
    EDIT_DISTANCE=${umi_edit_distance} \
    CELL_BARCODE_TAG=${cell_tag_collapsed} \
    SUMMARY=UMI_DGE/$filter_basename.umi.dge.summary.txt \
    CELL_BC_FILE=${barcodes}
    }

    output {
    File Dge_Umi_Output="UMI_DGE/$filter_basename.umi.dge.txt.gz"
    File Dge_Umi_Summary="UMI_DGE/$filter_basename.umi.dge.summary.txt"
    }
    }

    Unfortunately, it stil fails because it can't evaluate the $filter_basename in command section. I have also tried ${filter_basename} but it still fails. I can point you the script as well if that makes it easier for you.

    Thank you,
    Asma

  • ChrisLChrisL Cambridge, MAMember, Broadie, Moderator, Dev

    @Asma when you're building up a command section, you can use the ${ } to exit out of verbatim-text mode and into WDL expression mode. Once you do that, you need to put a valid WDL expression inside the block. The valid WDL expression (just like you might use outside the command section) would be: basename(filter_input).

    So, I think the following should work for you here:

      filter_basename=${basename(filter_input)}
    

    (As a side note, I wonder whether you're using an IDE to develop your WDL? If you have a jetBrains IDE like intelliJ or pyCharm, there's a WDL plugin that will highlight the text differently depending on which mode you're in when writing the command block.)

  • AsmaAsma Member, Broadie

    filter_basename=${basename(filter_input)}, does not work, pipeline doesn't even begin to run. I have tried the following line filter_basename=${basename $(filter_input)}, though the pipeline starts; it errors out in command section at line O=UMI_DGE/${filter_basename}.umi.dge.txt.gz

Sign In or Register to comment.