Updating cwl and yml for intervals and other changes
[arvados-tutorial.git] / WGS-processing / cwl / helper / getfastq.cwl
1 class: ExpressionTool
2 cwlVersion: v1.1
3 label: Find matching FASTQ pairs
4 requirements:
5   InlineJavascriptRequirement: {}
6
7 inputs:
8   fastqdir:
9     type: Directory
10     label: Input directory of FASTQs
11     loadListing: 'shallow_listing'
12
13 outputs:
14   fastq1: 
15     type: File[]
16     format: edam:format_1930 # FASTQ
17     label: Half set of pair-end FASTQs (R1)
18   fastq2:
19     type: File[]
20     format: edam:format_1930 # FASTQ
21     label: Half set of pair-end FASTQs (R2)
22   sample:
23     type: string[]
24     label: Sample Names
25
26 expression: |
27   ${function compare(a, b) {
28     var baseA = a.basename;
29     var baseB = b.basename;
30
31     var comparison = 0;
32     if (baseA > baseB) {
33     comparison = 1;
34     } else if (baseA < baseB) {
35     comparison = -1;
36     }
37     return comparison;
38     }
39
40     var fastq1 = [];
41     var fastq2 = [];
42     for (var i = 0; i < inputs.fastqdir.listing.length; i++) {
43       var name = inputs.fastqdir.listing[i];
44       name.format = 'http://edamontology.org/format_1930'
45       if (name.basename.indexOf('_1.fastq.gz') != -1 ) {
46         fastq1.push(name);
47       }
48       if (name.basename.indexOf('_2.fastq.gz') != -1 ) {
49         fastq2.push(name);
50       }
51     }
52   
53     fastq1 = fastq1.sort(compare)
54     fastq2 = fastq2.sort(compare)
55
56     var sample = [];
57
58     for (var i = 0; i < fastq1.length; i++) {
59       var name = fastq1[i].basename;
60       var samplename = name.replace(/_1.fastq.gz/,'');
61       sample.push(samplename);
62       }
63
64  
65     return {"fastq1": fastq1, "fastq2": fastq2, "sample": sample};
66   }
67
68
69 s:codeRepository: https://github.com/arvados/arvados-tutorial
70 s:license: https://www.gnu.org/licenses/agpl-3.0.en.html
71
72 $namespaces:
73  s: https://schema.org/
74  edam: http://edamontology.org/
75  arv: "http://arvados.org/cwl#"
76  cwltool: "http://commonwl.org/cwltool#"
77
78 #$schemas:
79 # - https://schema.org/version/latest/schema.rdf
80 # - http://edamontology.org/EDAM_1.18.owl