d566841debec095f98d149929c41a67e5ab46322
[arvados-tutorial.git] / cwl / helper / gather-array-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   gvcfarray: 
23     type: File[] 
24   sample: string
25   reference:
26     type: File
27     secondaryFiles:
28       - .amb
29       - .ann
30       - .bwt
31       - .pac
32       - .sa
33       - .fai
34       - ^.dict
35 outputs:
36   gatheredgvcf:
37     type: File
38     secondaryFiles:
39       - .tbi
40     outputBinding:
41       glob: "*.g.vcf.gz"
42
43 baseCommand: /gatk/gatk
44
45 arguments:
46   - "--java-options"
47   - "-Xmx8G" 
48   - MergeVcfs
49   - shellQuote: false
50     valueFrom: | 
51      ${function compare(a, b) {
52       var baseA = a.basename;
53       var baseB = b.basename;
54
55       var comparison = 0;
56       if (baseA > baseB) {
57       comparison = 1;
58       } else if (baseA < baseB) {
59       comparison = -1;
60       }
61       return comparison;
62       }
63
64       var sortedarray = [];
65       sortedarray = inputs.gvcfarray.sort(compare)
66  
67       var samples = [];
68       for (var i = 0; i < sortedarray.length; i++) {
69         var name = sortedarray[i];
70         if (name.nameext ==='.gz' ) {
71           samples.push(name.path);
72         }
73       }
74      
75       var sampleinput = "";
76
77       for (var i = 0; i < samples.length; i++) {
78        var s1 = samples[i];
79        sampleinput = sampleinput + "-I " + s1 + " "
80       }
81     
82       return sampleinput;
83       }
84   - prefix: "-O"
85     valueFrom: $(inputs.sample).g.vcf.gz