aboutsummaryrefslogtreecommitdiff
path: root/scripts/split_into_arrays.cwl
blob: 102fe7d50f25fa5c191d1573db3e7548420bdade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
cwlVersion: v1.1
class: ExpressionTool
requirements:
  InlineJavascriptRequirement: {}
inputs:
  dir:
    type: Directory
    loadListing: shallow_listing
outputs:
  fasta: File[]
  metadata: File[]
expression: |
  ${
  var dir = inputs.dir;
  var fasta = [];
  var metadata = [];
  dir.listing.sort(function(a, b) { return a.basename < b.basename; });
  for (var i = 0; i < dir.listing.length; i++) {
    if (dir.listing[i].basename.substr(-6) == ".fasta") {
      fasta.push(dir.listing[i]);
    }
    if (dir.listing[i].basename.substr(-5) == ".yaml") {
      metadata.push(dir.listing[i]);
    }
  }
  if (fasta.length != metadata.length) {
    throw "They dont match";
  }
  return {"fasta": fasta, "metadata": metadata};
  }