2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, bzip2
|
|
|
|
, bcftools
|
|
|
|
, curl
|
|
|
|
, cython
|
|
|
|
, htslib
|
2020-10-20 17:27:49 +00:00
|
|
|
, libdeflate
|
2021-04-05 15:23:46 +00:00
|
|
|
, xz
|
2020-04-24 23:36:52 +00:00
|
|
|
, pytest
|
|
|
|
, samtools
|
|
|
|
, zlib
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pysam";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "0.19.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Fetching from GitHub instead of PyPi cause the 0.13 src release on PyPi is
|
|
|
|
# missing some files which cause test failures.
|
|
|
|
# Tracked at: https://github.com/pysam-developers/pysam/issues/616
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pysam-developers";
|
|
|
|
repo = "pysam";
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
sha256 = "sha256-fbvfobffLha1eFatnHvh0tOYcuMRLTmy/BJ9QXFHx2o=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ samtools ];
|
2020-10-20 17:27:49 +00:00
|
|
|
buildInputs = [
|
|
|
|
bzip2
|
|
|
|
curl
|
|
|
|
cython
|
|
|
|
libdeflate
|
2021-04-05 15:23:46 +00:00
|
|
|
xz
|
2020-10-20 17:27:49 +00:00
|
|
|
zlib
|
|
|
|
];
|
|
|
|
|
|
|
|
# Use nixpkgs' htslib instead of the bundled one
|
|
|
|
# See https://pysam.readthedocs.io/en/latest/installation.html#external
|
|
|
|
# NOTE that htslib should be version compatible with pysam
|
|
|
|
preBuild = ''
|
|
|
|
export HTSLIB_MODE=shared
|
|
|
|
export HTSLIB_LIBRARY_DIR=${htslib}/lib
|
|
|
|
export HTSLIB_INCLUDE_DIR=${htslib}/include
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-20 17:27:49 +00:00
|
|
|
checkInputs = [
|
|
|
|
pytest
|
|
|
|
bcftools
|
|
|
|
htslib
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-20 17:27:49 +00:00
|
|
|
# See https://github.com/NixOS/nixpkgs/pull/100823 for why we aren't using
|
|
|
|
# disabledTests and pytestFlagsArray through pytestCheckHook
|
|
|
|
checkPhase = ''
|
|
|
|
# Needed to avoid /homeless-shelter error
|
2020-04-24 23:36:52 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2020-10-20 17:27:49 +00:00
|
|
|
|
|
|
|
# To avoid API incompatibilities, these should ideally show the same version
|
|
|
|
echo "> samtools --version"
|
|
|
|
samtools --version
|
|
|
|
echo "> htsfile --version"
|
|
|
|
htsfile --version
|
|
|
|
echo "> bcftools --version"
|
|
|
|
bcftools --version
|
|
|
|
|
|
|
|
# Create auxiliary test data
|
2020-04-24 23:36:52 +00:00
|
|
|
make -C tests/pysam_data
|
|
|
|
make -C tests/cbcf_data
|
2020-10-20 17:27:49 +00:00
|
|
|
|
|
|
|
# Delete pysam folder in current directory to avoid importing it during testing
|
|
|
|
rm -rf pysam
|
|
|
|
|
|
|
|
# Deselect tests that are known to fail due to upstream issues
|
|
|
|
# See https://github.com/pysam-developers/pysam/issues/961
|
|
|
|
py.test \
|
|
|
|
--deselect tests/AlignmentFileHeader_test.py::TestHeaderBAM::test_dictionary_access_works \
|
|
|
|
--deselect tests/AlignmentFileHeader_test.py::TestHeaderBAM::test_header_content_is_as_expected \
|
|
|
|
--deselect tests/AlignmentFileHeader_test.py::TestHeaderCRAM::test_dictionary_access_works \
|
|
|
|
--deselect tests/AlignmentFileHeader_test.py::TestHeaderCRAM::test_header_content_is_as_expected \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestDeNovoConstruction::testBAMWholeFile \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestEmptyHeader::testEmptyHeader \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestHeaderWithProgramOptions::testHeader \
|
2020-11-03 02:18:15 +00:00
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testBAM2BAM \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testBAM2CRAM \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testBAM2SAM \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testFetchFromClosedFileObject \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testOpenFromFilename \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testSAM2BAM \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIO::testWriteUncompressedBAMFile \
|
|
|
|
--deselect tests/AlignmentFile_test.py::TestIteratorRowAllBAM::testIterate \
|
2020-10-20 17:27:49 +00:00
|
|
|
--deselect tests/StreamFiledescriptors_test.py::StreamTest::test_text_processing \
|
2020-11-03 02:18:15 +00:00
|
|
|
--deselect tests/compile_test.py::BAMTest::testCount \
|
2020-10-20 17:27:49 +00:00
|
|
|
tests/
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
pythonImportsCheck = [
|
|
|
|
"pysam"
|
|
|
|
"pysam.bcftools"
|
2020-10-20 17:27:49 +00:00
|
|
|
"pysam.libchtslib"
|
2020-04-24 23:36:52 +00:00
|
|
|
"pysam.libcutils"
|
|
|
|
"pysam.libcvcf"
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A python module for reading, manipulating and writing genome data sets";
|
|
|
|
homepage = "https://pysam.readthedocs.io/";
|
|
|
|
maintainers = with maintainers; [ unode ];
|
|
|
|
license = licenses.mit;
|
2022-09-30 11:47:45 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|