aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlezhou8 <lezhou@protonmail.com>2023-03-24 11:15:50 +1100
committerJustin Bedő <cu@cua0.org>2023-03-27 23:01:10 +0000
commit59edb7d9c37a688c8c408508c1a9ae5d37df348f (patch)
tree3768833b8dde97231790d757d137c23b2a4b7b36
parent4ef81f5f631f5766287d3bbcb6bd1238259f0523 (diff)
samtools.queryRegion: queries regions from a fasta file
Only the indexing functionality of samtools faidx is used, rather than also the region querying functionality.
-rw-r--r--tools/samtools-queryRegion.nix22
-rw-r--r--tools/samtools.nix1
2 files changed, 23 insertions, 0 deletions
diff --git a/tools/samtools-queryRegion.nix b/tools/samtools-queryRegion.nix
new file mode 100644
index 0000000..650e4f4
--- /dev/null
+++ b/tools/samtools-queryRegion.nix
@@ -0,0 +1,22 @@
+{ bionix
+, flags ? null
+, regions ? []
+}:
+
+input:
+
+with bionix;
+with lib;
+with types;
+
+assert (matchFiletype "samtools-queryRegion" { fa = _: true; } input);
+
+stage {
+
+ name = "samtools-faidx";
+ buildInputs = with pkgs; [ samtools ];
+ buildCommand = ''
+ ln -s ${input} input.fasta
+ samtools faidx ${optionalString (flags != null) flags} input.fasta ${concatStringsSep " " regions} > $out
+ '';
+}
diff --git a/tools/samtools.nix b/tools/samtools.nix
index e0c45dd..32a563c 100644
--- a/tools/samtools.nix
+++ b/tools/samtools.nix
@@ -13,4 +13,5 @@ with bionix;
markdup = callBionixE ./samtools-markdup.nix;
fixmate = callBionixE ./samtools-fixmate.nix;
tabix = callBionixE ./samtools-tabix.nix;
+ queryRegion = callBionixE ./samtools-queryRegion.nix;
}