Skip to content

Instantly share code, notes, and snippets.

View dwinter's full-sized avatar
🐢
I may be slow to respond.

David Winter dwinter

🐢
I may be slow to respond.
View GitHub Profile
/*
* I updated to Ubiquity 0.5 but found that broke
* Julien Couvreur's set-proxy command:
* http://blog.monstuff.com/archives/000342.html.
* So here is a re-write for the new parser.
*/
CmdUtils.CreateCommand({
names: ["set proxy", "proxy", "setproxy"],
description: "Switch you proxy without going through the preferences menu",
# -*- coding: utf-8 -*-
import random
class Lineage:
""" Model one independantly evolving lineage """
def __init__(self, complexity= 0, min = None):
self.complexity = complexity
self.min = min
def __repr__(self):
@dwinter
dwinter / ring.r
Created February 28, 2011 11:59
plotting and testing some of Ken Ring's theories
We couldn’t find that file to show.
class ORFFinder:
"""Find the longest ORF in a given sequence
"seq" is a string, if "start" is not provided any codon can be the start of
and ORF. If muliple ORFs have the longest length the first one encountered
is printed
"""
def __init__(self, seq, start=[], stop=["TAG", "TAA", "TGA"]):
self.seq = seq
self.start = start
@dwinter
dwinter / MontyPython.py
Created April 18, 2011 00:38
Code to run simulation of the Monty hall problem
# -*- coding: utf-8 -*-
import random
def round(switch=True):
doors = ['car', 'goat', 'goat']
pick = random.randrange(3)
print "the RNG picked door %s" % (pick + 1)
#monty knows where the car is
car = doors.index('car')
#and he opens a door without the car
"""
Code writted to answer this challenge at Biostar:
http://biostar.stackexchange.com/questions/5902/
(This code includes improvements from Brad Chapman)
"""
class ORFFinder:
"""Find the longest ORF in a given sequence
"seq" is a string, if "start" is not provided any codon can be the start of
"""
Code written to answer stackoverflow question on substitution matrices:
http://stackoverflow.com/questions/5686211/
"""
from Bio.SubsMat import MatrixInfo
def score_match(pair, matrix):
"""
Return score for a given pair of residues in a give matrix.
import numpy as np
from scipy import cluster
from matplotlib import pyplot
#fake some data
tests = np.reshape( np.random.uniform(0,100,60), (30,2) )
#plot remaining variance for each value for 'k' between 1,10
initial = [cluster.vq.kmeans(tests,i) for i in range(1,10)]
pyplot.plot([var for (cent,var) in initial])
@dwinter
dwinter / fungi_step1.py
Created September 3, 2011 04:24
An online fungal foray
from Bio import Entrez
#Let NCBI know who you are in case you do something stupid :)
Entrez.email = 'your.name.here@someplace.com'
search_s ='"ectomycorrhizal root tip" AND "New Zealand"'
handle = Entrez.esearch(db='nucleotide', term=search_s, retmax=100)
ids = Entrez.read(handle)['IdList']
ids[:5]