Skip to content

Instantly share code, notes, and snippets.

View fomightez's full-sized avatar

Wayne's Bioinformatics Code Portal fomightez

View GitHub Profile
ma7dev /
Last active September 5, 2022 13:23
takes requirements.txt file without module versions and annotates it with the latest set of module versions that won't result in build/runtime errors.
# TODO: you will need to have conda installed
# create a python environment
conda create -n env_tmp python=3.8.13 -y
# activate environment
conda activate env_tmp
ptmcg /
Last active March 1, 2022 20:16
Rich spinners for "the computer is thinking"
import rich.progress
import rich.spinner
import time
import random
class RandomChars(rich.progress.ProgressColumn):
"""Simulation of computer 'thinking' by displaying random characters
chars (str): characters from which to choose for display. Defaults to 0-9A-F.
parente /
Last active August 23, 2018 13:16
Jupyter Tidbit: %run your ipynb file


The %run magic provided by IPython not only supports the execution of regular Python scripts, it also runs Jupyter Notebook files (.ipynb).



The run_demo.ipynb notebook below uses %run to execute all of the cells in reusable_stuff.ipynb. Once it does, both globals defined in reusable_stuff are available in run_demo for use.

fomightez /
Created March 28, 2018 17:33
do something every eight minutes with Python
import time
def executeSomething():
#code here
print ('.')
time.sleep(480) #60 seconds times 8 minutes
while True:
View r_logo.R
plot_fun <- function(sim) {
df <- as_tibble(sim)
plot(df$x, df$y, col = df$color, pch = '.', axes = FALSE, xlim = c(-100, 317), ylim = c(-268, 100), xlab = NA, ylab = NA)
fomightez /
Last active September 15, 2023 09:59
Useful Python snippets
# These are meant to work in both Python 2 and 3, except where noted.
# See my for those related to dataframes (such as pickling/`df.to_pickle(save_as)`)
# also see for examples of my
# frequently used Python functions and slight variations for more expanded, modular structures.
# good snippet collection at
astrojuanlu / Visualizing the SpaceX Tesla Roadster trip to Mars.ipynb
Created February 18, 2018 11:11
Visualizing the SpaceX Tesla Roadster trip to Mars
View Visualizing the SpaceX Tesla Roadster trip to Mars.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
anonymous /
Created February 15, 2018 21:03
# Get a list of all organisms
curl -s "" > organisms-all.txt
# Get just a few of interest
cat organisms-all.txt | awk '$2~/^(hsa|mmu|rno|cfa|bta|gga|xla|xtr|dre|dme|cel|ath|ehi|tgo|eco|sau|mtu|mav|cje|ccol)$/' > organisms-of-interest.txt
# Get the accession codes for each
cut -f1 organisms-of-interest.txt > organisms-of-interest-codes.txt
# Make a directory to put all the kgml files downloaded
evanmiltenburg /
Created February 13, 2018 15:02
Circles in legend
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.lines import Line2D
my_palette = sns.color_palette("cubehelix", 3)
def legend_circles(labels, palette, loc=1, markersize=10, marker='o', padding=0):
"Make a legend where the color is indicated by a circle."
fomightez /
Last active October 10, 2023 20:43 — forked from bsweger/
Useful Pandas Snippets
# List unique values in a DataFrame column
df['Column Name'].unique()
# To extract a specific column (subset the dataframe), you can use [ ] (brackets) or attribute notation.
# are same thing!!! (from
# -or-