Adding code to get fastqs from directory
authorSarah Wait Zaranek <swz@curii.com>
Tue, 16 Jun 2020 01:40:20 +0000 (01:40 +0000)
committerWard Vandewege <ward@jhvc.com>
Thu, 18 Jun 2020 15:16:40 +0000 (11:16 -0400)
Arvados-DCO-1.1-Signed-off-by: Sarah Wait Zaranek <swz@curii.com>
no issue #

cwl/helper/getfastq.cwl [new file with mode: 0644]

diff --git a/cwl/helper/getfastq.cwl b/cwl/helper/getfastq.cwl
new file mode 100644 (file)
index 0000000..a38bc91
--- /dev/null
@@ -0,0 +1,49 @@
+$namespaces:
+  arv: "http://arvados.org/cwl#"
+  cwltool: "http://commonwl.org/cwltool#"
+class: ExpressionTool
+cwlVersion: v1.1
+label: Create array of gvcfs to process
+requirements:
+  InlineJavascriptRequirement: {}
+inputs:
+  fastjdir:
+    type: Directory
+    label: Input directory of fastj
+    loadListing: 'shallow_listing' 
+outputs:
+  fastq1: 
+    type: File[]
+  fastq2:
+    type: File[]
+expression: |
+  ${function compare(a, b) {
+    var baseA = a.basename;
+    var baseB = b.basename;
+
+    var comparison = 0;
+    if (baseA > baseB) {
+    comparison = 1;
+    } else if (baseA < baseB) {
+    comparison = -1;
+    }
+    return comparison;
+    }
+
+    var fastq1 = [];
+    var fastq2 = [];
+    for (var i = 0; i < inputs.fastjdir.listing.length; i++) {
+      var name = inputs.fastjdir.listing[i];
+      if (name.basename.indexOf('_1.fastq.gz') != -1 ) {
+        fastq1.push(name);
+      }
+      if (name.basename.indexOf('_2.fastq.gz') != -1 ) {
+        fastq2.push(name);
+      }
+    }
+  
+    fastq1 = fastq1.sort(compare)
+    fastq2 = fastq2.sort(compare)
+    return {"fastq1": fastq1, "fastq2": fastq2};
+  }