@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 Dirent: <https://w3id.org/cwl/cwl#Dirent/> .
@prefix cwl:   <https://w3id.org/cwl/cwl#> .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl>
        a                        cwl:Workflow ;
        rdfs:comment             " Workflow to merge a large number of maf files into a single consensus maf file for use with GetBaseCountsMultiSample " ;
        ns1:original_cwlVersion  "v1.0" ;
        Workflow:steps           <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#merge_all_mafs> , <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#deduplicate_maf> ;
        cwl:cwlVersion           <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/v1.2> ;
        cwl:hints                [ a                            <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/NetworkAccess> ;
                                   NetworkAccess:networkAccess  true
                                 ] ;
        cwl:hints                [ a       <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/LoadListingRequirement> ;
                                   LoadListingRequirement:loadListing
                                           "deep_listing"
                                 ] ;
        cwl:inputs               <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#maf_files> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#output_file> ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a  cwl:ScatterFeatureRequirement ] ;
        cwl:requirements         [ a  cwl:SubworkflowFeatureRequirement ] ;
        cwl:requirements         [ a  cwl:StepInputExpressionRequirement ] ;
        cwl:requirements         [ a  cwl:MultipleInputFeatureRequirement ] .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#maf_files>
        sld:type  [ sld:items  cwl:File ;
                    sld:type   sld:array
                  ] .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl#output_filename>
        cwl:default  "output.maf" ;
        sld:type     xsd:string .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl>
        a                        cwl:CommandLineTool ;
        rdfs:comment             " Special case of concat-tables.py to use with concatenating maf files for use with https://github.com/zengzheng123/GetBaseCountsMultiSample\nNote that these columns are required by GetBaseCountsMultiSample: ( as per https://github.com/zengzheng123/GetBaseCountsMultiSample/blob/master/GetBaseCountsMultiSample.cpp#L771-L801 )\nHugo_Symbol, Chromosome, Start_Position, End_Position, Reference_Allele, Tumor_Seq_Allele1, Tumor_Seq_Allele2, Tumor_Sample_Barcode, Matched_Norm_Sample_Barcode, t_ref_count, t_alt_count, n_ref_count, n_alt_count, Variant_Classification\nHowever, only these columns appear to influence the output:\nHugo_Symbol Chromosome Start_Position End_Position Variant_Classification Reference_Allele Tumor_Seq_Allele1 Tumor_Seq_Allele2\nusually in a column order matching this; grep -v '#' Proj_08390_G.muts.maf | cut -f1,5,6,7,9,11,12,13,16,17,41,42,44,45 > Proj_08390_G.cols.muts.maf\nalso, if present these columns also appear in output but seem to be optional\nCenter\tNCBI_Build\nsee also; https://docs.gdc.cancer.gov/Data/File_Formats/MAF_Format/ " ;
        ns1:original_cwlVersion  "v1.0" ;
        cwl:arguments            ( [ CommandLineBinding:position  1 ;
                                     CommandLineBinding:prefix    "-o" ;
                                     cwl:valueFrom                "$(inputs.output_filename)"
                                   ]
                                   [ CommandLineBinding:position  2 ;
                                     cwl:valueFrom                "${ return \"inputs_dir\" }"
                                   ]
                                 ) ;
        cwl:baseCommand          ( "concat-tables.py" "--dir" "--na-str" "." "--keep-cols" "Hugo_Symbol" "Chromosome" "Start_Position" "End_Position" "Variant_Classification" "Reference_Allele" "Tumor_Seq_Allele1" "Tumor_Seq_Allele2" "Center" "NCBI_Build" "--na-cols" "Tumor_Sample_Barcode" "Matched_Norm_Sample_Barcode" "t_ref_count" "t_alt_count" "n_ref_count" "n_alt_count" "--comments" "--no-carriage-returns" ) ;
        cwl:cwlVersion           <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/v1.2> ;
        cwl:hints                [ a       <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/LoadListingRequirement> ;
                                   LoadListingRequirement:loadListing
                                           "deep_listing"
                                 ] ;
        cwl:hints                [ a                            <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/NetworkAccess> ;
                                   NetworkAccess:networkAccess  true
                                 ] ;
        cwl:inputs               <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl#output_filename> , <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl#input_files> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl#output_file> ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ Dirent:writable  true ;
                                                  cwl:entry        "${\n  for (var i = 0; i < inputs.input_files.length; i++) {\n    inputs.input_files[i].basename = inputs.input_files[i].basename + \".\" + i;\n  }\n  return {class: 'Directory', listing: inputs.input_files};\n}" ;
                                                  cwl:entryname    "inputs_dir"
                                                ]
                                 ] ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "mskcc/helix_filters_01:21.4.1"
                                 ] .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#merge_all_mafs/input_files>
        cwl:source  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#maf_files> .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/deduplicate-maf.cwl#input_file>
        cwl:inputBinding  [ CommandLineBinding:position
                          1 ] ;
        sld:type          cwl:File .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl#input_files>
        sld:type  [ sld:items  cwl:File ;
                    sld:type   sld:array
                  ] .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#deduplicate_maf>
        cwl:in   <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#deduplicate_maf/input_file> ;
        cwl:out  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#deduplicate_maf/output_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/deduplicate-maf.cwl> .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#merge_all_mafs>
        cwl:in   <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#merge_all_mafs/input_files> ;
        cwl:out  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#merge_all_mafs/output_file> ;
        cwl:run  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl> .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/concat-mafs.cwl#output_file>
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "$(inputs.output_filename)" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/deduplicate-maf.cwl#output_file>
        cwl:outputBinding  [ CommandOutputBinding:glob
                          "dedup.maf" ] ;
        sld:type           cwl:File .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/deduplicate-maf.cwl>
        a                        cwl:CommandLineTool ;
        rdfs:comment             "Remove duplicate lines from the maf file\nExpected columns are in this order;\n1  Hugo_Symbol 2  Center 3  NCBI_Build 4  Chromosome 5  Start_Position 6  End_Position 7  Variant_Classification 8  Reference_Allele 9  Tumor_Seq_Allele1 10  Tumor_Seq_Allele2 11  n_alt_count 12  Matched_Norm_Sample_Barcode 13  t_alt_count 14  t_ref_count 15  n_ref_count 16  Tumor_Sample_Barcode\nNOTE: actually this order might be wrong but all that matters is that Chromosome and Start_Position are columns 4 and 5 " ;
        ns1:original_cwlVersion  "v1.0" ;
        cwl:baseCommand          ( "bash" "run.sh" ) ;
        cwl:cwlVersion           <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/v1.2> ;
        cwl:hints                [ a       <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/LoadListingRequirement> ;
                                   LoadListingRequirement:loadListing
                                           "deep_listing"
                                 ] ;
        cwl:hints                [ a                            <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/NetworkAccess> ;
                                   NetworkAccess:networkAccess  true
                                 ] ;
        cwl:inputs               <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/deduplicate-maf.cwl#input_file> ;
        cwl:outputs              <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/deduplicate-maf.cwl#output_file> ;
        cwl:requirements         [ a            cwl:InitialWorkDirRequirement ;
                                   cwl:listing  [ cwl:entry      "set -euo pipefail\ngrep '#' \"$1\" > comments || touch comments\ngrep '^Hugo_Symbol' \"$1\" > header || touch header\ngrep -v '^Hugo_Symbol' \"$1\" | grep -v '#' | sort -u > body.dedup\nsort -V -k4,4 -k5,5n body.dedup > body.sorted\ncat comments > dedup.maf\ncat header >> dedup.maf\ncat body.sorted >> dedup.maf" ;
                                                  cwl:entryname  "run.sh"
                                                ]
                                 ] ;
        cwl:requirements         [ a  cwl:InlineJavascriptRequirement ] ;
        cwl:requirements         [ a                             cwl:DockerRequirement ;
                                   DockerRequirement:dockerPull  "mskcc/helix_filters_01:21.4.1"
                                 ] .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#deduplicate_maf/input_file>
        cwl:source  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#merge_all_mafs/output_file> .

<https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#output_file>
        cwl:outputSource  <https://w3id.org/cwl/view/git/45604eaeea15030c7302941c761464ce392abf74/cwl/consensus_maf.cwl#deduplicate_maf/output_file> ;
        sld:type          cwl:File .
