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 / data.csv
Last active August 29, 2015 14:16
A simple kNN implementation
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
@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
@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 / hello.fa
Created August 24, 2015 21:50
Multiple file suffixes in makefile rules
>sequence 1
ACTG
@ivan-krukov
ivan-krukov / volume
Created August 2, 2012 23:18
Change the OS X sound volume from the command line
! /usr/bin/osascript
on run argv
set Volume (item 1 of argv)
end run
@ivan-krukov
ivan-krukov / kyles_script.py
Created August 9, 2012 17:19
Header remover
import argparse
from Bio import SeqIO
parser=argparse.ArgumentParser()
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
ivan-krukov / fastaparse.py
Created August 9, 2012 18:20
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 = f.read()
@ivan-krukov
ivan-krukov / splitter.sh
Created August 17, 2012 18:28
This atrocious shell script prints the first 1/nth (half, third, etc) part of a file
#!/bin/sh
#get the command line arguments
input_file=$1
divisor=$2
#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
part=$(($1/$divisor))
@ivan-krukov
ivan-krukov / oggle.sh
Created November 10, 2012 01:20
A little output logging tool
#!/bin/sh
cmd=$*
pid=$$
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
@ivan-krukov
ivan-krukov / fastq_sample.py
Created November 21, 2012 20:04
Random sample of a FASTQ file
#Take a fraction of random sequence reads from a fastq file
from sh import wc
import argparse
import random
def first_word(string):
return string.strip().split()[0]
#read a file in chunks of deflines
def read_segments(filename,deflines):