Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vdauwera opened this issue Jul 16, 2016 · 3 comments
Closed

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

vdauwera opened this issue Jul 16, 2016 · 3 comments
Assignees
Labels
L-enhancement (Legacy) An enhancement to the WDL language. Z-specification-change (Metadata) An issue or PR related to a specification change.
Milestone

Comments

@vdauwera
Copy link

vdauwera commented Jul 16, 2016

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.

Draft implementation: https://github.com/openwdl/wdl/tree/43-map-values

@vdauwera
Copy link
Author

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

@vdauwera
Copy link
Author

https://github.com/broadinstitute/dsde-pipelines/pull/141 shows how this would be used in practice in the GOTC single-sample WDL.

@vdauwera vdauwera added the L-enhancement (Legacy) An enhancement to the WDL language. label Aug 6, 2017
@freeseek
Copy link
Contributor

I also feel like this is needed. Python has function items(), keys(), and values() for dictionaries. The current development version of WDL has function as_pairs() which is the equivalent of items() and function keys() but no function values(). This can be overcome using scatter, but it would be nice to have this capability inside tasks where scatter is not allowed. It limits the usefulness of maps which are otherwise extremely handy to pass information from workflows to tasks. Basically it feels odd that you have function zip(), as_pairs(), as_map(), and keys() with the function values() left out.

@jdidion jdidion moved this to Todo in WDL v1.2 Mar 23, 2023
@jdidion jdidion added this to WDL v1.2 Mar 23, 2023
@jdidion jdidion added this to the 1.2 milestone Mar 23, 2023
@jdidion jdidion self-assigned this Mar 25, 2023
@jdidion jdidion moved this from Todo to In Progress in WDL v1.2 Mar 25, 2023
@jdidion jdidion moved this from In Progress to Drafted in WDL v1.2 Feb 1, 2024
@jdidion jdidion added Z-specification-change (Metadata) An issue or PR related to a specification change. feature request labels Feb 7, 2024
@jdidion jdidion moved this from Drafted to Assigned in WDL v1.2 Mar 28, 2024
@jdidion jdidion moved this from Assigned to In Review in WDL v1.2 Mar 28, 2024
@jdidion jdidion moved this from In Review to Done in WDL v1.2 Apr 8, 2024
@jdidion jdidion closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L-enhancement (Legacy) An enhancement to the WDL language. Z-specification-change (Metadata) An issue or PR related to a specification change.
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants