Skip to content

Instantly share code, notes, and snippets.

@sxv
sxv / combine_raw_reads.py
Created November 18, 2017 08:30
take ENS gene id and gene name and append col[2:] from input files
import sys
rows = []
for line in open('gene_names.csv'):
a,b,c = line.replace('\n','').split(',')
rows.append([a,c])
for file in sys.argv[1:]:
for i, line in enumerate(open(file)):
@sxv
sxv / catan_boards.py
Last active May 14, 2018 17:51
script to run simulations of settlers of catan board tile setups to find the average number of games played before encountering a duplicate arrangement.
import sys, random
# board is defined as list of 19 land tiles: Forest (4), Sheep (4), Wheat (4), Brick (3), Rocks (3), Desert (1)
def new_board(board=''):
available = list('ffffsssswwwwbbbrrrd')
for i in range(19):
random.shuffle(available)
board += available.pop()
return board
@sxv
sxv / README.md
Last active July 3, 2018 07:20
Interactive SVG + Canvas Plot

A D3 demonstration of SVG and Canvas intermingling. Blue circles are plotted in SVG, black circles in canvas. One force to rule them all. The plot is zoomable and pannable.

Inspired by M. Bostock's Canvas / SVG zoom comparison series and collision detection examples [1] [2] .