Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return error when bgzf_open fails to open a file #444

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

ghuls
Copy link
Contributor

@ghuls ghuls commented Oct 23, 2024

  • Before rust_htslib::bgzf:Reader and rust_htslib::bgzf:Writer would never fail when opening a file that could not be opened and it would allow writing to rust_htslib::bgzf:Writer without returning any error messages.

ghuls and others added 2 commits October 23, 2024 15:41
  * Before `rust_htslib::bgzf:Reader` and `rust_htslib::bgzf:Writer`
    would never fail when opening a file that could not be opened
    and it would allow writing to `rust_htslib::bgzf:Writer` without
    returning any error messages.
@johanneskoester johanneskoester self-assigned this Nov 12, 2024
@johanneskoester johanneskoester merged commit 9bda5f7 into rust-bio:master Nov 12, 2024
9 checks passed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11799735471

Details

  • 4 of 8 (50.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 79.661%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/bgzf/mod.rs 4 8 50.0%
Totals Coverage Status
Change from base Build 11799687230: -0.06%
Covered Lines: 2491
Relevant Lines: 3127

💛 - Coveralls

ghuls added a commit to aertslab/scatac_fragment_tools that referenced this pull request Nov 12, 2024
…files.

Trow error if `scatac_from_fragments split` can't write to fragments files,
by updating rust_htslib as both `rust_htslib::bgzf:Reader` and
`rust_htslib::bgzf:Writer` did not check if it could open a file successfully.

  rust-bio/rust-htslib#444

This now print a traceback instead of silently failing:

    Processing contig "chr1"
    thread '<unnamed>' panicked at src/split_fragments.rs:56:37:
    Could not open file "/tmp/sample1/cellA.fragments.tsv.gz" for writing
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    Traceback (most recent call last):
      File "/software/anaconda3/envs/pycistopic/bin/scatac_fragment_tools", line 8, in <module>
        sys.exit(main())
             ^^^^^^
      File "/software/scatac_fragment_tools/src/scatac_fragment_tools/cli/main.py", line 317, in main
        args.func(args)
      File "/software/scatac_fragment_tools/src/scatac_fragment_tools/cli/commands.py", line 186, in command_split_fragments_by_cell_type
        split_fragment_files_by_cell_type(
      File "/software/scatac_fragment_tools/src/scatac_fragment_tools/library/split/split_fragments_by_cell_type.py", line 79, in split_fragment_files_by_cell_type
        joblib.Parallel(n_jobs=n_cpu)(
      File "/software/anaconda3/envs/pycistopic/lib/python3.11/site-packages/joblib/parallel.py", line 1918, in __call__
        return output if self.return_generator else list(output)
                                                ^^^^^^^^^^^^
      File "/software/anaconda3/envs/pycistopic/lib/python3.11/site-packages/joblib/parallel.py", line 1847, in _get_sequential_output
        res = func(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^
    pyo3_runtime.PanicException: Could not open file "/tmp/sample1/cellA.fragments.tsv.gz" for writing
ghuls added a commit to aertslab/scatac_fragment_tools that referenced this pull request Nov 12, 2024
… files.

Throw error if `scatac_from_fragments split` can't write to fragments files,
by updating rust_htslib as both `rust_htslib::bgzf:Reader` and
`rust_htslib::bgzf:Writer` did not check if it could open a file successfully.

  rust-bio/rust-htslib#444

This now print a traceback instead of silently failing:

    Processing contig "chr1"
    thread '<unnamed>' panicked at src/split_fragments.rs:56:37:
    Could not open file "/tmp/sample1/cellA.fragments.tsv.gz" for writing
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    Traceback (most recent call last):
      File "/software/anaconda3/envs/pycistopic/bin/scatac_fragment_tools", line 8, in <module>
        sys.exit(main())
             ^^^^^^
      File "/software/scatac_fragment_tools/src/scatac_fragment_tools/cli/main.py", line 317, in main
        args.func(args)
      File "/software/scatac_fragment_tools/src/scatac_fragment_tools/cli/commands.py", line 186, in command_split_fragments_by_cell_type
        split_fragment_files_by_cell_type(
      File "/software/scatac_fragment_tools/src/scatac_fragment_tools/library/split/split_fragments_by_cell_type.py", line 79, in split_fragment_files_by_cell_type
        joblib.Parallel(n_jobs=n_cpu)(
      File "/software/anaconda3/envs/pycistopic/lib/python3.11/site-packages/joblib/parallel.py", line 1918, in __call__
        return output if self.return_generator else list(output)
                                                ^^^^^^^^^^^^
      File "/software/anaconda3/envs/pycistopic/lib/python3.11/site-packages/joblib/parallel.py", line 1847, in _get_sequential_output
        res = func(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^
    pyo3_runtime.PanicException: Could not open file "/tmp/sample1/cellA.fragments.tsv.gz" for writing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants