forked from jbedo/malaria-variant-calling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
56 lines (49 loc) · 1.47 KB
/
default.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
56
{ bionix ? import <bionix> { }
, small ? false
, chunkSize ? 100
}:
with bionix;
with lib;
with types;
let
ref = fetchFastA {
url = "https://plasmodb.org/common/downloads/release-54/PvivaxP01/fasta/data/PlasmoDB-54_PvivaxP01_Genome.fasta";
sha256 = "sha256-1ZahI54i1iZ3kvJGzEz00Gv3l9BgzHL+1gJ1I+1wA3k=";
};
PMIX = "PvP01_13_v2:876959-881753";
PMX = "PvP01_01_v2:555499-559411";
ena = pkgs.callPackage ./ena.nix { inherit fetchFastQGZ; };
samples' = ena.importFromJSON ./PRJEB2140.json;
samples = if small then takeAttrs 1 samples' else samples';
takeAttrs = n: xs: listToAttrs (zipListsWith nameValuePair (take n (attrNames xs)) (attrValues xs));
QDNAseq = callBionix ./QDNAseq.nix { inherit ref; targets = [ PMIX PMX ]; };
preprocess = id: flip pipe [
(bwa.align { inherit ref; RG = { ID = id; SM = id; }; })
(samtools.sort { })
];
chunkFold1 = n: f: xs:
if length xs <= n then
f xs
else
chunkFold1 n f (chunkFold1' n f xs);
chunkFold1' = n: f: xs:
if length xs <= n then
xs
else
[ (f (take n xs)) ] ++ chunkFold1' n f (drop n xs);
in
linkOutputs {
cnv = mapAttrs'
(name: flip pipe [
(preprocess name)
(QDNAseq.call { inherit name; })
(nameValuePair "${name}.rds")
])
samples;
"variants.vcf.gz" = pipe samples [
(mapAttrsToList preprocess)
(map (gatk.callHaplotype { targets = [ PMIX PMX ]; }))
(chunkFold1 chunkSize (gatk.merge { }))
(gatk.callGenotypes { })
];
}