Skip to content

Instantly share code, notes, and snippets.

View ivan-krukov's full-sized avatar
🗃️
Getting there

Ivan Krukov ivan-krukov

🗃️
Getting there
View GitHub Profile
@ivan-krukov
ivan-krukov / README.md
Last active April 27, 2016 21:53
Get ENSEMBL IDs for a given KEGG pathway

Problem

For a given KEGG pathway, we want to get a list of all the genes. Ensembl IDs are convenient here.

KEGG provides a REST API for some tasks, but is far from complete. For example, it is possible to map from KEGG to NCBI IDs, but not to Ensembl IDs.

The implementation peforms the following steps:

@ivan-krukov
ivan-krukov / jupyter-imshow.py
Last active March 22, 2021 10:05
Show opencv image in ipython notebook
import cv2
import urllib.request
# Will use matplotlib for showing the image
from matplotlib import pyplot as plt
# Plot inline
%matplotlib inline
# For local images, read as usual
@ivan-krukov
ivan-krukov / multinomial.cpp
Created April 21, 2016 15:11
Generating multinomial random variates via the binomial conditional method
#include <vector>
#include <numeric>
#include <random>
using namespace std;
template <typename T>
T sum(vector<T> v) {
return accumulate(v.begin(), v.end(), 0.0);
}
@ivan-krukov
ivan-krukov / print_vector.cpp
Created April 19, 2016 21:56
Print vectors in C++, easy as `cout << vector << endl`
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << "[";
typename vector<T>::const_iterator it;
for (it = v.begin(); it != v.end() - 1; ++it) {
os << *it << ", ";
}
os << *(it) << "]";
return os;
}
@ivan-krukov
ivan-krukov / R_ify.R
Created March 30, 2016 16:18
Use dots instead of dollar signs in R
# Use dots (.) instead of ($)
R_ify <- function(expr) eval(parse(text=
gsub("\\.","$",substitute(expr))))
R_ify(mtcars.mpg)
@ivan-krukov
ivan-krukov / clone_all.sh
Last active March 17, 2016 03:34
Clone all repos for a given user
#Get repo list, filter git urls
GITHUB_NAME=octocat
curl https://api.github.com/users/$GITHUB_NAME/repos > github_response
for repo in `cat github_response | jq -r '.[] | .git_url'`; do;
git clone $repo;
done
@ivan-krukov
ivan-krukov / hello.fa
Created August 24, 2015 21:50
Multiple file suffixes in makefile rules
>sequence 1
ACTG
@ivan-krukov
ivan-krukov / README.md
Last active August 29, 2015 14:18
Shuffle and relabel observations in a csv file

#Randomization script

The idea is to do bootstrap resampling on the control dataset to make sure it is appropriate as a control dataset.

#Usage

python randomize.py <input.csv> <resample_times>
@ivan-krukov
ivan-krukov / README.md
Last active March 6, 2021 03:49
My favourite keymap

#Custom Keymap (Lenovo T430)

This will apply settings for both system console and Xorg server.

  • CapsLock will become an extra Esc
  • Home will be switched with PageUp
  • End will be switched with PageDown

This makes sense for the Lenovo T430, where PageUp and PageDown are right next to the arrow keys.

@ivan-krukov
ivan-krukov / README.md
Last active August 29, 2015 14:17
Chords

#20 chords A simple chord diagram for amino-acid relationships ##Usage

The input data should be a 20x20 table with tabs as separators.

To run the thing, do this (uses firefox)

git clone https://gist.github.com/ivan-kryukov/c265c9df6bfeda28abc8