higlass / higlass/clodius

Ability to support file-like objects in `clodius.tiles`

Open
#142 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
39
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Tracking whether file-like objects could be supported by the different tiles implementations.

🟩 = yes, 🟨 = unknown, πŸŸ₯ = no

#### 🟨 [`bam.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/bam.py)

Depends on [`pysam.AlignmentFile`](https://pysam.readthedocs.io/en/latest/api.html#pysam.AlignmentFile) which allows a file-like object for the reference but not the index.

```python
import pysam

# internal support for remote files http://www.htslib.org/doc/samtools.html#DESCRIPTION
# We could use this, but would need to cache instances (like tiles/clodius) to avoid
# re-initializing for each call to `tiles()`
pysam.AlignmentFile('http://localhost:8080/data.bam##idx##s3://path/to/data.bai')

with open('./data.bam') as f:
pysam.AlignmentFile(f) # works

with open('./data.bam') as f, open('./data.bai') as idx:
pysam.AlignmentFile(f, index_filename=idx) # error, can't pass file-like object for index!

with fsspec.open('http://localhost:8080/data.bam') as f:
pysam.AlignmentFile(f) # not recognized as a file-like object
```

#### πŸŸ₯ [`bed2ddb.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/bed2ddb.py)

Depends on [`sqllite3.connect`](https://docs.python.org/3/library/sqlite3.html#sqlite3.connect) which only accepts a string.

#### πŸŸ₯ [`bedarcsdb.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/bedarcsdb.py)

Depends on [`sqllite3.connect`](https://docs.python.org/3/library/sqlite3.html#sqlite3.connect) which only accepts a string.

#### πŸŸ₯ [`beddb.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/beddb.py)

Depends on [`sqllite3.connect`](https://docs.python.org/3/library/sqlite3.html#sqlite3.connect) which only accepts a string.

#### 🟩 [`bedfile.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/bedfile.py)

Currently a no-op.

#### 🟨 [`bigbed.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/bigbed.py)

Depends on `tiles/bigwig.py`.

#### 🟨 [`bigwig.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/bigwig.py)

Depends on whether [`pybbi`](https://github.com/nvictus/pybbi) could accept file-like objects.

#### 🟩 [`chromsizes.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/chromsizes.py)

Just reading a csv using builtin `open`.

#### 🟩 [`cooler.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/cooler.py)

Depends on `h5py` which [allows file-like objects](https://docs.h5py.org/en/stable/high/file.html#python-file-like-objects)

#### 🟩 [`density.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/density.py)

Depends on `h5py` which [allows file-like objects](https://docs.h5py.org/en/stable/high/file.html#python-file-like-objects)

#### 🟩/🟨 [`fasta.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/fasta.py)

Depends on [`pyfaidx.Fasta`](https://github.com/mdshw5/pyfaidx) supports only filenames. Some effort [here](https://github.com/mdshw5/pyfaidx/pull/168) that could be abstracted further.

#### πŸŸ₯ [`geo.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/geo.py)

Depends on [`sqllite3.connect`](https://docs.python.org/3/library/sqlite3.html#sqlite3.connect) which only accepts a string.

#### 🟩 [`hitile.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/hitile.py)

Depends on `h5py` which [allows file-like objects](https://docs.h5py.org/en/stable/high/file.html#python-file-like-objects)

#### πŸŸ₯ [`imtiles.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/imtiles.py)

Depends on [`sqllite3.connect`](https://docs.python.org/3/library/sqlite3.html#sqlite3.connect) which only accepts a string.

#### 🟩 [`mrmatrix.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/mrmatrix.py)

Depends on `h5py` which [allows file-like objects](https://docs.h5py.org/en/stable/high/file.html#python-file-like-objects)

#### 🟩 [`multivec.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/multivec.py)

Depends on `h5py` which [allows file-like objects](https://docs.h5py.org/en/stable/high/file.html#python-file-like-objects)

#### 🟩 [`tabix.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/tabix.py)

Uses builtin `open` and `gzip.open` which can be replaced with `f.open` and `gzip.open(f)` if filehandles are provided.

#### 🟩 [`time_interval.py`](https://github.com/higlass/clodius/blob/develop/clodius/tiles/time_interval.py)

Uses builtin `open` with can be replaced with `fh.open` if file-like object is provided.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.