aboutsummaryrefslogtreecommitdiff
path: root/scripts/split_into_arrays.cwl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/split_into_arrays.cwl')
-rw-r--r--scripts/split_into_arrays.cwl30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/split_into_arrays.cwl b/scripts/split_into_arrays.cwl
new file mode 100644
index 0000000..102fe7d
--- /dev/null
+++ b/scripts/split_into_arrays.cwl
@@ -0,0 +1,30 @@
+cwlVersion: v1.1
+class: ExpressionTool
+requirements:
+ InlineJavascriptRequirement: {}
+inputs:
+ dir:
+ type: Directory
+ loadListing: shallow_listing
+outputs:
+ fasta: File[]
+ metadata: File[]
+expression: |
+ ${
+ var dir = inputs.dir;
+ var fasta = [];
+ var metadata = [];
+ dir.listing.sort(function(a, b) { return a.basename < b.basename; });
+ for (var i = 0; i < dir.listing.length; i++) {
+ if (dir.listing[i].basename.substr(-6) == ".fasta") {
+ fasta.push(dir.listing[i]);
+ }
+ if (dir.listing[i].basename.substr(-5) == ".yaml") {
+ metadata.push(dir.listing[i]);
+ }
+ }
+ if (fasta.length != metadata.length) {
+ throw "They dont match";
+ }
+ return {"fasta": fasta, "metadata": metadata};
+ }