pairtools icon indicating copy to clipboard operation
pairtools copied to clipboard

Warning when running with pysam 0.23.1 leading to non-zero exit code

Open prototaxites opened this issue 5 months ago • 3 comments
trafficstars

I encounter the following warning when running pairtools with pysam 0.23.1:

> conda create -n pairtools pairtools

...
The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    biopython-1.85             |  py312h66e93f0_1         3.3 MB  conda-forge
    brotli-python-1.1.0        |  py312h2ec8cdc_2         342 KB  conda-forge
    cffi-1.17.1                |  py312h06ac9bb_0         288 KB  conda-forge
    contourpy-1.3.2            |  py312h68727a3_0         270 KB  conda-forge
    cytoolz-1.0.1              |  py312h66e93f0_0         385 KB  conda-forge
    fonttools-4.58.1           |  py312h178313f_0         2.7 MB  conda-forge
    kiwisolver-1.4.8           |  py312h84d6215_0          70 KB  conda-forge
    matplotlib-base-3.10.3     |  py312hd3ec401_0         7.8 MB  conda-forge
    numpy-1.26.4               |  py312heda63a1_0         7.1 MB  conda-forge
    pairix-0.3.9               |  py312h4711d71_0         101 KB  bioconda
    pairtools-1.1.3            |  py312h5219090_0         357 KB  bioconda
    pandas-2.2.3               |  py312hf9745cd_3        14.7 MB  conda-forge
    pillow-11.2.1              |  py312h80c1187_0        40.5 MB  conda-forge
    pysam-0.23.1               |  py312h47d5410_0         4.6 MB  bioconda
    python-3.12.10             |h9e4cc4f_0_cpython        29.8 MB  conda-forge
    python_abi-3.12            |          7_cp312           7 KB  conda-forge
    pyyaml-6.0.2               |  py312h178313f_2         202 KB  conda-forge
    scipy-1.15.2               |  py312ha707e6e_0        16.3 MB  conda-forge
    unicodedata2-16.0.0        |  py312h66e93f0_0         395 KB  conda-forge
    zstandard-0.23.0           |  py312h66e93f0_2         715 KB  conda-forge
    ------------------------------------------------------------
                                           Total:       130.0 MB
...

> conda activate pairtools
> pairtools
<frozen importlib._bootstrap>:228: RuntimeWarning: pysam.libcalignedsegment.AlignedSegment size changed, may indicate binary incompatibility. Expected 72 from C header, got 88 from PyObject                                             
Usage: pairtools [OPTIONS] COMMAND [ARGS]...                                                                         
                                                                                                                     
  Flexible tools for Hi-C data processing.                                                                           
                                                                                                                     
  All pairtools have a few common options, which should be typed _before_ the                                        
  command name.                                                                                                      
                                                                                                                     
Options:                                                                                                             
  --post-mortem          Post mortem debugging                                                                       
  --output-profile TEXT  Profile performance with Python cProfile and dump the
                         statistics into a binary file
  -v, --verbose          Verbose logging.
  -d, --debug            On error, drop into the post-mortem debugger shell.
  --version              Show the version and exit.
  -h, --help             Show this message and exit.

Commands:
  dedup        Find and remove PCR/optical duplicates.
  filterbycov  Remove pairs from regions of high coverage.
  flip         Flip pairs to get an upper-triangular matrix.
  header       Manipulate the .pairs/.pairsam header
  markasdup    Tag all pairs in the input file as duplicates.
  merge        Merge .pairs/.pairsam files.
  parse        Find ligation pairs in .sam data, make .pairs.
  parse2       Extracts pairs from .sam/.bam data with complex walks,...
  phase        Phase pairs mapped to a diploid genome.
  restrict     Assign restriction fragments to pairs.
  sample       Select a random subset of pairs in a pairs file.
  scaling      Calculate pairs scalings.
  select       Select pairs according to some condition.
  sort         Sort a .pairs/.pairsam file.
  split        Split a .pairsam file into .pairs and .sam.
  stats        Calculate pairs statistics.

This exits with exit code 2.

Manually downgrading to pysam 0.23.0 fixes the issue and pairtools runs as expected.

prototaxites avatar May 30 '25 12:05 prototaxites

Pysam has inadvertently created a binary compatibility problem. Most packages using pysam are pure Python themselves, so concerns like this are immaterial. However some, like pairtools, are Cython projects and should be able to assume some binary compatibility guarantees from pysam.

The pysam maintainers will make a 0.23.2 release soon that fixes this issue.

jmarshall avatar Jun 05 '25 13:06 jmarshall

@jmarshall That's great to hear!

nvictus avatar Jun 05 '25 13:06 nvictus

Pysam 0.23.2 has now been released and removes this warning.

(pairtools with no arguments exits with status 2 regardless. pairtools --help would exit with status 0.)

jmarshall avatar Jun 06 '25 10:06 jmarshall