Skip to content

Instantly share code, notes, and snippets.

View althonos's full-sized avatar
🧬
Writing Cython bindings to every single bioinformatics tool out there

Martin Larralde althonos

🧬
Writing Cython bindings to every single bioinformatics tool out there
View GitHub Profile
@althonos
althonos / example.py
Created May 16, 2024 16:02
A decorator for delaying the import of a module in Python.
from imports import imports
@imports("torch.cuda")
def is_cuda_available():
return torch.cuda.is_available()
@althonos
althonos / select_fisher.py
Created January 9, 2023 22:38
An `sklearn` implementation of a feature selection procedure using p-value thresholds for each feature.
import sklearn
import fisher
class SelectPValueUnderThreshold(sklearn.base.TransformerMixin):
"""Select features with Fisher p-value under a certain threshold.
"""
def __init__(self, threshold=1.0):
self.threshold = threshold
self.features_ = None
@althonos
althonos / mtbls_dump.py
Created August 2, 2018 09:55
MTBLS dump script through FTP
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import io
import ftplib
import posixpath
ftp = ftplib.FTP("ftp.ebi.ac.uk")
@althonos
althonos / setup.cfg
Last active March 4, 2024 18:08
A `setup.cfg` template for my Python projects
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = file: {name}/_version.txt
author = Martin Larralde
author_email = [email protected]
url = https://github.com/althonos/{name}
description = {description}
long_description = file: README.md
@althonos
althonos / doctest_autoload.py
Last active September 8, 2023 09:29
Unittest Doctest autoloader: add doctests automatically to the unittest test suites in the tests folder, allowing unit test runners to directly load the doctests.
# coding: utf-8
"""Test doctest contained tests in every file of the module.
"""
import configparser
import doctest
import importlib
import json
import gzip
import os