Skip to content

Instantly share code, notes, and snippets.

View cthoyt's full-sized avatar

Charles Tapley Hoyt cthoyt

View GitHub Profile
@cthoyt
cthoyt / jennie-unpivot.py
Created September 21, 2015 19:15
Jennie's Unpivot
# open up the file
with open("filepath") as f:
# read the first line, this contains all of the header information
# then, get rid of whitespace with strip, and split into an array on each tab
header = f.readline().strip().split("\t")
# only keep the important header columns (delete leftmost element)
header = header[1:]
@cthoyt
cthoyt / BiologicalDatabasesDayOne.ipynb
Created January 12, 2016 20:10
Biological Databases Practical 2016 Day 1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / ExerciseSolutions.sql
Last active January 18, 2016 13:59
Biological Databases Practical 2016 Day 2
/* How many countries exist */
select count(*) as num_countries
from country;
/* Select the first 10 countries and order them by name */
select *
from country
order by country.Name
limit 10;
@cthoyt
cthoyt / Day3.ipynb
Created January 19, 2016 13:03
Biological Databases Exercise 2015
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cthoyt
cthoyt / blast_problem.py
Last active January 27, 2016 16:50
Solves the BLAST Problem from Bioinformatics Class on 27.01.16
#!/usr/bin/env python
# Author: Charlie Hoyt
import itertools as itt
s = {
('A','A'): 5,
('A','R'): -2,
('A','N'): -1,
('A','D'): -2,
@cthoyt
cthoyt / SmilesServer.py
Created January 30, 2016 20:47
Troubleshooting SMILES Server with Flask and RDKit
#!/usr/bin/env python3
from flask import Flask, request, make_response
from rdkit import Chem, rdBase
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D
app = Flask(__name__)
@cthoyt
cthoyt / toy_gene_coexp.py
Created April 9, 2016 16:33
Generate a toy gene co-expression network
import numpy as np
import pandas as pd
# Represent different entities with these letters
letters = list("abcdefghjkmnopqrstuvwxyzABCDEFGHIJKLMN")
l = int(0.2 * np.square(len(letters)))
g = np.random.choice(letters, size=(l, 2))
n = np.random.uniform(size=l).round(3)
@cthoyt
cthoyt / coalesce_zeta.py
Last active August 12, 2016 09:45
This script coalesces the results from running Fraunhofer FIT ZETA and merges all of the output files from the evaluation task.
#! /usr/bin/env python3
"""
This script coalesces the results from running Fraunhofer FIT ZETA and
merges all of the output files from the evaluation task.
From the terminal, run something like:
`python3 coalesce_zeta_results.py -d ~/Desktop/HCA\ 2016\ Data/assay/resultPath -o ~/Desktop/coalesced.csv`

Keybase proof

I hereby claim:

  • I am cthoyt on github.
  • I am cthoyt (https://keybase.io/cthoyt) on keybase.
  • I have a public key whose fingerprint is 91A7 A8AA B13B E6CE 6812 DD70 8FCE 28AC BC44 3133

To claim this, I am signing this object:

def parse_bertini_main_data(fl):
"""
Parses main_data output from Bertini 1.5.1
:param fl: file object for main_data
:type f1: file-like object
:return: list of solutions
"""
it = (line.strip() for line in fl)
number_variables = next(it)
solution_dimension = int(number_variables[21:])