{"@id":"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl","retrievedFrom":{"repoUrl":"https://github.com/Barski-lab/workflows.git","branch":"0a8a3a654518547047ca4c975795459ade904fe2","path":"subworkflows/allele-process-strain.cwl","packedId":null,"type":"GITHUB","rawUrl":"https://raw.githubusercontent.com/Barski-lab/workflows/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl","url":"https://github.com/Barski-lab/workflows/blob/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl"},"retrievedOn":"2026-09-23T02:24:56.423+00:00","lastCommit":"0a8a3a654518547047ca4c975795459ade904fe2","label":"allele-process-strain.cwl","inputs":{"threads":{"label":"Number of threads","doc":"Number of threads for those steps that support multithreading","type":"Integer (Optional)"},"hal_file":{"label":"HAL file","doc":"HAL file that includes current and reference strain information","type":"File"},"sam_file":{"label":"SAM file","doc":"SAM file with reads from both strains mapped to concatenated 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"},"current_strain_name":{"label":"Current strain name","doc":"Current strain name","type":"String"},"mapped_reads_number":{"label":"Mapped to concatenated genome reads number","doc":"Mapped to concatenated genome reads number to calculate scaling factor","type":"Integer"},"reference_strain_name":{"label":"Reference strain name","doc":"Reference strain name to be projected to","type":"String"}},"outputs":{"bambai_pair":{"label":"BAM mapped to strain genome, not projected to reference genome","doc":"Coordinate sorted BAM file mapped to the current strain genome, not projected to reference genome","type":"File"},"bigwig_file":{"label":"Strain specific bigWig file","doc":"Generated bigWig file for the current strain, projected to reference genome","type":"File"}},"steps":{"filter_sam":{"doc":"Tool to run custom script set as `script` input with arguments from `param`.\nDefault script runs sed command over the input file and exports results to the file with the same name as input's basename\n","run":"../tools/custom-bash.cwl","runType":"COMMANDLINETOOL","sources":{"filter_sam":{"sourceIDs":["sam_file"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#filter_sam/param":{"sourceIDs":["current_strain_name"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#filter_sam/script":{"defaultVal":"\\\"cat \\\"$0\\\" | grep \\\"$1\\\" | sed \\\"s/$1/chr/g\\\"  > `basename $0`\\\""}}},"sort_bedgraph":{"doc":"Tool sorts data from `unsorted_file` by key\n\n`default_output_filename` function returns file name identical to `unsorted_file`, if `output_filename` is not provided.\n","run":"../tools/linux-sort.cwl","runType":"COMMANDLINETOOL","sources":{"sort_bedgraph":{"sourceIDs":["bam_to_bedgraph"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#sort_bedgraph/key":{"defaultVal":"\\\"1,1\\\""}}},"bam_to_bedgraph":{"doc":"Tool calculates genome coverage from input bam/bed/gff/vcf using `bedtools genomecov`\n\nDepending on `input_file` extension additional prefix is used: if `*.bam` use `-ibam`, else use `-i`.\n\n`scale` and `mapped_reads_number` inputs result in the same parameter `-scale`. If `scale` is not provided, check if\n`mapped_reads_number` is not null and calculate `-scale` as `1000000/mapped_reads_number`. If both inputs are\nnull, `bedtools genomecov` will use its default scaling value.\n\n`default_output_filename` function returns default output filename and is used when `output_filename` is not provided.\nDefault output file extention is `.tab`. If bedGraph should be generated (check flags `inputs.depth`), extension is\nupdated to `.bedGraph`. Default basename of the output file is generated on the base of `input_file` basename.\n","run":"../tools/bedtools-genomecov.cwl","runType":"COMMANDLINETOOL","sources":{"bam_to_bedgraph":{"defaultVal":"true"},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#bam_to_bedgraph/depth":{"defaultVal":"\\\"-bg\\\""},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#bam_to_bedgraph/input_file":{"sourceIDs":["samtools_sort_index"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#bam_to_bedgraph/mapped_reads_number":{"sourceIDs":["mapped_reads_number"]}}},"remove_overlaps":{"doc":"Tool to run custom script set as `script` input with arguments from `param`. Based on bedops Dockerfile\nDefault script runs sed command over the input file and exports results to the file with the same name as input's basename\n\nThe temporary solution before the bedmap.cwl will be created\n","run":"../tools/custom-bedops.cwl","runType":"COMMANDLINETOOL","sources":{"remove_overlaps":{"defaultVal":"\\\"bedops --partition \\\"$0\\\" | bedmap --echo --echo-map-id --delim \\\"\\t\\\" - \\\"$0\\\" | awk '{n=split($4,reads,\\\";\\\"); sum=0; for(i=1;i<=n;i++) sum+=reads[i]; $4=sum; print $0 }' > `basename $0`\\\""},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#remove_overlaps/input_file":{"sourceIDs":["sort_filtered_bedgraph"]}}},"project_bedgraph":{"doc":"Runs halliftover to project input BED file from source to target genome.\n`source_genome_name` and `target_genome_name` should correspond to the fields in `hal_file`.\n\nIf `output_filename` is not set, call `default_output_filename` function.\n\nThe following parameters are not yet supported:\n  --outPSL\n  --outPSLWithName\n\nhalLiftover manual doesn't say anything if `input_bed_file` should be sorted or not\n","run":"../tools/halliftover.cwl","runType":"COMMANDLINETOOL","sources":{"project_bedgraph":{"sourceIDs":["hal_file"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#project_bedgraph/input_bed_file":{"sourceIDs":["sort_bedgraph"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#project_bedgraph/source_genome_name":{"sourceIDs":["current_strain_name"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#project_bedgraph/target_genome_name":{"sourceIDs":["reference_strain_name"]}}},"bedgraph_to_bigwig":{"doc":"Tool converts bedGraph to bigWig file.\n\n`default_output_filename` function returns filename for generated bigWig if `output_filename` is not provided.\nDefault filename is generated on the base of `bedgraph_file` basename with the updated to `*.bigWig` extension.\n","run":"../tools/ucsc-bedgraphtobigwig.cwl","runType":"COMMANDLINETOOL","sources":{"bedgraph_to_bigwig":{"sourceIDs":["remove_overlaps"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#bedgraph_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/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#samtools_sort_index/threads":{"sourceIDs":["threads"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#samtools_sort_index/sort_input":{"sourceIDs":["filter_sam"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#samtools_sort_index/sort_output_filename":{"sourceIDs":["current_strain_name"]}}},"sort_filtered_bedgraph":{"doc":"Tool to run custom script set as `script` input with arguments from `param`. Based on bedops Dockerfile\nDefault script runs sed command over the input file and exports results to the file with the same name as input's basename\n\nThe temporary solution before the bedmap.cwl will be created\n","run":"../tools/custom-bedops.cwl","runType":"COMMANDLINETOOL","sources":{"sort_filtered_bedgraph":{"sourceIDs":["filter_projected_bedgraph"]},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#sort_filtered_bedgraph/script":{"defaultVal":"\\\"sort-bed \\\"$0\\\" > `basename $0`\\\""}}},"filter_projected_bedgraph":{"doc":"Tool to run custom script set as `script` input with arguments from `param`.\nDefault script runs sed command over the input file and exports results to the file with the same name as input's basename\n","run":"../tools/custom-bash.cwl","runType":"COMMANDLINETOOL","sources":{"filter_projected_bedgraph":{"defaultVal":"\\\"cat \\\"$0\\\" | grep \\\"$1\\\" > `basename $0`\\\""},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#filter_projected_bedgraph/param":{"defaultVal":"\\\"chr\\\""},"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl#filter_projected_bedgraph/input_file":{"sourceIDs":["project_bedgraph"]}}}},"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    \"hal_file\" [fillcolor=\"#94DDF4\",label=\"HAL file\"];\n    \"sam_file\" [fillcolor=\"#94DDF4\",label=\"SAM file\"];\n    \"output_file_prefix\" [fillcolor=\"#94DDF4\",label=\"Prefix for all generated output files\"];\n    \"current_strain_name\" [fillcolor=\"#94DDF4\",label=\"Current strain name\"];\n    \"mapped_reads_number\" [fillcolor=\"#94DDF4\",label=\"Mapped to concatenated genome reads number\"];\n    \"threads\" [fillcolor=\"#94DDF4\",label=\"Number of threads\"];\n    \"chrom_length_file\" [fillcolor=\"#94DDF4\",label=\"Chromosome length file for reference genome\"];\n    \"reference_strain_name\" [fillcolor=\"#94DDF4\",label=\"Reference strain name\"];\n  }\n  subgraph cluster_outputs {\n    rank = \"same\";\n    style = \"dashed\";\n    labelloc = \"b\";\n    label = \"Workflow Outputs\";\n    \"bambai_pair\" [fillcolor=\"#94DDF4\",label=\"BAM mapped to strain genome, not projected to reference genome\"];\n    \"bigwig_file\" [fillcolor=\"#94DDF4\",label=\"Strain specific bigWig file\"];\n  }\n  \"samtools_sort_index\" [label=\"samtools_sort_index\"];\n  \"remove_overlaps\" [label=\"remove_overlaps\"];\n  \"bam_to_bedgraph\" [label=\"bam_to_bedgraph\"];\n  \"sort_bedgraph\" [label=\"sort_bedgraph\"];\n  \"project_bedgraph\" [label=\"project_bedgraph\"];\n  \"filter_projected_bedgraph\" [label=\"filter_projected_bedgraph\"];\n  \"filter_sam\" [label=\"filter_sam\"];\n  \"sort_filtered_bedgraph\" [label=\"sort_filtered_bedgraph\"];\n  \"bedgraph_to_bigwig\" [label=\"bedgraph_to_bigwig\"];\n  \"output_file_prefix\" -> \"samtools_sort_index\" [label=\"sort_output_filename\"];\n  \"current_strain_name\" -> \"samtools_sort_index\" [label=\"sort_output_filename\"];\n  \"threads\" -> \"samtools_sort_index\" [label=\"threads\"];\n  \"filter_sam\" -> \"samtools_sort_index\" [label=\"sort_input\"];\n  \"default1\" -> \"remove_overlaps\" [label=\"script\"];\n  \"default1\" [label=\"\\\"bedops --partition \\\"$0\\\" | bedmap --echo --echo-map-id --delim \\\"\\t\\\" - \\\"$0\\\" | awk '{n=split($4,reads,\\\";\\\"); sum=0; for(i=1;i<=n;i++) sum+=reads[i]; $4=sum; print $0 }' > `basename $0`\\\"\", fillcolor=\"#D5AEFC\"];\n  \"sort_filtered_bedgraph\" -> \"remove_overlaps\" [label=\"input_file\"];\n  \"default2\" -> \"bam_to_bedgraph\" [label=\"split\"];\n  \"default2\" [label=\"true\", fillcolor=\"#D5AEFC\"];\n  \"mapped_reads_number\" -> \"bam_to_bedgraph\" [label=\"mapped_reads_number\"];\n  \"samtools_sort_index\" -> \"bam_to_bedgraph\" [label=\"input_file\"];\n  \"default3\" -> \"bam_to_bedgraph\" [label=\"depth\"];\n  \"default3\" [label=\"\\\"-bg\\\"\", fillcolor=\"#D5AEFC\"];\n  \"bam_to_bedgraph\" -> \"sort_bedgraph\" [label=\"unsorted_file\"];\n  \"default4\" -> \"sort_bedgraph\" [label=\"key\"];\n  \"default4\" [label=\"\\\"2,2n\\\"\", fillcolor=\"#D5AEFC\"];\n  \"default5\" -> \"sort_bedgraph\" [label=\"key\"];\n  \"default5\" [label=\"\\\"1,1\\\"\", fillcolor=\"#D5AEFC\"];\n  \"hal_file\" -> \"project_bedgraph\" [label=\"hal_file\"];\n  \"sort_bedgraph\" -> \"project_bedgraph\" [label=\"input_bed_file\"];\n  \"reference_strain_name\" -> \"project_bedgraph\" [label=\"target_genome_name\"];\n  \"current_strain_name\" -> \"project_bedgraph\" [label=\"source_genome_name\"];\n  \"default6\" -> \"filter_projected_bedgraph\" [label=\"script\"];\n  \"default6\" [label=\"\\\"cat \\\"$0\\\" | grep \\\"$1\\\" > `basename $0`\\\"\", fillcolor=\"#D5AEFC\"];\n  \"default7\" -> \"filter_projected_bedgraph\" [label=\"param\"];\n  \"default7\" [label=\"\\\"chr\\\"\", fillcolor=\"#D5AEFC\"];\n  \"project_bedgraph\" -> \"filter_projected_bedgraph\" [label=\"input_file\"];\n  \"sam_file\" -> \"filter_sam\" [label=\"input_file\"];\n  \"current_strain_name\" -> \"filter_sam\" [label=\"param\"];\n  \"default8\" -> \"filter_sam\" [label=\"script\"];\n  \"default8\" [label=\"\\\"cat \\\"$0\\\" | grep \\\"$1\\\" | sed \\\"s/$1/chr/g\\\"  > `basename $0`\\\"\", fillcolor=\"#D5AEFC\"];\n  \"filter_projected_bedgraph\" -> \"sort_filtered_bedgraph\" [label=\"input_file\"];\n  \"default9\" -> \"sort_filtered_bedgraph\" [label=\"script\"];\n  \"default9\" [label=\"\\\"sort-bed \\\"$0\\\" > `basename $0`\\\"\", fillcolor=\"#D5AEFC\"];\n  \"remove_overlaps\" -> \"bedgraph_to_bigwig\" [label=\"bedgraph_file\"];\n  \"chrom_length_file\" -> \"bedgraph_to_bigwig\" [label=\"chrom_length_file\"];\n  \"samtools_sort_index\" -> \"bambai_pair\";\n  \"bedgraph_to_bigwig\" -> \"bigwig_file\";\n}\n","permalink":"https://w3id.org/cwl/view/git/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl","packed":false,"visualisationXdot":"/graph/xdot/github.com/Barski-lab/workflows/blob/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl","visualisationPng":"/graph/png/github.com/Barski-lab/workflows/blob/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl","visualisationSvg":"/graph/svg/github.com/Barski-lab/workflows/blob/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl","roBundle":"/robundle/github.com/Barski-lab/workflows/blob/0a8a3a654518547047ca4c975795459ade904fe2/subworkflows/allele-process-strain.cwl"}