Skip to content

Instantly share code, notes, and snippets.

View dansondergaard's full-sized avatar

Dan Søndergaard dansondergaard

View GitHub Profile
In [4]: %timeit int(1001) in range(1000)
558 ns ± 6.22 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
In [5]: %timeit int(100001) in range(100000)
567 ns ± 14.1 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
In [6]: %timeit int(10000001) in range(10000000)
561 ns ± 8.6 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
In [7]: %timeit int(1000000001) in range(1000000000)
"""Example of adding attributes to a function using a decorator."""
import time
def delayable(func):
def _delayer(delay, *args, **kwargs):
time.sleep(delay)
return func(*args, **kwargs)
setattr(func, 'delay', _delayer)
from itertools import zip_longest
def remove_consecutive(lst, item=0):
"""Remove consecutive occurrences of `item` from `lst`.
For example:
>>> print(list(remove_consecutive([1, 1, 0, 0, 0, 1, 0, 1, 1], item=0)))
[1, 1, 0, 1, 0, 1, 1]
"""Converting fasta files to data frames and back again."""
import pandas as pd
import skbio as sk
def fasta_to_dataframe(path, id_col='id', description_col='description', sequence_col='sequence'):
"""Read a FASTA file into a pandas data frame.
This function is the inverse of :func:`dataframe_to_fasta`.
@dansondergaard
dansondergaard / expand.py
Created May 11, 2017 05:42
Bash-like string expansion in Python.
"""Bash-like string expansion in Python.
Author: Dan Søndergaard <[email protected]>
License: MIT
"""
import re
from itertools import product
GROUP_RE = re.compile(r'\{.+?\}')
#!/bin/bash
#
# Short description of what this script does...
#
# This is a bash script template based on the recommendations
# from Julia Evans' excellent blog post about bash quirks and
# how to avoid them:
#
# https://jvns.ca/blog/2017/03/26/bash-quirks/
#
accessibility: []
additionDate: '2015-12-17T14:23:00Z'
availability: null
canonicalID: null
collectionID:
- CBS
contact:
- email: [email protected]
name: Henrik Nielsen
tel: null
def prepend_line(line, rest):
return line + '\n' + rest
class Transformer:
def __call__(self, f):
def wrapper(*args, **kwargs):
options, spec = f(*args, **kwargs)
return self.transform(options, spec)
return wrapper
@dansondergaard
dansondergaard / biotools_packages.txt
Last active July 27, 2021 07:09
Package names from bio.tools and various conda channels (anaconda, conda-forge, bioconda, r).
KNIME - Cellular phenotyping
Galaxy Image Analysis
COMPSs
YEASTRACT
WormBase
Reactome knowledgebase of biological pathways
PRIDE
PANTHER
AnalysisServiceService
Kyoto encyclopedia of genes and genomes KEGG

CEDA Journal Club

Meetings

[Astrid Kousholt] TBA.

[2017/03/08] [Elham Bavafaye Haghighi] Bartsch GJ, Mitra AP, Mitra SA, et al. Use of Artificial Intelligence and Machine Learning Algorithms with Gene Expression Profiling to Predict Recurrent Nonmuscle Invasive Urothelial Carcinoma of the Bladder. J Urol. 2016;195(2):493-498. doi:10.1016/j.juro.2015.09.090.