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
ma7dev / cool_script.sh
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.
View cool_script.sh
#!/bin/bash
# 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
ptmcg / computer_thinking_spinners.py
Last active March 1, 2022 20:16
Rich spinners for "the computer is thinking"
View computer_thinking_spinners.py
import rich.progress
import rich.spinner
import time
import random
class RandomChars(rich.progress.ProgressColumn):
"""Simulation of computer 'thinking' by displaying random characters
Args:
chars (str): characters from which to choose for display. Defaults to 0-9A-F.
@parente
parente / README.md
Last active August 23, 2018 13:16
Jupyter Tidbit: %run your ipynb file
View README.md

Summary

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

Example

Binder

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
fomightez / run_every_eight_mins.py
Created March 28, 2018 17:33
do something every eight minutes with Python
View run_every_eight_mins.py
import time
def executeSomething():
#code here
print ('.')
time.sleep(480) #60 seconds times 8 minutes
while True:
executeSomething()
View r_logo.R
library(magick)
library(reshape2)
library(dplyr)
library(tidygraph)
library(particles)
library(animation)
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
fomightez / useful_python_snippets.py
Last active September 15, 2023 09:59
Useful Python snippets
View useful_python_snippets.py
# These are meant to work in both Python 2 and 3, except where noted.
# See my useful_pandas_snippets.py for those related to dataframes (such as pickling/`df.to_pickle(save_as)`)
# https://gist.github.com/fomightez/ef57387b5d23106fabd4e02dab6819b4
# also see https://gist.github.com/fomightez/324b7446dc08e56c83fa2d7af2b89a33 for examples of my
# frequently used Python functions and slight variations for more expanded, modular structures.
#argparse
# good snippet collection at https://mkaz.tech/code/python-argparse-cookbook/
@astrojuanlu
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
anonymous / download_kegg.sh
Created February 15, 2018 21:03
View download_kegg.sh
# Get a list of all organisms
curl -s "http://rest.kegg.jp/list/organism" > 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
evanmiltenburg / legend_circles.py
Created February 13, 2018 15:02
Circles in legend
View legend_circles.py
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.lines import Line2D
my_palette = sns.color_palette("cubehelix", 3)
sns.set_palette(my_palette)
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
fomightez / useful_pandas_snippets.py
Last active October 10, 2023 20:43 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
View useful_pandas_snippets.py
# 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.
df.height
df['height']
# are same thing!!! (from http://www.stephaniehicks.com/learnPython/pages/pandas.html
# -or-
# http://www.datacarpentry.org/python-ecology-lesson/02-index-slice-subset/)