<commit_before>{ lib
, buildPythonPackage
, fetchFromGitHub
, bzip2
, bcftools
, curl
, cython
, htslib
, libdeflate
, xz
, pytest
, samtools
, zlib
}:

buildPythonPackage rec {
  pname   = "pysam";
  version = "0.16.0.1";

  # 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";
    rev = "v${version}";
    sha256 = "168bwwm8c2k22m7paip8q0yajyl7xdxgnik0bgjl7rhqg0majz0f";
  };

  nativeBuildInputs = [ samtools ];
  buildInputs = [
    bzip2
    curl
    cython
    libdeflate
    xz
    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
  '';

  checkInputs = [
    pytest
    bcftools
    htslib
  ];

  # 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
    export HOME=$(mktemp -d)

    # 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
    make -C tests/pysam_data
    make -C tests/cbcf_data

    # 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 \
      --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 \
      --deselect tests/StreamFiledescriptors_test.py::StreamTest::test_text_processing \
      --deselect tests/compile_test.py::BAMTest::testCount \
      tests/
  '';

  pythonImportsCheck = [
    "pysam"
    "pysam.bcftools"
    "pysam.libchtslib"
    "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;
    platforms = [ "i686-linux" "x86_64-linux" ];
  };
}
<commit_msg>pythonPackages.pysam: 0.16.0.1 -> 0.17.0<commit_after>{ lib
, buildPythonPackage
, fetchFromGitHub
, bzip2
, bcftools
, curl
, cython
, htslib
, libdeflate
, xz
, pytest
, samtools
, zlib
}:

buildPythonPackage rec {
  pname   = "pysam";
  version = "0.17.0";

  # 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";
    rev = "v${version}";
    sha256 = "sha256-RDeBq6pwBGCBNIn8YOPQr96GuL6FKEYeLAPQD6XN0iE=";
  };

  nativeBuildInputs = [ samtools ];
  buildInputs = [
    bzip2
    curl
    cython
    libdeflate
    xz
    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
  '';

  checkInputs = [
    pytest
    bcftools
    htslib
  ];

  # 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
    export HOME=$(mktemp -d)

    # 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
    make -C tests/pysam_data
    make -C tests/cbcf_data

    # 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 \
      --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 \
      --deselect tests/StreamFiledescriptors_test.py::StreamTest::test_text_processing \
      --deselect tests/compile_test.py::BAMTest::testCount \
      tests/
  '';

  pythonImportsCheck = [
    "pysam"
    "pysam.bcftools"
    "pysam.libchtslib"
    "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;
    platforms = [ "i686-linux" "x86_64-linux" ];
  };
}

{'fraction_non_alphanumeric': 0.10390973497769614, 'fraction_numerical': 0.013775911834164262, 'mean_word_length': 3.5186721991701244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2361455', 'n_tokens_mistral': 2657, 'n_tokens_neox': 2551, 'n_words': 494}