Skip to content

Instantly share code, notes, and snippets.

Ivan Krukov ivan-krukov

  • Canada
Block or report user

Report or block ivan-krukov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ivan-krukov / data.csv
Last active Aug 29, 2015
A simple kNN implementation
View data.csv
1 1 0
1 2 0
1 3 0
2 1 0
2 2 0
2 3 0
4 1 1
4 2 1
4 3 1
5 1 1

#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
ivan-krukov /
Last active Aug 29, 2015
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 /
Last active Aug 29, 2015
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.


python <input.csv> <resample_times>
ivan-krukov / hello.fa
Created Aug 24, 2015
Multiple file suffixes in makefile rules
View hello.fa
>sequence 1
ivan-krukov / volume
Created Aug 2, 2012
Change the OS X sound volume from the command line
View volume
! /usr/bin/osascript
on run argv
set Volume (item 1 of argv)
end run
import argparse
from Bio import SeqIO
parser.add_argument("inputFile", help="input fasta file")
parser.add_argument("outputFile",help="output file name")
parser.add_argument("sampleName",help="sample name to be removed")
args = parser.parse_args()
ivan-krukov /
Created Aug 9, 2012
Another quick FASTA parser
#Read a fasta file and only keep the sequences with correct headers (id_pattern regex)
import re
import sys
seq_pattern = re.compile(r">[^>]+\n",re.MULTILINE)
id_pattern = re.compile(r"protein_id:(?P<id>[.\w]+)")
with open(sys.argv[1]) as f:
text =
ivan-krukov /
Created Aug 17, 2012
This atrocious shell script prints the first 1/nth (half, third, etc) part of a file
#get the command line arguments
#run wc on the file in argv[1]
size=`wc -l $input_file`
#split the return on whitespace - first word is now in
set $size
#get the intiger division of wc/divisor
ivan-krukov /
Created Nov 10, 2012
A little output logging tool
echo "$cmd @ `pwd`; Started at `date`" > $pid.out
echo "[$pid] $cmd"
eval $cmd >> $pid.out 2>> $pid.err
echo "$cmd @ `pwd`; Finished at `date`" >> $pid.out
You can’t perform that action at this time.