Skip to content

Instantly share code, notes, and snippets.

View krassowski's full-sized avatar

Michał Krassowski krassowski

View GitHub Profile
@krassowski
krassowski / 2016_GSoC_Final_Evaluation.md
Created August 23, 2016 03:54
GSoC Final Evaluation 2016 for project "Interactive visualisation framework for genome mutations in gene and protein networks"

Work Product

Code written for project is available in repository on github: /reimandlab/Visualisation-Framework-for-Genome-Mutations.

For the day of writing evaluation I am the only author of code availalbe in the repository; as there might be other contributors in future: all commits prior to Aug 24, 2016 available here: /reimandlab/Visualisation-Framework-for-Genome-Mutations/commits/master?author=krassowski are my GSoC 2016 commits.

Collecting data was not the part of my work during GSoC 2016 - the data for application was provided by my Mentor and hence I mark explicitly that the content of the website/data directory is not part of my GSoC work (moreover it is not even code).

Deployment & reuse

@krassowski
krassowski / first-test.sh
Created October 4, 2016 09:35
Bash shell answers for "Molecular modelling and computational biology 1"
# 1. Create a directory with your name on your desktop
mkdir ~/Desktop/Michal
# 2. Download a directory XYZ located in /home/login/somedir from login@host to your created directory
cd ~/Desktop/Michal
scp -r login@host:~/somedir/XYZ . # often you can skip '~/' after the colon - remote directories defaults to user's home
# 3. Merge files a.pdb with b.pdb, in this order, and save the result to c.pdb
cd XYZ
cat a.pdb b.pdb > c.pdb
# 4. Replace 'X' occurrences in lines 100-200 with 'Y' in the c.pdb file
sed -ie '100,200s/X/Y/g' c.pdb # the simplest way
@krassowski
krassowski / bcd.py
Created April 4, 2017 13:55
BCD implementation
"""
A partial, lazy implementation of BCD (http://genomebiology.biomedcentral.com/articles/10.1186/gb-2007-8-12-r271)
BiBS, Systems Biology workshops 2017
"""
from math import sqrt
from networkx import Graph, number_of_nodes, connected_component_subgraphs
from networkx.algorithms import edge_betweenness_centrality
def test_graph():
#ifndef FORCEFIELD_HPP
#define FORCEFIELD_HPP
#include "vector.hpp"
#include "atom.hpp"
#include "system.hpp"
// I moved all code to one file for gist easier sharing ;)
// change to potential energy??
class ForceField {
@krassowski
krassowski / autocompletion.py
Last active March 17, 2019 03:00
R (rpy2) autocompletion in Jupyter for IPython
from rpy2.robjects import r
from IPython import get_ipython
def rpy2_completer(ipython, event):
query = event.line.strip().split()[-1]
suggestions = []
all_r_symbols = r('sapply(search(), ls)')
for environment, symbols in all_r_symbols.items():
for _, symbol in symbols.items():
if symbol.startswith(query):
@krassowski
krassowski / beeper.py
Created March 17, 2019 03:20
Beep after long code cell execution in Jupyter Python
from time import time
from IPython import get_ipython
from IPython.display import Audio, display
class Beeper:
def __init__(self, threshold, **audio_kwargs):
self.threshold = threshold
self.start_time = None # time in sec, or None
self.audio = audio_kwargs
@krassowski
krassowski / play_sound_on_exception.py
Created March 17, 2019 17:04
Play sound on exception - IPython
# CC-BY-SA 4.0 Kevin (https://stackoverflow.com/a/41603739/6646912)
# https://creativecommons.org/licenses/by-sa/4.0/
from IPython.display import Audio, display
def play_sound(self, etype, value, tb, tb_offset=None):
self.showtraceback((etype, value, tb), tb_offset=tb_offset)
display(Audio(url='http://www.wav-sounds.com/movie/austinpowers.wav', autoplay=True))
get_ipython().set_custom_exc((ZeroDivisionError,), play_sound)
@krassowski
krassowski / Benchmark.ipynb
Created January 22, 2019 23:20
Performance and peak-memory evaluation of some explode implementations, see https://stackoverflow.com/q/12680754
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@krassowski
krassowski / loadings_similarity_simple.py
Created March 22, 2020 11:58
Loadings similarity method - a simplified version
from pandas import DataFrame
from sklearn.pipeline import Pipeline
from sklearn.base import clone
from sklearn.model_selection import KFold
from scipy.stats import pearsonr
from numpy import Inf
def loadings_similarity_simple(
pipeline: Pipeline, data,