aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2021-12-06 17:23:47 +1100
committerJustin Bedo <cu@cua0.org>2021-12-06 17:23:47 +1100
commitd75b723281aea944fbafdb28f5b0841a03827b4a (patch)
tree1b3b8a6103ed6547d00b1e3e1b61b08038e08a27
parent18d442a951dc36a352c13c604642cb3d4db5a6b6 (diff)
parameterise RG line as nix attribute set
Allows more seamless transitioning between alingment algorithms
-rw-r--r--default.nix3
-rw-r--r--tools/bowtie-align.nix5
-rw-r--r--tools/bwa-mem.nix3
-rw-r--r--tools/bwa-mem2.nix2
-rw-r--r--tools/minimap2-align.nix2
5 files changed, 12 insertions, 3 deletions
diff --git a/default.nix b/default.nix
index db5d14f..6f6fb3d 100644
--- a/default.nix
+++ b/default.nix
@@ -109,7 +109,7 @@ let
'';
in
''
- mkdir $out
+ mkdir $out
'' + (concatStringsSep "\n" (mapAttrsToList link x));
passthru.linkInputs = x;
};
@@ -136,6 +136,7 @@ let
lib = nixpkgs.lib // {
inherit types;
shard = callBionix ./lib/shard.nix { };
+ concatMapAttrsStringsSep = s: f: a: with nixpkgs.lib; concatStringsSep s (mapAttrsToList f a);
};
stage = x@{ name, stripStorePaths ? true, multicore ? false, ... }:
(if stripStorePaths then strip else x: x)
diff --git a/tools/bowtie-align.nix b/tools/bowtie-align.nix
index 8df3dba..cca12a2 100644
--- a/tools/bowtie-align.nix
+++ b/tools/bowtie-align.nix
@@ -3,6 +3,7 @@
, bamOutput ? true
, flags ? null
, indexAttrs ? { }
+, RG ? { }
}:
{ input1
@@ -29,7 +30,9 @@ stage {
fi
bowtie2 -x ${bionix.bowtie.index indexAttrs ref}/ref ${optionalString (flags != null) flags} --threads $cores \
${if input2 != null then "-1 " + fq input1 + " -2 " + fq input2 else "-U " + fq input1} \
- | samtools sort -n \
+ ${optionalString (RG ? ID) ''
+ --rg-id ${RG.ID} ${concatMapAttrsStringsSep " " (k: v: "--rg ${k}:${v}") (filterAttrs (k: _: k != "ID") RG)} \
+ ''} \
${optionalString bamOutput "| samtools view -b"} \
> $out
'';
diff --git a/tools/bwa-mem.nix b/tools/bwa-mem.nix
index 52e73d1..84038d9 100644
--- a/tools/bwa-mem.nix
+++ b/tools/bwa-mem.nix
@@ -3,6 +3,7 @@
, bamOutput ? true
, flags ? null
, indexAttrs ? { }
+, RG ? { }
}:
{ input1
@@ -17,7 +18,6 @@ with compression;
let
fa = f: matchFiletype "bwa-ref" { fa = _: f; } f;
fq = f: matchFiletype "bwa-input" { fq = _: f; gz = matchFiletype' "bwa-input" { fq = _: f; }; } f;
-
in
stage {
name = "bwa-mem";
@@ -33,6 +33,7 @@ stage {
fi
bwa mem ${optionalString (flags != null) flags} -t $cores ref.fa ${fq input1} \
${optionalString (input2 != null) (fq input2)} \
+ ${optionalString (RG ? ID) "-R'@RG\\t${concatMapAttrsStringsSep "\\t" (k: v: "${k}:${v}") RG}'"} \
${optionalString bamOutput "| samtools view -b"} \
> $out
'';
diff --git a/tools/bwa-mem2.nix b/tools/bwa-mem2.nix
index 843c5b0..e6237f0 100644
--- a/tools/bwa-mem2.nix
+++ b/tools/bwa-mem2.nix
@@ -3,6 +3,7 @@
, bamOutput ? true
, flags ? null
, indexAttrs ? { }
+, RG ? { }
}:
{ input1
@@ -33,6 +34,7 @@ stage {
fi
bwa-mem2 mem ${optionalString (flags != null) flags} -t $cores ref.fa ${fq input1} \
${optionalString (input2 != null) (fq input2)} \
+ ${optionalString (RG ? ID) "-R'@RG\\t${concatMapAttrsStringsSep "\\t" (k: v: "${k}:${v}") RG}'"} \
${optionalString bamOutput "| samtools view -b"} \
> $out
'';
diff --git a/tools/minimap2-align.nix b/tools/minimap2-align.nix
index 18bca35..e7e71c6 100644
--- a/tools/minimap2-align.nix
+++ b/tools/minimap2-align.nix
@@ -3,6 +3,7 @@
, bamOutput ? true
, flags ? null
, preset
+, RG ? { }
}:
{ input1
@@ -30,6 +31,7 @@ stage {
fi
minimap2 ${optionalString (flags != null) flags} -t $cores -ax ${preset} ref.fa ${fq input1} \
${optionalString (input2 != null) (fq input2)} \
+ ${optionalString (RG ? ID) "-R'@RG\\t${concatMapAttrsStringsSep "\\t" (k: v: "${k}:${v}") RG}'"} \
${optionalString bamOutput "| samtools view -b"} \
> $out
'';