at 22.05-pre 3.8 kB view raw
1{ lib 2, buildPythonPackage 3, fetchFromGitHub 4, bzip2 5, bcftools 6, curl 7, cython 8, htslib 9, libdeflate 10, xz 11, pytest 12, samtools 13, zlib 14}: 15 16buildPythonPackage rec { 17 pname = "pysam"; 18 version = "0.17.0"; 19 20 # Fetching from GitHub instead of PyPi cause the 0.13 src release on PyPi is 21 # missing some files which cause test failures. 22 # Tracked at: https://github.com/pysam-developers/pysam/issues/616 23 src = fetchFromGitHub { 24 owner = "pysam-developers"; 25 repo = "pysam"; 26 rev = "v${version}"; 27 sha256 = "sha256-RDeBq6pwBGCBNIn8YOPQr96GuL6FKEYeLAPQD6XN0iE="; 28 }; 29 30 nativeBuildInputs = [ samtools ]; 31 buildInputs = [ 32 bzip2 33 curl 34 cython 35 libdeflate 36 xz 37 zlib 38 ]; 39 40 # Use nixpkgs' htslib instead of the bundled one 41 # See https://pysam.readthedocs.io/en/latest/installation.html#external 42 # NOTE that htslib should be version compatible with pysam 43 preBuild = '' 44 export HTSLIB_MODE=shared 45 export HTSLIB_LIBRARY_DIR=${htslib}/lib 46 export HTSLIB_INCLUDE_DIR=${htslib}/include 47 ''; 48 49 checkInputs = [ 50 pytest 51 bcftools 52 htslib 53 ]; 54 55 # See https://github.com/NixOS/nixpkgs/pull/100823 for why we aren't using 56 # disabledTests and pytestFlagsArray through pytestCheckHook 57 checkPhase = '' 58 # Needed to avoid /homeless-shelter error 59 export HOME=$(mktemp -d) 60 61 # To avoid API incompatibilities, these should ideally show the same version 62 echo "> samtools --version" 63 samtools --version 64 echo "> htsfile --version" 65 htsfile --version 66 echo "> bcftools --version" 67 bcftools --version 68 69 # Create auxiliary test data 70 make -C tests/pysam_data 71 make -C tests/cbcf_data 72 73 # Delete pysam folder in current directory to avoid importing it during testing 74 rm -rf pysam 75 76 # Deselect tests that are known to fail due to upstream issues 77 # See https://github.com/pysam-developers/pysam/issues/961 78 py.test \ 79 --deselect tests/AlignmentFileHeader_test.py::TestHeaderBAM::test_dictionary_access_works \ 80 --deselect tests/AlignmentFileHeader_test.py::TestHeaderBAM::test_header_content_is_as_expected \ 81 --deselect tests/AlignmentFileHeader_test.py::TestHeaderCRAM::test_dictionary_access_works \ 82 --deselect tests/AlignmentFileHeader_test.py::TestHeaderCRAM::test_header_content_is_as_expected \ 83 --deselect tests/AlignmentFile_test.py::TestDeNovoConstruction::testBAMWholeFile \ 84 --deselect tests/AlignmentFile_test.py::TestEmptyHeader::testEmptyHeader \ 85 --deselect tests/AlignmentFile_test.py::TestHeaderWithProgramOptions::testHeader \ 86 --deselect tests/AlignmentFile_test.py::TestIO::testBAM2BAM \ 87 --deselect tests/AlignmentFile_test.py::TestIO::testBAM2CRAM \ 88 --deselect tests/AlignmentFile_test.py::TestIO::testBAM2SAM \ 89 --deselect tests/AlignmentFile_test.py::TestIO::testFetchFromClosedFileObject \ 90 --deselect tests/AlignmentFile_test.py::TestIO::testOpenFromFilename \ 91 --deselect tests/AlignmentFile_test.py::TestIO::testSAM2BAM \ 92 --deselect tests/AlignmentFile_test.py::TestIO::testWriteUncompressedBAMFile \ 93 --deselect tests/AlignmentFile_test.py::TestIteratorRowAllBAM::testIterate \ 94 --deselect tests/StreamFiledescriptors_test.py::StreamTest::test_text_processing \ 95 --deselect tests/compile_test.py::BAMTest::testCount \ 96 tests/ 97 ''; 98 99 pythonImportsCheck = [ 100 "pysam" 101 "pysam.bcftools" 102 "pysam.libchtslib" 103 "pysam.libcutils" 104 "pysam.libcvcf" 105 ]; 106 107 meta = with lib; { 108 description = "A python module for reading, manipulating and writing genome data sets"; 109 homepage = "https://pysam.readthedocs.io/"; 110 maintainers = with maintainers; [ unode ]; 111 license = licenses.mit; 112 platforms = [ "i686-linux" "x86_64-linux" ]; 113 }; 114}