Skip to content

Instantly share code, notes, and snippets.

View geraldmc's full-sized avatar
🏠
Working from home

Gerald McCollam geraldmc

🏠
Working from home
  • Terre Bon Bioscience LLC
  • Houma, LA
View GitHub Profile
@geraldmc
geraldmc / ncbi_to_omim.py
Last active August 23, 2019 17:06
Read NCBI and OMIM gene id's, return a dict keyed by NCBI number.
def omim_from_entrez():
"""Return a mapping from NCBI GeneIDs to OMIM IDs.
Returns 17,108 entries from an original 26,371.
Sorted by key.
"""
fp = './app/data/mim2gene.txt' # https://www.omim.org/static/omim/data/mim2gene.txt
df = pd.read_csv(fp, skiprows=4, sep='\t',
usecols=['# MIM Number', 'Entrez Gene ID (NCBI)'])
df.columns = ['omim', 'ncbi'] # rename columns
df = df[np.isfinite(df['ncbi'])] # remove NaN's from ncbi
@geraldmc
geraldmc / get_greyscale.py
Last active April 11, 2019 20:42
Use GDAL to open a 4-band image
# Using GDAL to open a 4-band image created by Sequoia camera.
from osgeo import gdal # Geospatial Data Abstraction Library
import numpy as np
import sys, os, re
def get_raster_bands(src_grayscale):
"""
Each band is a 2d numpy array of real luminosity values.
"""
@geraldmc
geraldmc / ipy.sh
Created May 24, 2017 12:53
configure ipython within a virtualenv
alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
@geraldmc
geraldmc / pep20_by_example.py
Created February 22, 2017 03:38 — forked from evandrix/pep20_by_example.py
PEP 20 (The Zen of Python) by example
#!/usr/bin/env python
"""
=====================================
PEP 20 (The Zen of Python) by example
=====================================
Usage: %prog
:Author: Hunter Blanks, hblanks@artifex.org / hblanks@monetate.com
@geraldmc
geraldmc / nyt_article_search_api.py
Created February 7, 2017 16:54
Stand-alone script to search NYT articles, based on Evan Sherlock's original. Python3 enabled.
import requests
'''
Stand-alone script to search NYT articles, based on Evan Sherlock's original. Python3 enabled.
>> import nyt_article_search_api as nyt
>> api = nyt.articleAPI()
>> api/search()
'''
@geraldmc
geraldmc / show_RAM.sh
Created August 14, 2016 22:15
Show available memory from command line (Ubuntu).
lshw -C memory 2>/dev/null | grep -Po ' +size: \K.*'
@geraldmc
geraldmc / find_largest.sh
Created August 7, 2016 21:40
find top ten largest files from target (here /var)
du -a /var | sort -n -r | head -n 10
library(igraph)
library(rgexf)
library(ggplot2)
# ggnet2 is available through the GGally package
# install.packages("GGally")
library(GGally)
# Following libraries will be required - used internally.
lapply(c("sna", "scales","intergraph", "network"),require, character.only=T)
@geraldmc
geraldmc / simplest_luigi.py
Created July 26, 2016 20:28
simplest workflow
import luigi
class FirstTask(luigi.Task):
# The date when 'whatever' will be run.
upload_date_param = luigi.DateParameter()
def requires(self):
"""
What needs to happen before FirstTask begins?
@geraldmc
geraldmc / three_tasks.py
Created July 26, 2016 20:20
simple luigi example w/ three tasks
import luigi
from luigi.mock import MockTarget
class FirstTask(luigi.Task):
def output(self):
return MockTarget("SimpleTask",
mirror_on_stderr=True)
def run(self):
_write = self.output().open('w')