Created
March 4, 2021 05:52
-
-
Save pvanheus/cd4c730ec429741d0e5567b33fb38b85 to your computer and use it in GitHub Desktop.
process_all_reads_tb_profiler.cwl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env cwl-runner | |
cwlVersion: v1.0 | |
class: Workflow | |
requirements: | |
InlineJavascriptRequirement: {} | |
ScatterFeatureRequirement: {} | |
StepInputExpressionRequirement: {} | |
inputs: | |
reads_dir: | |
type: Directory | |
outputs: | |
json_results: | |
type: File[] | |
outputSource: | |
process_read_pairs/json_output_file | |
text_results: | |
type: File[]? | |
outputSource: | |
process_read_pairs/text_output_file | |
steps: | |
make_read_pairs: | |
in: | |
reads_dir: reads_dir | |
out: | |
- read_pairs | |
run: | |
class: ExpressionTool | |
inputs: | |
reads_dir: | |
type: Directory | |
outputs: | |
read_pairs: | |
type: | |
type: array | |
items: | |
type: array | |
items: File | |
expression: | | |
${ | |
var read_pairs = Array(); | |
inputs.reads_dir.listing.forEach( function (entry) { | |
if (entry.class == "File" && (entry.location.endsWith("_2.fastq.gz") || entry.location.endsWith("_2.fastq."))) { | |
var read1 = Object.assign({}, entry); // shallow copy | |
read1.location = entry.location.replace('_2.fastq', '_1.fastq'); | |
read1.basename = entry.basename.replace('_2.fastq', '_1.fastq'); | |
read_pairs.push(Array(read1, entry)); | |
} | |
}); | |
console.log("pairs: " + read_pairs); | |
return {"read_pairs": read_pairs}; | |
} | |
process_read_pairs: | |
in: | |
sequences: | |
source: make_read_pairs/read_pairs | |
valueFrom: | | |
${ | |
var res = { | |
"read1": self[0], | |
"read2": self[1] | |
}; | |
console.log(res); | |
return res; | |
} | |
output_prefix: | |
source: make_read_pairs/read_pairs | |
valueFrom: | | |
${ | |
// get just the prefix of the sequence name | |
return self[0].basename.replace(/_1.fastq.*$/, ''); | |
} | |
text_output: | |
default: true | |
out: | |
- json_output_file | |
- text_output_file | |
scatter: | |
- sequences | |
- output_prefix | |
scatterMethod: dotproduct | |
run: | |
tb-profiler-profile.cwl | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment