aboutsummaryrefslogtreecommitdiff
path: root/scripts/split_into_arrays.cwl
diff options
context:
space:
mode:
authorPeter Amstutz2020-07-03 20:45:17 +0000
committerPeter Amstutz2020-07-03 20:47:14 +0000
commit535b8017ddd27a9db683f6d29368258b5c48cf5a (patch)
tree521a3e446f0eb9cbdc6e8736a13706c8141f8351 /scripts/split_into_arrays.cwl
parent841af02eaa45c1b7395d5f4e4711de3c3661c146 (diff)
downloadbh20-seq-resource-535b8017ddd27a9db683f6d29368258b5c48cf5a.tar.gz
bh20-seq-resource-535b8017ddd27a9db683f6d29368258b5c48cf5a.tar.lz
bh20-seq-resource-535b8017ddd27a9db683f6d29368258b5c48cf5a.zip
Improving genbank import workflow
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};
+ }