Skip to content

Instantly share code, notes, and snippets.

View terrycojones's full-sized avatar

Terry Jones terrycojones

View GitHub Profile
#!/usr/bin/env python
import sys
seen = {}
for lineNumber, line in enumerate(sys.stdin):
if lineNumber:
fields = line.split('|')
key = '|'.join(fields[:2] + fields[3:])
#!/usr/bin/env python
import sys
from collections import defaultdict
seen = defaultdict(list)
for lineNumber, line in enumerate(sys.stdin):
if lineNumber:
fields = line.split('|')
Subjects (with offsets) by hash:
GB7:GA24:87
gi|285002301|ref|YP_003422365.1| envelope fusion protein [Pseudaletia unipuncta granulovirus] [453]
gi|311977556|ref|YP_003986676.1| hypothetical protein [Acanthamoeba polyphaga mimivirus] [88]
gi|9626461|ref|NP_059434.1| hypothetical protein JEVgp1 [Japanese encephalitis virus] [3118]
gi|20564197|ref|NP_620735.1| replication-associated protein [Tomato pseudo-curly top virus] [228]
gi|448825870|ref|YP_007418801.1| putative ankyrin repeat protein [Megavirus lba] [153]
gi|226377796|ref|YP_002790845.1| hypothetical protein lb338_phage_166 [Lactobacillus phage Lb338-1] [97]
gi|563397262|ref|YP_008857028.1| putative DNA ligase [Pseudomonas phage PAK_P5] [117]
gi|118197773|ref|YP_874166.1| hypothetical protein YS40_153 [Thermus phage phiYS40] [539]
from collections import defaultdict
def confusion(trueLabels, clusterLabels):
counts = defaultdict(lambda: defaultdict(int))
allLabels = sorted(set(trueLabels + clusterLabels))
for trueLabel, clusterLabel in zip(trueLabels, clusterLabels):
counts[trueLabel][clusterLabel] += 1
return allLabels, counts
from collections import Counter, defaultdict
class ConfusionMatrix(object):
def __init__(self, trueLabels, clusterLabels):
self._counts = defaultdict(Counter)
self.allLabels = set(trueLabels + clusterLabels)
for trueLabel, clusterLabel in zip(trueLabels, clusterLabels):
self._counts[trueLabel][clusterLabel] += 1
def __getitem__(self, item):
def checkAlphabet(self, count=10):
"""
"""
alphabet = Read.checkAlphabet(self, count)
if len(self) > 10 and alphabet.issubset(set('ACGT')):
raise ...
# using the new-style classes super():
def checkAlphabet(self, count=10):
#!/bin/bash
# A Git pre-commit hook.
#
# To install:
#
# $ cd .git/hooks
# $ ln -s ../../bin/pre-commit.sh pre-commit
# Add our virtualenv bin to PATH. Git commit seems to muck with PATH :-(
var wsuri = "ws://127.0.0.1:8080/ws";
var connection = new autobahn.Connection({
url: wsuri,
realm: "realm1",
use_deferred: jQuery.Deferred
});
var jqueryReady = jQuery.Deferred();
var routerReady = jQuery.Deferred();
$ ls -la /usr/local/bin/gcc*
lrwxr-xr-x 1 terry admin 7 Aug 6 2014 /usr/local/bin/gcc -> gcc-4.9
lrwxr-xr-x 1 terry admin 46 Sep 21 2014 /usr/local/bin/gcc-4.2 -> ../Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
lrwxr-xr-x 1 terry admin 33 Jan 14 10:04 /usr/local/bin/gcc-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-4.9
lrwxr-xr-x 1 terry admin 36 Jan 14 10:04 /usr/local/bin/gcc-ar-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-ar-4.9
lrwxr-xr-x 1 terry admin 36 Jan 14 10:04 /usr/local/bin/gcc-nm-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-nm-4.9
lrwxr-xr-x 1 terry admin 40 Jan 14 10:04 /usr/local/bin/gcc-ranlib-4.9 -> ../Cellar/gcc/4.9.2_1/bin/gcc-ranlib-4.9

Bayes is cool!

From the introduction to An Intuitive Explanation of Bayes' Theorem:

Your friends and colleagues are talking about something called "Bayes' Theorem" or "Bayes' Rule", or something called Bayesian reasoning. They sound really enthusiastic about it, too, so you google and find a webpage about Bayes' Theorem and... >