Rearranging for clarity
[arvados-tutorial.git] / WGS-processing / cwl / helper / gather-vcf.cwl
1 cwlVersion: v1.1
2 class: CommandLineTool
3 label: Gathering vcf using Picard 
4 $namespaces:
5   arv: "http://arvados.org/cwl#"
6   cwltool: "http://commonwl.org/cwltool#"
7
8 requirements:
9   DockerRequirement:
10     dockerPull: broadinstitute/gatk:4.1.7.0
11   ShellCommandRequirement: {}
12   InlineJavascriptRequirement: {}
13
14 hints:
15   ResourceRequirement:
16     ramMin: 20000
17     coresMin: 4    
18   arv:RuntimeConstraints:
19     outputDirType: keep_output_dir
20
21 inputs:
22   gvcfdir: 
23     type: Directory
24     label: Input directory of gvcfs
25     loadListing: 'shallow_listing'
26   sample: string
27   reference:
28     type: File
29     secondaryFiles:
30       - .amb
31       - .ann
32       - .bwt
33       - .pac
34       - .sa
35       - .fai
36       - ^.dict
37 outputs:
38   gatheredgvcf:
39     type: File
40     secondaryFiles:
41       - .tbi
42     outputBinding:
43       glob: "*.g.vcf.gz"
44
45 baseCommand: /gatk/gatk
46
47 arguments:
48   - "--java-options"
49   - "-Xmx8G" 
50   - MergeVcfs
51   - shellQuote: false
52     valueFrom: | 
53      ${function compare(a, b) {
54       var baseA = a.basename;
55       var baseB = b.basename;
56
57       var comparison = 0;
58       if (baseA > baseB) {
59       comparison = 1;
60       } else if (baseA < baseB) {
61       comparison = -1;
62       }
63       return comparison;
64       } 
65
66       var samples = [];
67       for (var i = 0; i < inputs.gvcfdir.listing.length; i++) {
68         var name = inputs.gvcfdir.listing[i];
69         if (name.nameext ==='.gz' ) {
70           samples.push(name.path);
71         }
72       }
73       samples = samples.sort(compare);
74       var sampleinput = [];
75
76       for (var i = 0; i < samples.length; i++) {
77        var s1 = samples[i];
78        sampleinput = sampleinput + "-I " + s1 + " "
79       }
80     
81       return sampleinput;
82       }
83   - prefix: "-O"
84     valueFrom: $(inputs.sample).g.vcf.gz