Skip to content

Instantly share code, notes, and snippets.

@pvanheus
Created March 4, 2021 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvanheus/cd4c730ec429741d0e5567b33fb38b85 to your computer and use it in GitHub Desktop.
Save pvanheus/cd4c730ec429741d0e5567b33fb38b85 to your computer and use it in GitHub Desktop.
process_all_reads_tb_profiler.cwl
#!/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