Skip to content

Instantly share code, notes, and snippets.

@golobor
golobor / h5cp.py
Created December 12, 2023 12:51
h5cp
import h5py
import argparse
def copy_dataset(source_file, destination_file, source_dataset, destination_dataset, overwrite):
with h5py.File(source_file, 'r') as source:
with h5py.File(destination_file, 'a') as destination:
if source_dataset not in source:
print(f"Dataset '{source_dataset}' does not exist in the source file.")
return
from contextlib import contextmanager
import functools
import numpy as np
import gsd
import gsd.hoomd
import hoomd
import hoomd.md
@golobor
golobor / 230306-symmetrize-stack.ipynb
Last active March 6, 2023 20:32
230306-symmetrize-stack
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@golobor
golobor / dotdict
Last active January 29, 2023 16:42
A simple wrapper to enable dot autocompletion of Python dictionaries
class dotdict(dict):
'''A dict with dot access and autocompletion.
The idea and most of the code was taken from
http://stackoverflow.com/a/23689767,
http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
http://stackoverflow.com/questions/2390827/how-to-properly-subclass-dict-and-override-get-set
'''
def __init__(self,*a,**kw):
@golobor
golobor / hela-pairing.ipynb
Created October 14, 2022 15:18
region-wide-P(s)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@golobor
golobor / centromere_downloader.ipynb
Last active October 29, 2020 07:49
centromere_downloaded
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@golobor
golobor / bottle-brush-scaling-theory.ipynb
Created June 22, 2020 20:26
Bottle Brush P(s) theory for Gibcus et at 2018
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# from https://stackoverflow.com/questions/22712292/how-to-use-numpy-savez-in-a-loop-for-save-more-than-one-array/22716159#22716159
import numpy as np
import tempfile
class my_savez(object):
def __init__(self, file, compression=None, compresslevel=None):
# Import is postponed to here since zipfile depends on gzip, an optional
# component of the so-called standard library.
import zipfile
@golobor
golobor / yeast_cohesin_project_fig6.ipynb
Created December 14, 2018 06:09
Yeast dCohesin Hi-C, fig6
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@golobor
golobor / w303.centromeres.tsv
Last active December 14, 2018 05:50
Yeast cohesin supplemental files (w303 genome)
chrom start end
chrVII 496916 497034
chrVI 148509 148626
chrV 151987 152104
chrIV 449712 449822
chrIII 114385 114501
chrII 238206 238322
chrI 151465 151582
chrIX 355629 355745
chrVIII 105591 105708