{"@id":"https://w3id.org/cwl/view/git/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl","retrievedFrom":{"repoUrl":"https://github.com/Barski-lab/workflows.git","branch":"14d0618786c1499e8626f234341e99782a1e55c2","path":"subworkflows/allele-process-reference.cwl","packedId":null,"type":"GITHUB","rawUrl":"https://raw.githubusercontent.com/Barski-lab/workflows/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl","url":"https://github.com/Barski-lab/workflows/blob/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl"},"retrievedOn":"2026-10-16T20:35:27.833+00:00","lastCommit":"14d0618786c1499e8626f234341e99782a1e55c2","label":"allele-process-reference.cwl","inputs":{"threads":{"label":"Number of threads","doc":"Number of threads for those steps that support multithreading","type":"Integer (Optional)"},"bam_file":{"label":"BAM file","doc":"BAM file mapped to reference genome","type":"File"},"chrom_length_file":{"label":"Chromosome length file for reference genome","doc":"Chromosome length file for reference genome","type":"File"},"output_file_prefix":{"label":"Prefix for all generated output files","doc":"Corresponds to UID","type":"String"},"mapped_reads_number":{"label":"Uniquely mapped reads number","doc":"Uniquely mapped to reference genome reads number","type":"Integer"}},"outputs":{"bambai_pair":{"label":"Reference BAM","doc":"Coordinate sorted BAM file mapped to reference genome","type":"File"},"bigwig_file":{"label":"Reference bigWig file","doc":"Generated bigWig file for reference genome","type":"File"}},"steps":{"bam_to_bigwig":{"doc":"Workflow converts input BAM file into bigWig and bedGraph files\n","run":"bam-bedgraph-bigwig.cwl","runType":"WORKFLOW","sources":{"bam_to_bigwig":{"sourceIDs":["mapped_reads_number"]},"https://w3id.org/cwl/view/git/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl#bam_to_bigwig/bam_file":{"sourceIDs":["samtools_sort_index"]},"https://w3id.org/cwl/view/git/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl#bam_to_bigwig/chrom_length_file":{"sourceIDs":["chrom_length_file"]}}},"samtools_sort_index":{"doc":"Tool to sort and index input BAM/SAM/CRAM.\nIf input `trigger` is set to `true` or isn't set at all (`true` is used by default), run `samtools sort` and\n`samtools index`, return sorted BAM and BAI/CSI index file.\nIf input `trigger` is set to `false`, return unchanged `sort_input` (BAM/SAM/CRAM) and index (BAI/CSI, if provided in\n`secondaryFiles`) files, previously staged into output directory.\n\nBefore execution `baseCommand`, `sort_input` and `secondaryFiles` (if provided) are staged into directory\nset as docker parameter `--workdir` (tool's output directory), using `InitialWorkDirRequirement`. Setting\n`writable: true` makes cwl-runner to make copies of the `sort_input` and `secondaryFiles` (if provided) and mount\nthem to docker container with `rw` mode as part of `--workdir` (if set to false, the files staged into output\ndirectory will be mounted to docker container separately with `ro` mode). Because both `samtools sort` and\n`samtools index` can overwrite files with the same names (and in case of `samtools sort` even the input file can be\noverwritten), we don't need to rename any of the staged files.\n\nTrigger logic is implemented in two bash scripts set by default as `bash_script_sort` and `bash_script_index` inputs.\nFor both of then, if the first argument $0 (which is `trigger` input) is true, run `samtools sort/index` with the rest\nof the arguments. If $0 is not true, skip `samtools sort/index` and return `sort_input` and `secondaryFiles`\n(if provided) staged into output directory.\n\nInput `trigger` is Boolean, but returns String, because of `valueFrom` field. The `valueFrom` is used, because if `trigger`\nis false, cwl-runner doesn't append this argument at all to the the `baseCommand` - new feature of CWL v1.0.2. Alternatively,\n`prefix` field could be used, but it causes changing in script logic.\n\nIf using `sort_output_filename`, the output file extension should be `*.bam`, because `samtools sort` defines the output\nfile format on the base of the file extension. If `*.sam` is sed as output filename, it cannot be usefully indexed\nby `samtools index`.\n\n`default_bam` function is used to generate output filename for `samtools sort` if input `sort_output_filename` is not\nset or when `trigger` is false and we need to return `sort_input` and `secondaryFiles` (if provided) files staged into\noutput directory. Output filename is generated on the base of `sort_input` basename with `.bam` extension by default.\n\n`ext` function is used to return the index file extension (BAI/CSI) based on `csi` and `bai` inputs according to the\nfollowing logic\n  `csi` &&  `bai`  => BAI\n !`csi` && !`bai ` => BAI\n  `csi` && !`bai ` => CSI\n","run":"../tools/samtools-sort-index.cwl","runType":"COMMANDLINETOOL","sources":{"samtools_sort_index":{"sourceIDs":["output_file_prefix"]},"https://w3id.org/cwl/view/git/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl#samtools_sort_index/threads":{"sourceIDs":["threads"]},"https://w3id.org/cwl/view/git/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl#samtools_sort_index/sort_input":{"sourceIDs":["bam_file"]}}}},"cwltoolVersion":"3.1.20230201224320","visualisationDot":"digraph workflow {\n  graph [\n    bgcolor = \"#eeeeee\"\n    color = \"black\"\n    fontsize = \"10\"\n    labeljust = \"left\"\n    clusterrank = \"local\"\n    ranksep = \"0.22\"\n    nodesep = \"0.05\"\n  ]\n  node [\n    fontname = \"Helvetica\"\n    fontsize = \"10\"\n    fontcolor = \"black\"\n    shape = \"record\"\n    height = \"0\"\n    width = \"0\"\n    color = \"black\"\n    fillcolor = \"lightgoldenrodyellow\"\n    style = \"filled\"\n  ];\n  edge [\n    fontname=\"Helvetica\"\n    fontsize=\"8\"\n    fontcolor=\"black\"\n    color=\"black\"\n    arrowsize=\"0.7\"\n  ];\n  subgraph cluster_inputs {\n    rank = \"same\";\n    style = \"dashed\";\n    label = \"Workflow Inputs\";\n    \"output_file_prefix\" [fillcolor=\"#94DDF4\",label=\"Prefix for all generated output files\"];\n    \"mapped_reads_number\" [fillcolor=\"#94DDF4\",label=\"Uniquely mapped reads number\"];\n    \"chrom_length_file\" [fillcolor=\"#94DDF4\",label=\"Chromosome length file for reference genome\"];\n    \"bam_file\" [fillcolor=\"#94DDF4\",label=\"BAM file\"];\n    \"threads\" [fillcolor=\"#94DDF4\",label=\"Number of threads\"];\n  }\n  subgraph cluster_outputs {\n    rank = \"same\";\n    style = \"dashed\";\n    labelloc = \"b\";\n    label = \"Workflow Outputs\";\n    \"bambai_pair\" [fillcolor=\"#94DDF4\",label=\"Reference BAM\"];\n    \"bigwig_file\" [fillcolor=\"#94DDF4\",label=\"Reference bigWig file\"];\n  }\n  \"samtools_sort_index\" [label=\"samtools_sort_index\"];\n  \"bam_to_bigwig\" [label=\"bam_to_bigwig\", fillcolor=\"#F3CEA1\"];\n  \"output_file_prefix\" -> \"samtools_sort_index\" [label=\"sort_output_filename\"];\n  \"threads\" -> \"samtools_sort_index\" [label=\"threads\"];\n  \"bam_file\" -> \"samtools_sort_index\" [label=\"sort_input\"];\n  \"mapped_reads_number\" -> \"bam_to_bigwig\" [label=\"mapped_reads_number\"];\n  \"samtools_sort_index\" -> \"bam_to_bigwig\" [label=\"bam_file\"];\n  \"chrom_length_file\" -> \"bam_to_bigwig\" [label=\"chrom_length_file\"];\n  \"samtools_sort_index\" -> \"bambai_pair\";\n  \"bam_to_bigwig\" -> \"bigwig_file\";\n}\n","permalink":"https://w3id.org/cwl/view/git/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl","packed":false,"visualisationXdot":"/graph/xdot/github.com/Barski-lab/workflows/blob/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl","visualisationPng":"/graph/png/github.com/Barski-lab/workflows/blob/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl","visualisationSvg":"/graph/svg/github.com/Barski-lab/workflows/blob/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl","roBundle":"/robundle/github.com/Barski-lab/workflows/blob/14d0618786c1499e8626f234341e99782a1e55c2/subworkflows/allele-process-reference.cwl"}