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

Ability to support file-like objects in clodius.tiles #142

Open
manzt opened this issue Feb 7, 2022 · 1 comment
Open

Ability to support file-like objects in clodius.tiles #142

manzt opened this issue Feb 7, 2022 · 1 comment

Comments

@manzt
Copy link
Member

manzt commented Feb 7, 2022

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

🟩 = yes, 🟨 = unknown, 🟥 = no

🟨 bam.py

Depends on pysam.AlignmentFile which allows a file-like object for the reference but not the index.

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

Depends on sqllite3.connect which only accepts a string.

🟥 bedarcsdb.py

Depends on sqllite3.connect which only accepts a string.

🟥 beddb.py

Depends on sqllite3.connect which only accepts a string.

🟩 bedfile.py

Currently a no-op.

🟨 bigbed.py

Depends on tiles/bigwig.py.

🟨 bigwig.py

Depends on whether pybbi could accept file-like objects.

🟩 chromsizes.py

Just reading a csv using builtin open.

🟩 cooler.py

Depends on h5py which allows file-like objects

🟩 density.py

Depends on h5py which allows file-like objects

🟩/🟨 fasta.py

Depends on pyfaidx.Fasta supports only filenames. Some effort here that could be abstracted further.

🟥 geo.py

Depends on sqllite3.connect which only accepts a string.

🟩 hitile.py

Depends on h5py which allows file-like objects

🟥 imtiles.py

Depends on sqllite3.connect which only accepts a string.

🟩 mrmatrix.py

Depends on h5py which allows file-like objects

🟩 multivec.py

Depends on h5py which allows file-like objects

🟩 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

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

@manzt
Copy link
Member Author

manzt commented Feb 7, 2022

context: manzt/hg#6

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

No branches or pull requests

1 participant