To celebrate the release of GATK 4.0, we are giving away free credits for running the GATK4 Best Practices pipelines in FireCloud, our secure online analysis portal. It’s first come first serve, so sign up now to claim your free credits worth $250. Sponsored by Google Cloud. Learn more at

getting tail of the array

I have a tsv file where the first column is condition_name of RNA-Seq and all subsequent columns are GSM ids. How can I get .tail of the array for each row to scatter over it?
I see there is a method select_first for the head of the array, but I do not see any methods to select the tail of array in WDL specification


  • danbdanb Member, Broadie

    select_first is for getting the first defined value in an array of optional values, which is not necessarily the head.

    You would like to see an actual "tail" function on an array, regardless of the Array value type. Correct?

    In either case we do not currently offer such a function, but I will create a Github issue to capture this request.

  • ChrisLChrisL Cambridge, MAMember, Broadie, Dev
    edited July 2017

    @antonkulaga there's often a hacky way to do this sort of thing with scatters and if blocks, in this case you could do this:

    workflow behead_list {
      # Example input: [ "A", "B", "C", "D" ]
      Array[String] withUnwantedHead
      # In our example: [ 0, 1, 2, 3 ] 
      Array[Int] indices = range(length(withUnwantedHead))
      # In our example: [ (0, "A"), (1, "B"), (2, "C"), (3, "D") ] 
      Array[Pair[Int, String]] zippedwithIndices = zip(indices, withUnwantedHead)
      scatter(p in zippedwithIndices) {
        if (p.left != 0) {
          String notFirst = p.right
      # Outside the if and scatter, the value of 'notFirst' is an array of optionally-set Strings:
      # In our example: [ null, "B", "C", "D" ]
      Array[String?] everythingExceptFirst = notFirst
      # Use select_all to get the good stuff:
      output {
        # In our example: [ "B", "C", "D" ]
        Array[String] withoutUnwantedHead = select_all(everythingExceptFirst)
Sign In or Register to comment.