Skip to content

Instantly share code, notes, and snippets.

View cthoyt's full-sized avatar
💭
On sabbatical - unable to respond until Fall 2024.

Charles Tapley Hoyt cthoyt

💭
On sabbatical - unable to respond until Fall 2024.
View GitHub Profile
@cthoyt
cthoyt / hbp_ideogram.html
Created February 7, 2019 12:50
Ideogram of the Human Brain Pharmacome Repository
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Human Brain Pharmacome Knowledge</title>
<script src="https://unpkg.com/ideogram@1.5.0/dist/js/ideogram.min.js"></script>
</head>
<body>
<script>
var ideogram = new Ideogram({
import pubchempy as pcp
keys = '''MXDPZUIOZWKRAA-UZOALHFESA-K
MJUVRTYWUMPBTR-MRXNPFEDSA-N
HJBWBFZLDZWPHF-UHFFFAOYSA-N
HZIYEEMJNBKMJH-UHFFFAOYSA-N
CPZBLNMUGSZIPR-NVXWUHKLSA-N
GKDRMWXFWHEQQT-UHFFFAOYSA-N
KSMAGQUYOIHWFS—UHFFFAOYSA-N
OFZJKCQENFPZBH-UHFFFAOYSA-N
@cthoyt
cthoyt / truthycontext.py
Last active September 6, 2017 18:22
A context manager using frame hacks to only run when truthy
import unittest
from contextlib import contextmanager
# see https://stackoverflow.com/questions/12594148/skipping-execution-of-with-block
@contextmanager
def when_truthy(argument):
"""
The point of this function is to make it so you never have to write
@cthoyt
cthoyt / update_resources.sh
Last active July 20, 2017 10:32
Update BEL Resources on Artifactory with Selventa Generator
#!/usr/bin bash
mkdir output
# Download and install pybel-tools
git clone https://github.com/pybel/pybel-tools
cd pybel-tools
python3 -m pip install --user .
cd ..
@cthoyt
cthoyt / use_pip.py
Created April 28, 2017 19:04
Programatically use pip
# Pip is actually a python package!
import pip
# It's screwy and not really written to be used this way, but we still can
pip_install_cmd = pip.commands.InstallCommand()
# load up all the args you'd use after pip install and away we go!
args = ['--upgrade', '--user', 'requests']
pip_install_cmd.main(args)
@cthoyt
cthoyt / compare_bel_compilers.sh
Created January 26, 2017 21:46
Compares Java, Python, and Ruby BEL compilers
mkdir /tmp/beltest
cd /tmp/beltest
curl http://resources.openbel.org/belframework/1.0/knowledge/small_corpus.bel > small.bel
curl http://resources.openbel.org/belframework/1.0/knowledge/large_corpus.bel > large.bel
# Test Python
python -m pip install pybel
time python -m pybel convert --path small.bel --pickle small.gpickle
time python -m pybel convert --path large.bel --pickle large.gpickle
@cthoyt
cthoyt / process.sh
Created November 9, 2016 18:33
Bel.rb Installation trouble
[544] [19:04] [cthoyt@microvac:~]
$ rvm use 2.3.0 --install
ruby-2.3.0 is not installed - installing.
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.3.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/cthoyt/.rvm/rubies/ruby-2.3.0, this may take a while depending on your cpu(s)...
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:])

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:

@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`