forked from jbedo/malaria-variant-calling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsgenome.nix
55 lines (48 loc) · 1.31 KB
/
bsgenome.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ rWrapper, rPackages, ref, writeText, runCommand }:
let
r = rWrapper.override {
packages = with rPackages; [ BSgenome ];
};
forgeBSgenome = ref:
let
script = writeText "forgeBSgenome.r" ''
library("BSgenome")
forgeBSgenomeDataPkg("${seed}", "${splitRef}", getwd())
'';
in
runCommand "forgeBSgenome" { nativeBuildInputs = [ r ]; } ''
Rscript ${script}
cp -r BSgenome.vivax $out
'';
seed = writeText "seed.txt" ''
Package: BSgenome.vivax
Title: Plasmodium vivax
Description: Plasmodium vivax
Version: 0.1
Author: John Smith
Maintainer: John Smith <john@smith.com>
License: public domain
organism: Plasmodium vivax P01
common_name: P. vivax
provider: PlasmoDB
genome: PvivaxP01
release_date: 1970-01-01
organism_biocview: Plasmodium_vivax_P01
BSgenomeObjname: PvivaxP01
source_url: ${builtins.head ref.urls}
circ_seqs: character(0)
seqs_srcdir: ${splitRef}/
seqfiles_suffix:
seqnames: dir("${splitRef}")
'';
splitRef = runCommand "splitFA" { } ''
mkdir $out
cd $out
awk '/^>/{output=substr($1,2,length($1)-1)}{print > output}' ${ref}
'';
in
rPackages.buildRPackage {
name = "BSGenome.Vivax";
src = forgeBSgenome ref;
propagatedBuildInputs = with rPackages; [ BSgenome ];
}