@prefix LoadListingRequirement: <http://commonwl.org/cwltool#LoadListingRequirement/> .
@prefix CommandLineBinding: <https://w3id.org/cwl/cwl#CommandLineBinding/> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix DockerRequirement: <https://w3id.org/cwl/cwl#DockerRequirement/> .
@prefix Workflow: <https://w3id.org/cwl/cwl#Workflow/> .
@prefix sld:   <https://w3id.org/cwl/salad#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix CommandOutputBinding: <https://w3id.org/cwl/cwl#CommandOutputBinding/> .
@prefix ns1:   <http://commonwl.org/cwltool#> .
@prefix NetworkAccess: <http://commonwl.org/cwltool#NetworkAccess/> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cwl:   <https://w3id.org/cwl/cwl#> .
@prefix ResourceRequirement: <https://w3id.org/cwl/cwl#ResourceRequirement/> .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "The program can handle the following classes of inputs:\n - single end reads (only reads File and rg string provided)\n - reads with mates (reads File, mates File, and rg string provided)\n - interleaved reads (reads File provided, rg string provided, and interleaved set to true)\nThis tool runs the following programs:\n - bwa mem | samblaster | sambamba view | sambamba sort" ;
        ns1:original_cwlVersion  "v1.0" ;
        cwl:arguments            ( [ CommandLineBinding:position    0 ;
                                     CommandLineBinding:shellQuote  false ;
                                     cwl:valueFrom                  "set -eo pipefail\nbwa mem -K 100000000 ${if (inputs.interleaved) {return '-p';} else {return \"\"}} -v 3 -t 36 -Y $(inputs.ref.path) -R '${return inputs.rg}' ${return inputs.reads.path} ${if (inputs.mates != null) {return inputs.mates.path} else {return \"\"}} | /opt/samblaster/samblaster -i /dev/stdin -o /dev/stdout | /opt/sambamba_0.6.3/sambamba_v0.6.3 view -t 36 -f bam -l 0 -S /dev/stdin | /opt/sambamba_0.6.3/sambamba_v0.6.3 sort -t 36 --natural-sort -m 15GiB --tmpdir ./ -o ${if (inputs.reads != null) {return inputs.reads.nameroot} else {return \"\"}}.unsorted.bam -l 5 /dev/stdin"
                                   ]
                                 ) ;
        cwl:baseCommand          ( "/bin/bash" "-c" ) ;
        cwl:cwlVersion           <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/v1.2> ;
        cwl:hints                [ a       <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/LoadListingRequirement> ;
                                   LoadListingRequirement:loadListing
                                           "deep_listing"
                                 ] ;
        cwl:hints                [ a                            <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/NetworkAccess> ;
                                   NetworkAccess:networkAccess  true
                                 ] ;
        cwl:inputs               <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/rg> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/mates> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/interleaved> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/reads> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/ref> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/output> ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "zhangb1/bwa-kf-bundle:0.1.17"
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] ;
        cwl:requirements         [ a                             cwl:ResourceRequirement ;
                                   ResourceRequirement:coresMin  36 ;
                                   ResourceRequirement:ramMin    50000
                                 ] .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/output>
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "*.bam" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/reads>
        rdfs:comment  "Primary reads file" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/rg>
        cwl:source  <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/input_se_rgs> .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/zcat_split_reads>
        cwl:hints  [ a    <https://sevenbridges.comAWSInstanceType> ] ;
        cwl:in     <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/zcat_split_reads/input_fastq> ;
        cwl:out    <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/zcat_split_reads/output> ;
        cwl:run    <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl> .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads>
        cwl:in       <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/reads> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/ref> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/rg> ;
        cwl:out      <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/output> ;
        cwl:run      <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl> ;
        cwl:scatter  ( <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/reads> ) .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/input_se_reads>
        sld:type  cwl:File .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/mates>
        rdfs:comment  "Mates file for the reads" ;
        sld:type      cwl:File , sld:null .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/ref>
        cwl:source  <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/indexed_reference_fasta> .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp/input_fastq>
        rdfs:comment  "Input fastq file" ;
        sld:type      cwl:File .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set>
        a                        cwl:Workflow ;
        ns1:original_cwlVersion  "v1.0" ;
        Workflow:steps           <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/zcat_split_reads> ;
        cwl:cwlVersion           <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/v1.2> ;
        cwl:hints                [ a  <https://sevenbridges.commaxNumberOfParallelInstances> ] ;
        cwl:hints                [ a       <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/LoadListingRequirement> ;
                                   LoadListingRequirement:loadListing
                                           "deep_listing"
                                 ] ;
        cwl:hints                [ a                            <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/NetworkAccess> ;
                                   NetworkAccess:networkAccess  true
                                 ] ;
        cwl:inputs               <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/input_se_reads> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/input_se_rgs> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/indexed_reference_fasta> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/unsorted_bams> ;
        cwl:requirements         [ a  cwl:ScatterFeatureRequirement ] ;
        cwl:requirements         [ a  cwl:MultipleInputFeatureRequirement ] ;
        cwl:requirements         [ a  cwl:SubworkflowFeatureRequirement ] .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/reads>
        cwl:source  <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/zcat_split_reads/output> .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/unsorted_bams>
        cwl:outputSource  <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/bwa_mem_split_se_reads/output> ;
        sld:type          [ sld:items  cwl:File ;
                            sld:type   sld:array
                          ] .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp/output>
        cwl:outputBinding  [ CommandOutputBinding:glob  "*.fq" ;
                             CommandOutputBinding:outputEval
                                     "${\n  if (self.length == 0) return [inputs.input_fastq]\n  else return self\n}"
                           ] ;
        sld:type           [ sld:items  cwl:File ;
                             sld:type   sld:array
                           ] .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/input_se_rgs>
        sld:type  xsd:string .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/zcat_split_reads/input_fastq>
        cwl:source  <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/input_se_reads> .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/rg>
        rdfs:comment  "Formatted RG header to use in the resulting BAM, check BWA for formatting guidelines (e.g. escaped tabs '\\t')" ;
        sld:type      xsd:string .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/interleaved>
        rdfs:comment  "The reads input is interleaved" ;
        cwl:default   false ;
        sld:type      xsd:boolean .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/bwa_mem_naive.cwl#bwa_mem_naive/ref>
        rdfs:comment        "Reference fasta file with associated indexes" ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        sld:type            cwl:File .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/subworkflows/kfdrc_process_se_set.cwl#kfdrc_process_se_set/indexed_reference_fasta>
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        cwl:secondaryFiles  []  ;
        sld:type            cwl:File .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "This tool will chomp any fastq larger than the max size (10 gb by default) into 320000000 line chunks (80M reads). \nPrograms used in this tool:\n  - zcat | split\n  - ls | mv" ;
        ns1:original_cwlVersion  "v1.0" ;
        cwl:arguments            ( [ CommandLineBinding:position    0 ;
                                     CommandLineBinding:shellQuote  false ;
                                     cwl:valueFrom                  "set -eo pipefail\n\nif [ $(inputs.input_fastq.size) -gt $(inputs.max_size) ]; then\n  zcat $(inputs.input_fastq.path) | split -dl 320000000 - reads-\n  ls reads-* | xargs -i mv {} {}.fq\nelse\n  echo \"FASTQ not large enough to split.\"\nfi"
                                   ]
                                 ) ;
        cwl:baseCommand          ( "/bin/bash" "-c" ) ;
        cwl:cwlVersion           <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/v1.2> ;
        cwl:hints                [ a       <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/LoadListingRequirement> ;
                                   LoadListingRequirement:loadListing
                                           "deep_listing"
                                 ] ;
        cwl:hints                [ a                            <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/NetworkAccess> ;
                                   NetworkAccess:networkAccess  true
                                 ] ;
        cwl:inputs               <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp/input_fastq> , <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp/max_size> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp/output> ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a                             cwl:ResourceRequirement ;
                                   ResourceRequirement:coresMin  4 ;
                                   ResourceRequirement:ramMin    8000
                                 ] ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "kfdrc/bwa-bundle:dev"
                                 ] ;
        cwl:requirements         [ a  cwl:ShellCommandRequirement ] .

<https://w3id.org/cwl/view/git/3fba930f3eca7880320fa19744e377a9d5dca9d5/tools/fastq_chomp.cwl#fastq_chomp/max_size>
        rdfs:comment  "The maximum size (in bytes) that an input bam can be before the FASTQ is split" ;
        cwl:default   10000000000 ;
        sld:type      xsd:int .
