-
Notifications
You must be signed in to change notification settings - Fork 306
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
engine function to map over an Array #203
Comments
Just a thought, what would you think of a list comprehension expression, eg something like the python syntax? (just throwing out some ideas here): # 1:
Array[String] arr_with_suffix = [ a in arr: a + "_1" ]
# 2:
Array[String] arr_with_suffix = [ arr: a => a + "_1" ]
# 3:
Array[String] arr_with_suffix = [ map arr: a => a + "_1" ]
# 4:
Array[String] arr_with_suffix = [ a + "_1" for a in arr ] |
A list comprehension sounds exactly like whats required, and I could work with any of that syntax. Do you imagine something like this would be allowed? |
@ruchim if we go down this route, I don't see why not! |
Another possible suggestion is to follow the path of vectorized languages like R or MATLAB (which in my experience are the two most common languages used by bioinformatics researches), and simply have functions be Array-aware. That is, if a scalar function that takes scalar input is run on an array, a new array is returned with each value being the result of that scalar function being run on the corresponding value of the input array (implicit map). |
Super convenient for array of maps of file with their indexes, i.e. array of bams and their bai. |
Hey @patmagee, is there any way to gain some momentum on this feature request? Is list comprehension an acceptable approach? I'm happy to target something against a spec and implement it in MiniWDL maybe? |
I like the addition but I'd opt for the less burdensome (on the user) approach suggested by @dheiman where if you pass an array of strings to something like |
There's currently one main function (prefix) that maps over all the elements in an array. When one wants to do some other kind of mapping/manipulation over all the elements in an array, they can do so by using a scatter block:
It would be great if there was an engine function that allowed for running functions over an Array type without requiring the boilerplate of a scatter block.
The text was updated successfully, but these errors were encountered: