Add a function to get a list of the values from a Map #43

Open
vdauwera opened this Issue Jul 16, 2016 · 2 comments

Comments

Projects
None yet
1 participant
Collaborator

vdauwera commented Jul 16, 2016 edited

I have a Map[String,File] from which I want to extract the values into an Array[File], that would be equivalent to eg the Java expression List list = map.values.

Justification: I need to provide multiple files to a task and I don't want to have to hardcode separate arguments for each. I can't just use an Array at the workflow inputs level because I need to be able to call on one of the files specifically in other tasks.

Worked out use case:

JSON

{
    "DoStuffWithKnownSitesWf.known_sites_VCFs_map": { "dbsnp": "dbsnp_138.vcf", "mills": "mills_indels.vcf", "other": "other_sites.vcf" }
    "DoStuffWithKnownSitesWf.known_sites_indices_map": { "dbsnp": "dbsnp_138.vcf.idx", "mills": "mills_indels.vcf.idx", "other": "other_sites.vcf.idx" }
}

WDL

task SomeTool {
    Array[File] known_sites_VCFs
    Array[File] known_sites_indices

    command { 
        doSomething -knownSites ${sep=" -knownSites " known_sites_VCFs}
    }
}

task SomeOtherTool {
    File dbSNP_VCF   
    File dbSNP_index

    command { 
        doSomethingElse --dbsnp  ${dbSNP_VCF}
    }
}

workflow DoStuffWithKnownSitesWf  {
    Map[String, File] known_sites_VCFs_map
    Map[String, File] known_sites_indices_map

    call SomeTool {
        input:
            known_sites_VCFs = known_sites_VCFs_map.values,
            known_sites_indices = known_sites_indices_map.values,
    }

    call SomeOtherTool {
        input:
            dbSNP_VCF = known_sites_VCFs_map["dbsnp"],
            dbSNP_index = known_sites_indices_map["dbsnp"],
    }
}

The expression dbSNP_VCF = known_sites_VCFs_map["dbsnp"] already works perfectly. But there's currently no way to do a straightforward known_sites_VCFs = known_sites_VCFs_map.values. This is the feature request. Actual syntax can be different of course.

Bonus points for making the keys available as well, though I don't have an immediate use case in mind.

Collaborator

vdauwera commented Jul 16, 2016

@kcibul Here's my ticket; let me know if you need any other info.

Collaborator

vdauwera commented Jul 16, 2016

broadinstitute/dsde-pipelines#141 shows how this would be used in practice in the GOTC single-sample WDL.

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