Skip to content

Instantly share code, notes, and snippets.

View cplaisier's full-sized avatar

Christopher L Plaisier, PhD cplaisier

View GitHub Profile
@cplaisier
cplaisier / reannotate.py
Created July 19, 2011 22:42
Reannotating halobacterium with GO annotations from: ftp://ftp.geneontology.org/pub/go/ontology/gene_ontology.obo
goTerms = {}
inFile = open('gene_ontology.obo','r')
while 1:
line = inFile.readline()
if not line:
break
if line.strip()=='[Term]':
id1 = inFile.readline().strip().split('id: ')[1]
name = inFile.readline().strip().split('name: ')[1]
namespace = inFile.readline().strip().split('namespace: ')[1]
library(topGO)
# Read in GO mappings to gene ids
# <gene>\t<GOID>,<GOID>,...
vng2GO <- readMappings(file='vng2GO.map')
# Load up cluster or gene set identifiers
geneSets <- ## Depends on your analysis, list of vectors of gene ids
################
@cplaisier
cplaisier / FIRM.py
Created August 28, 2012 20:27
FIRM.py for single name signature files.
#################################################################
# @Program: FIRM.py #
# @Version: 1 #
# @Author: Christopher L Plaisier, PhD #
# @Sponsored by: #
# Nitin Baliga, ISB #
# Institute for Systems Biology #
# 401 Terry Ave North #
# Seattle, Washington 98109-5234 #
# (216) 732-2139 #
import cPickle, os, re, math
from pssm import pssm
from copy import deepcopy
from multiprocessing import Pool, cpu_count, Manager
from subprocess import *
# Make the files for a TomTom run
def makeQueryFile(nucFreqs, queryPssms, num, strands='+ -'):
# Header crap
memeHeader = ''
import glob
# Get a list of the '.clone' files in the
files = glob.glob('*.clone')
# Read in expression data and put it into a dictionary
matrixDictionary = {}
conditions = []
for file in files:
condition = file.split('.')[0]
@cplaisier
cplaisier / makeTable.py
Created September 2, 2014 18:58
Converting Files from htseq-count to Matrix
from subprocess import *
from shutil import move
import os
# Read in manifest of samples to process
samples = []
inFile = open('manifest.csv','r')
while 1:
line = inFile.readline()
if not line:
#################################################################
# @Program: tomtom.py #
# @Version: 1 #
# @Author: Chris Plaisier #
# @Sponsored by: #
# Nitin Baliga, ISB #
# Institute for Systems Biology #
# 1441 North 34th Street #
# Seattle, Washington 98103-8904 #
# (216) 732-2139 #
# Read in clusters of biclusters
clusters = {}
inFile = open('clustersOfBiclusters_VALL.csv','r')
inFile.readline() # Get rid of header
while 1:
line = inFile.readline()
if not line:
break
splitUp = line.strip().split(',')
if not splitUp[1] in clusters:
from subprocess import *
def phyper(q, m, n, k):
# Get an array of values to run
rProc = Popen('R --no-save --slave', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
runMe = []
for i in range(len(q)):
runMe.append('phyper('+str(q[i])+','+str(m[i])+','+str(n[i])+','+str(k[i])+',lower.tail=F)')
runMe = '\n'.join(runMe)+'\n'
out = rProc.communicate(runMe)
@cplaisier
cplaisier / makeSynoyms.py
Created February 3, 2015 18:42
makeSynoyms.py
entrezIds = {}
inFile = open('mart_export.txt','r')
inFile.readline() # Get rid of header
while 1:
line = inFile.readline()
if not line:
break
splitUp = line.strip().split(',')
if not splitUp[3]=='':
if not splitUp[3] in entrezIds: