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

array slices #120

Open
antonkulaga opened this issue Jun 30, 2017 · 3 comments
Open

array slices #120

antonkulaga opened this issue Jun 30, 2017 · 3 comments
Labels
L-enhancement (Legacy) An enhancement to the WDL language. Z-specification-change (Metadata) An issue or PR related to a specification change.

Comments

@antonkulaga
Copy link

Very often I need to slice an array. For instance, in RNA-Seq experiments I have tsv files with first column as a condtion and all subsequent as GSM ids for samples. It would be useful to get all elements of array except the first. I would love to have something either like Scala's head/tail or like Python access for slices of the array.

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

jdidion commented Feb 7, 2024

For the use case you describe above, I think it would be better handled by #194 - read the TSV with a header and cast the result to a struct. This will be available in WDL 1.2.

For creating a subset of an array, currently you can do:

Array[Int] my_array = [1,2,3]
for (i in range(1, 3)) {
  my_new_array = my_array[i]
}
# my_new_array == [2,3]

I agree this is not elegant, but I'm not sure how common the need is to do something like this.

We could add a function like:

Array[Int] my_subset = subset(my_array, 1, 3)

I also wouldn't mind if this were polymorphic over String as well:

String my_string = "hello"
String substring = subset(my_string,  1, 3)
# substring == "el"

@jdidion jdidion added Z-specification-change (Metadata) An issue or PR related to a specification change. feature request labels Feb 7, 2024
@kjaisingh
Copy link

+1 would be a helpful feature.

@kjaisingh
Copy link

kjaisingh commented Dec 6, 2024

for (i in range(1, 3)) {
my_new_array = my_array[i]
}

I don't believe this is supported natively in WDL either...

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
None yet
Development

No branches or pull requests

5 participants