summary refs log tree commit diff
path: root/pkgs/applications/science/biology/truvari/default.nix
blob: e626af56278faeebf3dca95d0a4d83d07b1c2017 (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ lib
, fetchFromGitHub
, fetchpatch
, python3Packages
, runtimeShell
, bcftools
, htslib
}:

let
  ssshtest = fetchFromGitHub {
    owner = "ryanlayer";
    repo = "ssshtest";
    rev = "d21f7f928a167fca6e2eb31616673444d15e6fd0";
    hash = "sha256-zecZHEnfhDtT44VMbHLHOhRtNsIMWeaBASupVXtmrks=";
  };
in python3Packages.buildPythonApplication rec {
  pname = "truvari";
  version = "4.0.0";

  src = fetchFromGitHub {
    owner = "ACEnglish";
    repo = "truvari";
    rev = "v${version}";
    hash = "sha256-UJNMKEV5m2jFqnWvkVAtymkcE2TjPIXp7JqRZpMSqsE=";
  };

  patches = [
    (fetchpatch {
      name = "fix-anno-trf-on-darwin.patch";
      url = "https://github.com/ACEnglish/truvari/commit/f9f36305e8eaa88f951562210e3672a4d4f71265.patch";
      hash = "sha256-7O9jTQDCC2b8hUBm0qJQCYMzTC9NFtn/E0dTHSfJALU=";
    })
    (fetchpatch {
      name = "fix-anno-grm-on-darwin.patch";
      url = "https://github.com/ACEnglish/truvari/commit/31416552008a506204ed4e2add55474f10392357.patch";
      hash = "sha256-42u0ewZU38GCoSfff+XQFv9hEFeO3WlJufTHcl6vkN4=";
    })
  ];

  postPatch = ''
    substituteInPlace setup.py \
      --replace "rich==" "rich>="
    substituteInPlace truvari/utils.py \
      --replace "/bin/bash" "${runtimeShell}"
    patchShebangs repo_utils/test_files
  '';

  propagatedBuildInputs = with python3Packages; [
    rich
    edlib
    pysam
    intervaltree
    joblib
    numpy
    pytabix
    bwapy
    pandas
  ];

  makeWrapperArgs = [
    "--prefix" "PATH" ":" (lib.makeBinPath [ bcftools htslib ])
  ];

  pythonImportsCheck = [ "truvari" ];

  nativeCheckInputs = [
    bcftools
    htslib
  ] ++ (with python3Packages; [
    coverage
  ]);

  checkPhase = ''
    runHook preCheck

    ln -s ${ssshtest}/ssshtest .
    bash repo_utils/truvari_ssshtests.sh

    runHook postCheck
  '';

  meta = with lib; {
    description = "Structural variant comparison tool for VCFs";
    homepage = "https://github.com/ACEnglish/truvari";
    license = licenses.mit;
    maintainers = with maintainers; [ natsukium scalavision ];
    longDescription = ''
      Truvari is a benchmarking tool for comparison sets of SVs.
      It can calculate the recall, precision, and f-measure of a
      vcf from a given structural variant caller. The tool
      is created by Spiral Genetics.
    '';
  };
}