From 0b0fb1c8a68df989bb2e1f593d717ac62e31d952 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 19 Oct 2020 21:04:19 -0400 Subject: Extract subset of the all-sequences fasta by running a sparql query. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- workflows/pangenome-generate/from_sparql.cwl | 23 +++++++++++++++++++++++ workflows/pangenome-generate/from_sparql.py | 8 ++++++++ 2 files changed, 31 insertions(+) create mode 100644 workflows/pangenome-generate/from_sparql.cwl create mode 100644 workflows/pangenome-generate/from_sparql.py (limited to 'workflows') diff --git a/workflows/pangenome-generate/from_sparql.cwl b/workflows/pangenome-generate/from_sparql.cwl new file mode 100644 index 0000000..5bc0792 --- /dev/null +++ b/workflows/pangenome-generate/from_sparql.cwl @@ -0,0 +1,23 @@ +cwlVersion: v1.1 +class: CommandLineTool +requirements: + DockerRequirement: + dockerFile: | + FROM debian:10 + RUN apt-get update && apt-get -yq --no-install-recommends install samtools python3-rdflib + dockerImageId: rdflib-and-samtools +inputs: + script: + type: File + default: + class: File + location: from_sparql.py + metadata: File + fasta: + type: File + secondaryFiles: [.fai] + query: string +stdout: selected.fasta +outputs: + selected: stdout +arguments: [python3, $(inputs.script), $(inputs.metadata), $(inputs.fasta), $(inputs.query)] diff --git a/workflows/pangenome-generate/from_sparql.py b/workflows/pangenome-generate/from_sparql.py new file mode 100644 index 0000000..4610cad --- /dev/null +++ b/workflows/pangenome-generate/from_sparql.py @@ -0,0 +1,8 @@ +from rdflib import Graph +import sys +import subprocess +g = Graph() +g.parse(sys.argv[1], format="nt") +res = g.query(sys.argv[3]) +for r in res: + subprocess.run(["samtools", "faidx", sys.argv[2], r[0]]) -- cgit v1.2.3